From 05cf8f42e0ee754a408473ca4c54de1cf389ef24 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 5 Sep 2020 04:08:34 +0200 Subject: [PATCH 1/2] Only audit appcast URL if specified and check its contents. --- Library/Homebrew/cask/audit.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index db3ffb71e3a55..ebd9c8035cb49 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -571,15 +571,15 @@ def check_denylist def check_https_availability return unless download - if !cask.url.blank? && !cask.url.using - check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent]) - end - check_url_for_https_availability(cask.appcast) unless cask.appcast.blank? - check_url_for_https_availability(cask.homepage, user_agents: [:browser]) unless cask.homepage.blank? + check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent]) if cask.url && !cask.url.using + + check_url_for_https_availability(cask.appcast, check_content: true) if cask.appcast && appcast? + + check_url_for_https_availability(cask.homepage, check_content: true, user_agents: [:browser]) if cask.homepage end - def check_url_for_https_availability(url_to_check, user_agents: [:default]) - problem = curl_check_http_content(url_to_check.to_s, user_agents: user_agents) + def check_url_for_https_availability(url_to_check, **options) + problem = curl_check_http_content(url_to_check.to_s, **options) add_error problem if problem end end From 6194155765ab91031efc23cd34b51c263fbffcf3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 5 Sep 2020 04:13:07 +0200 Subject: [PATCH 2/2] Use `official?` for checking tap. --- Library/Homebrew/cask/audit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index ebd9c8035cb49..5072c0098b30a 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -395,7 +395,7 @@ def check_token_bad_words add_warning "cask token contains .app" if token.end_with? ".app" if /-(?alpha|beta|rc|release-candidate)$/ =~ cask.token && - cask.tap.official? && + cask.tap&.official? && cask.tap != "homebrew/cask-versions" add_warning "cask token contains version designation '#{designation}'" end @@ -562,7 +562,7 @@ def get_repo_data(regex) end def check_denylist - return if cask.tap&.user != "Homebrew" + return unless cask.tap&.official? return unless reason = Denylist.reason(cask.token) add_error "#{cask.token} is not allowed: #{reason}"