From 012bd1f1348224d12d4888aa7c5af841dad4cbd8 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sun, 30 Oct 2022 15:00:56 +0100 Subject: [PATCH 1/3] cask: audit for minimal OS version in sparkle feeds --- Library/Homebrew/cask/audit.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 840cfff921..6b0e4e1858 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -545,6 +545,37 @@ module Cask false end + def check_livecheck_min_os + return unless cask.livecheckable? + return unless cask.livecheck.strategy == :sparkle + + out, _, status = curl_output(cask.livecheck.url) + return unless status.success? + + require "rexml/document" + + xml = begin + REXML::Document.new(out) + rescue + nil + end + + return if xml.blank? + + item = xml.get_elements("//rss//channel//item").first + return if item.blank? + + min_os = item.elements["sparkle:minimumSystemVersion"].text + return if min_os.blank? + + min_os_string = OS::Mac::Version.new(min_os).strip_patch + cask_min_os = cask.depends_on.macos.version + + return if cask_min_os == min_os_string + + add_error "Upstream defined #{min_os_string} as minimal OS version and the cask defined #{cask_min_os}" + end + sig { void } def check_appcast_contains_version return unless appcast? From b27aeb8f946119e0d6cce099489e9881511d1f55 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sun, 30 Oct 2022 19:41:51 +0100 Subject: [PATCH 2/3] Update Library/Homebrew/cask/audit.rb Co-authored-by: Bo Anderson --- Library/Homebrew/cask/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 6b0e4e1858..e53fe30487 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -556,7 +556,7 @@ module Cask xml = begin REXML::Document.new(out) - rescue + rescue REXML::ParseException nil end From 73d124f34282317d9cd95db6b5238e337a3e8bb9 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Mon, 31 Oct 2022 09:00:43 +0100 Subject: [PATCH 3/3] audit: make min OS check depend on online? --- Library/Homebrew/cask/audit.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index e53fe30487..3f714edc66 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -546,6 +546,7 @@ module Cask end def check_livecheck_min_os + return unless online? return unless cask.livecheckable? return unless cask.livecheck.strategy == :sparkle