Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only audit appcast URL if specified and check its contents. #8613

Merged
merged 2 commits into from
Sep 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def check_token_bad_words
add_warning "cask token contains .app" if token.end_with? ".app"

if /-(?<designation>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
Expand Down Expand Up @@ -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}"
Expand All @@ -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
Expand Down