Skip to content

Commit

Permalink
rubocops/shared/url_helper: tweak SourceForge handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Oct 24, 2024
1 parent e8ee210 commit 0341300
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Library/Homebrew/rubocops/shared/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def audit_url(type, urls, mirrors, livecheck_url: false)
%r{^http://hackage\.haskell\.org/},
%r{^http://(?:[^/]*\.)?archive\.org},
%r{^http://(?:[^/]*\.)?freedesktop\.org},
%r{^http://(?:[^/]*\.)?mirrorservice\.org/}])
%r{^http://(?:[^/]*\.)?mirrorservice\.org/},
%r{^http://downloads?.sourceforge\.net/}])

Check failure

Code scanning / CodeQL

Incomplete regular expression for hostnames High

This regular expression has an unescaped '.' before 'sourceforge\.net/', so it might match more hosts than expected.
audit_urls(urls, http_to_https_patterns) do |_, url, index|
# It's fine to have a plain HTTP mirror further down the mirror list.
https_url = url.dup.insert(4, "s")
Expand Down Expand Up @@ -153,7 +154,7 @@ def audit_url(type, urls, mirrors, livecheck_url: false)

problem "Don't use /download in SourceForge urls (url is #{url})." if url.end_with?("/download")

if url.match?(%r{^https?://sourceforge\.}) && url != livecheck_url
if url.match?(%r{^https?://(sourceforge|sf)\.}) && url != livecheck_url
problem "Use https://downloads.sourceforge.net to get geolocation (url is #{url})."
end

Expand All @@ -165,7 +166,10 @@ def audit_url(type, urls, mirrors, livecheck_url: false)
problem "Don't use specific dl mirrors in SourceForge urls (url is #{url})."
end

problem "Please use https:// for #{url}" if url.start_with? "http://downloads"
# sf.net does HTTPS -> HTTP redirects.
if url.match?(%r{^https?://downloads?\.sf\.net})
problem "Use https://downloads.sourceforge.net instead of downloads.sf.net (url is #{url})"
end
end

# Debian has an abundance of secure mirrors. Let's not pluck the insecure
Expand Down

0 comments on commit 0341300

Please sign in to comment.