aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorDavid Broder-Rodgers2017-02-20 19:00:27 +0000
committerDavid Broder-Rodgers2017-02-20 19:24:35 +0000
commit55bc2a30195db915a60c862bf1c3d4ba6cd3cd4a (patch)
treeb129dd008285b8e4e0593c7ff67d856d6006fc9e /Library/Homebrew/dev-cmd
parent12501b4046339b6becd42e37730873babeaa9dc2 (diff)
downloadbrew-55bc2a30195db915a60c862bf1c3d4ba6cd3cd4a.tar.bz2
Merged 404 and security mirror auditing logic
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 180783f79..6e454f4d2 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -174,7 +174,7 @@ class FormulaAuditor
@specs = %w[stable devel head].map { |s| formula.send(s) }.compact
end
- def self.url_status_code(url, range: false)
+ def url_status_code(url, range: false)
# The system Curl is too old and unreliable with HTTPS homepages on
# Yosemite and below.
return "200" unless DevelopmentTools.curl_handles_most_https_homepages?
@@ -619,8 +619,8 @@ class FormulaAuditor
return unless @online
- status_code = FormulaAuditor.url_status_code(homepage, user_agent: :browser)
- return if status_code.start_with? "20"
+ status_code = url_status_code(homepage)
+ return if status_code.start_with? "2"
problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})"
end
@@ -1492,11 +1492,7 @@ class ResourceAuditor
urls.each do |url|
strategy = DownloadStrategyDetector.detect(url)
if strategy <= CurlDownloadStrategy && !url.start_with?("file")
- problem url
- status_code = FormulaAuditor.url_status_code url
- unless status_code.start_with? "2"
- problem "The URL #{url} is not reachable (HTTP status code #{status_code})"
- end
+ check_http_mirror url
elsif strategy <= GitDownloadStrategy
unless Utils.git_remote_exists url
problem "The URL #{url} is not a valid git URL"
@@ -1506,12 +1502,20 @@ class ResourceAuditor
problem "The URL #{url} is not a valid svn URL"
end
end
- check_insecure_mirror(url) if url.start_with? "http:"
end
end
- def check_insecure_mirror(url)
+ def check_http_mirror(url)
details = get_content_details(url)
+
+ if details[:status].nil?
+ problem "The URL #{url} is not reachable"
+ elsif !details[:status].start_with? "2"
+ problem "The URL #{url} is not reachable (HTTP status code #{details[:status]})"
+ end
+
+ return unless url.start_with? "http:"
+
secure_url = url.sub "http", "https"
secure_details = get_content_details(secure_url)