Merge pull request #14060 from SMillerDev/feature/cask/minos_audit

cask: audit for minimal OS version in sparkle feeds
This commit is contained in:
Mike McQuaid 2022-11-01 12:46:48 +00:00 committed by GitHub
commit 29e3e5906b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -545,6 +545,38 @@ module Cask
false
end
def check_livecheck_min_os
return unless online?
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 REXML::ParseException
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?