Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
094cab89
Unverified
Commit
094cab89
authored
6 years ago
by
L. E. Segovia
Browse files
Options
Downloads
Patches
Plain Diff
Cask: remove curl calls, use them with --download
parent
32246dd0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Library/Homebrew/cask/audit.rb
+1
-0
1 addition, 0 deletions
Library/Homebrew/cask/audit.rb
Library/Homebrew/cask/auditor.rb
+1
-1
1 addition, 1 deletion
Library/Homebrew/cask/auditor.rb
Library/Homebrew/utils/curl.rb
+23
-31
23 additions, 31 deletions
Library/Homebrew/utils/curl.rb
with
25 additions
and
32 deletions
Library/Homebrew/cask/audit.rb
+
1
−
0
View file @
094cab89
...
...
@@ -321,6 +321,7 @@ module Cask
end
def
check_https_availability
return
unless
download
unless
cask
.
url
.
to_s
.
empty?
||
cask
.
url
.
using
check_url_for_https_availability
(
cask
.
url
,
user_agents:
[
cask
.
url
.
user_agent
])
end
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/cask/auditor.rb
+
1
−
1
View file @
094cab89
...
...
@@ -60,7 +60,7 @@ module Cask
download
=
audit_download?
&&
Download
.
new
(
cask
,
quarantine:
quarantine?
)
audit
=
Audit
.
new
(
cask
,
download:
download
,
check_token_conflicts:
check_token_conflicts?
,
commit_range:
commit_range
)
commit_range:
commit_range
)
audit
.
run!
puts
audit
.
summary
audit
.
success?
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/utils/curl.rb
+
23
−
31
View file @
094cab89
...
...
@@ -92,6 +92,12 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
return
"The URL
#{
url
}
is not reachable (HTTP status code
#{
details
[
:status
]
}
)"
end
if
url
.
start_with?
(
"https://"
)
&&
ENV
[
"HOMEBREW_NO_INSECURE_REDIRECT"
]
unless
details
[
:final_url
].
start_with?
(
"https://"
)
return
"The URL
#{
url
}
redirects back to HTTP"
end
end
return
unless
hash_needed
secure_url
=
url
.
sub
"http"
,
"https"
...
...
@@ -111,7 +117,9 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
file_match
=
details
[
:file_hash
]
==
secure_details
[
:file_hash
]
if
etag_match
||
content_length_match
||
file_match
return
curl_check_http_redirections
(
secure_url
,
original_url:
url
,
user_agents:
user_agents
)
if
secure_details
[
:final_url
].
start_with?
(
"https://"
)
return
"The URL
#{
url
}
should use HTTPS rather than HTTP"
if
url
.
start_with?
(
"http://"
)
end
end
return
unless
check_content
...
...
@@ -122,7 +130,9 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
# Check for the same content after removing all protocols
if
details
[
:file
]
==
secure_details
[
:file
]
return
curl_check_http_redirections
(
secure_url
,
original_url:
url
,
user_agents:
user_agents
)
if
secure_details
[
:final_url
].
start_with?
(
"https://"
)
return
"The URL
#{
url
}
should use HTTPS rather than HTTP"
if
url
.
start_with?
(
"http://"
)
end
end
return
unless
strict
...
...
@@ -142,7 +152,7 @@ end
def
curl_http_content_headers_and_checksum
(
url
,
hash_needed:
false
,
user_agent: :default
)
max_time
=
hash_needed
?
"600"
:
"25"
output
,
=
curl_output
(
"--connect-timeout"
,
"15"
,
"--include"
,
"--max-time"
,
max_time
,
"--location"
,
url
,
"--head"
,
"--connect-timeout"
,
"15"
,
"--include"
,
"--max-time"
,
max_time
,
"--location"
,
url
,
user_agent:
user_agent
)
...
...
@@ -150,11 +160,21 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent:
while
status_code
==
:unknown
||
status_code
.
to_s
.
start_with?
(
"3"
)
headers
,
_
,
output
=
output
.
partition
(
"
\r\n\r\n
"
)
status_code
=
headers
[
%r{HTTP
\/
.* (
\d
+)}
,
1
]
location
=
headers
[
/^Location:\s*(.*)$/i
,
1
]
# puts "URL: #{url}, location: #{location.inspect}, status: #{status_code}"
# puts headers
unless
location
.
nil?
final_url
=
location
.
chomp
end
end
output_hash
=
Digest
::
SHA256
.
digest
(
output
)
if
hash_needed
final_url
=
url
if
final_url
.
nil?
{
url:
url
,
final_url:
final_url
,
status:
status_code
,
etag:
headers
[
%r{ETag: ([wW]
\/
)?"(([^"]|
\\
")*)"}
,
2
],
content_length:
headers
[
/Content-Length: (\d+)/
,
1
],
...
...
@@ -162,31 +182,3 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent:
file:
output
,
}
end
def
curl_check_http_redirections
(
url
,
original_url:
nil
,
user_agents:
[
:default
])
out
,
_
,
status
=
curl_output
(
"--location"
,
"--silent"
,
"--head"
,
url
.
to_s
)
lines
=
status
.
success?
?
out
.
lines
.
map
(
&
:chomp
)
:
[]
locations
=
lines
.
map
{
|
line
|
line
[
/^Location:\s*(.*)$/i
,
1
]
}
.
compact
redirect_url
=
locations
.
reduce
(
url
)
do
|
current_url
,
location
|
if
location
.
start_with?
(
"/"
)
uri
=
URI
(
current_url
)
"
#{
uri
.
scheme
}
://
#{
uri
.
host
}#{
location
}
"
else
location
end
end
if
original_url
.
start_with?
(
"https://"
)
unless
redirect_url
.
start_with?
(
"https://"
)
return
"The URL
#{
original_url
}
redirects back to HTTP"
end
elsif
url
.
start_with?
(
"https://"
)
if
redirect_url
.
start_with?
(
"https://"
)
return
"The URL
#{
original_url
}
should use HTTPS rather than HTTP"
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment