Merge pull request #5159 from vszakats/debmirrcanon

audit: use debian canonical mirror
This commit is contained in:
Mike McQuaid 2018-10-23 19:13:40 +01:00 committed by GitHub
commit 0ac0eaf484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View File

@ -43,6 +43,7 @@ module RuboCop
%r{^http://code\.google\.com/},
%r{^http://fossies\.org/},
%r{^http://mirrors\.kernel\.org/},
%r{^http://mirrors\.ocf\.berkeley\.edu/},
%r{^http://(?:[^/]*\.)?bintray\.com/},
%r{^http://tools\.ietf\.org/},
%r{^http://launchpad\.net/},
@ -125,10 +126,19 @@ module RuboCop
problem <<~EOS
Please use a secure mirror for Debian URLs.
We recommend:
https://mirrors.ocf.berkeley.edu/debian/#{match[1]}
https://deb.debian.org/debian/#{match[1]}
EOS
end
# Check to use canonical urls for Debian packages
noncanon_deb_pattern =
Regexp.union([%r{^https://mirrors\.kernel\.org/debian/},
%r{^https://mirrors\.ocf\.berkeley\.edu/debian/},
%r{^https://(?:[^/]*\.)?mirrorservice\.org/sites/ftp\.debian\.org/debian/}])
audit_urls(urls, noncanon_deb_pattern) do |_, url|
problem "Please use https://deb.debian.org/debian/ for #{url}"
end
# Check for new-url Google Code download urls, https:// is preferred
google_code_pattern = Regexp.union([%r{^http://.*\.googlecode\.com/files.*},
%r{^http://code\.google\.com/}])

View File

@ -76,9 +76,33 @@ describe RuboCop::Cop::FormulaAudit::Urls do
"msg" => <<~EOS,
Please use a secure mirror for Debian URLs.
We recommend:
https://mirrors.ocf.berkeley.edu/debian/dists/foo/
https://deb.debian.org/debian/dists/foo/
EOS
"col" => 2,
}, {
"url" => "https://mirrors.kernel.org/debian/pool/main/n/nc6/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrors.kernel.org/debian/pool/main/n/nc6/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://mirrors.ocf.berkeley.edu/debian/pool/main/m/mkcue/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrors.ocf.berkeley.edu/debian/pool/main/m/mkcue/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"col" => 2,
}, {
"url" => "https://www.mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"msg" => "Please use " \
"https://deb.debian.org/debian/ for " \
"https://www.mirrorservice.org/sites/ftp.debian.org/debian/pool/main/n/netris/foo.tar.gz",
"col" => 2,
}, {
"url" => "http://foo.googlecode.com/files/foo-1.0.zip",
"msg" => "Please use https:// for http://foo.googlecode.com/files/foo-1.0.zip",