diff options
| author | Mike McQuaid | 2017-06-09 11:16:11 +0300 |
|---|---|---|
| committer | GitHub | 2017-06-09 11:16:11 +0300 |
| commit | 113a7a81d031bc060aa9e83f334e52bed75b79c3 (patch) | |
| tree | cf78f777c1ebbaa65bc1bd1b50b67e7e89648ef9 /Library/Homebrew/dev-cmd/audit.rb | |
| parent | e83e394a731f3317dc09a5eb1210ff6996e40ed2 (diff) | |
| download | brew-113a7a81d031bc060aa9e83f334e52bed75b79c3.tar.bz2 | |
Revert "audit: Port audit_checksum method to rubocop and add tests"
Diffstat (limited to 'Library/Homebrew/dev-cmd/audit.rb')
| -rw-r--r-- | Library/Homebrew/dev-cmd/audit.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 105bc0e86..e069fef36 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1246,6 +1246,7 @@ class ResourceAuditor def audit audit_version + audit_checksum audit_download_strategy audit_urls self @@ -1272,6 +1273,28 @@ class ResourceAuditor problem "version #{version} should not end with an underline and a number" end + def audit_checksum + return unless checksum + + case checksum.hash_type + when :md5 + problem "MD5 checksums are deprecated, please use SHA256" + return + when :sha1 + problem "SHA1 checksums are deprecated, please use SHA256" + return + when :sha256 then len = 64 + end + + if checksum.empty? + problem "#{checksum.hash_type} is empty" + else + problem "#{checksum.hash_type} should be #{len} characters" unless checksum.hexdigest.length == len + problem "#{checksum.hash_type} contains invalid characters" unless checksum.hexdigest =~ /^[a-fA-F0-9]+$/ + problem "#{checksum.hash_type} should be lowercase" unless checksum.hexdigest == checksum.hexdigest.downcase + end + end + def audit_download_strategy if url =~ %r{^(cvs|bzr|hg|fossil)://} || url =~ %r{^(svn)\+http://} problem "Use of the #{$&} scheme is deprecated, pass `:using => :#{$1}` instead" |
