audit: refactor http content checks.
This commit is contained in:
parent
125a6eee21
commit
5390897883
@ -1492,7 +1492,7 @@ class ResourceAuditor
|
|||||||
urls.each do |url|
|
urls.each do |url|
|
||||||
strategy = DownloadStrategyDetector.detect(url)
|
strategy = DownloadStrategyDetector.detect(url)
|
||||||
if strategy <= CurlDownloadStrategy && !url.start_with?("file")
|
if strategy <= CurlDownloadStrategy && !url.start_with?("file")
|
||||||
check_http_mirror url
|
check_http_content url
|
||||||
elsif strategy <= GitDownloadStrategy
|
elsif strategy <= GitDownloadStrategy
|
||||||
unless Utils.git_remote_exists url
|
unless Utils.git_remote_exists url
|
||||||
problem "The URL #{url} is not a valid git URL"
|
problem "The URL #{url} is not a valid git URL"
|
||||||
@ -1505,7 +1505,7 @@ class ResourceAuditor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_http_mirror(url)
|
def check_http_content(url)
|
||||||
details = get_content_details(url)
|
details = get_content_details(url)
|
||||||
|
|
||||||
if details[:status].nil?
|
if details[:status].nil?
|
||||||
@ -1519,10 +1519,16 @@ class ResourceAuditor
|
|||||||
secure_url = url.sub "http", "https"
|
secure_url = url.sub "http", "https"
|
||||||
secure_details = get_content_details(secure_url)
|
secure_details = get_content_details(secure_url)
|
||||||
|
|
||||||
return if !details[:status].start_with?("2") || !secure_details[:status].start_with?("2")
|
if !details[:status].to_s.start_with?("2") ||
|
||||||
|
!secure_details[:status].to_s.start_with?("2")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
etag_match = details[:etag] && details[:etag] == secure_details[:etag]
|
etag_match = details[:etag] &&
|
||||||
content_length_match = details[:content_length] && details[:content_length] == secure_details[:content_length]
|
details[:etag] == secure_details[:etag]
|
||||||
|
content_length_match =
|
||||||
|
details[:content_length] &&
|
||||||
|
details[:content_length] == secure_details[:content_length]
|
||||||
file_match = details[:file_hash] == secure_details[:file_hash]
|
file_match = details[:file_hash] == secure_details[:file_hash]
|
||||||
|
|
||||||
return if !etag_match && !content_length_match && !file_match
|
return if !etag_match && !content_length_match && !file_match
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user