From 44578adfdb3e780579381407e0a88677fa0eaa8c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 23 Oct 2018 12:26:58 +0000 Subject: [PATCH] audit: use debian canonical mirror --- Library/Homebrew/rubocops/urls_cop.rb | 12 ++++++++- .../Homebrew/test/rubocops/urls_cop_spec.rb | 26 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/rubocops/urls_cop.rb b/Library/Homebrew/rubocops/urls_cop.rb index 8ef40e9144..76713d5a3b 100644 --- a/Library/Homebrew/rubocops/urls_cop.rb +++ b/Library/Homebrew/rubocops/urls_cop.rb @@ -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/}]) diff --git a/Library/Homebrew/test/rubocops/urls_cop_spec.rb b/Library/Homebrew/test/rubocops/urls_cop_spec.rb index 5664b93ccb..34500a4d22 100644 --- a/Library/Homebrew/test/rubocops/urls_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/urls_cop_spec.rb @@ -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",