aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrevor Wennblom2012-02-15 21:44:14 -0600
committerJack Nagel2012-02-15 22:12:06 -0600
commit641d22f9f33733a6f9020d247ef3045288748e4e (patch)
treee7a43383f8564f7abb1eb9084cbce3644bd6f7c4
parent7e40820c68d20884905da75922f74f50324bade4 (diff)
downloadhomebrew-641d22f9f33733a6f9020d247ef3045288748e4e.tar.bz2
more stringent auditing of checksums
Closes #10213. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
-rwxr-xr-xLibrary/Homebrew/cmd/audit.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index 843d19437..99dc3a979 100755
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -75,18 +75,31 @@ def audit_formula_text name, text
end
# Empty checksums
- if text =~ /md5\s+(\'\'|\"\")/
+ if text =~ /md5\s+(''|"")/
problems << " * md5 is empty"
end
- if text =~ /sha1\s+(\'\'|\"\")/
+ if text =~ /sha1\s+(''|"")/
problems << " * sha1 is empty"
end
- if text =~ /sha256\s+(\'\'|\"\")/
+ if text =~ /sha256\s+(''|"")/
problems << " * sha256 is empty"
end
+ # Checksum sanity check
+ if text =~ /md5\s+['"](.+)['"]/ and $1 != '#{md5}' and $1 !~ /[a-f0-9]{32}/
+ problems << " * md5 contains invalid or incorrect number of characters"
+ end
+
+ if text =~ /sha1\s+['"](.+)['"]/ and $1 != '#{sha1}' and $1 !~ /[a-f0-9]{40}/
+ problems << " * sha1 contains invalid or incorrect number of characters"
+ end
+
+ if text =~ /sha256\s+['"](.+)['"]/ and $1 != '#{sha256}' and $1 !~ /[a-f0-9]{64}/
+ problems << " * sha256 contains invalid or incorrect number of characters"
+ end
+
# Commented-out depends_on
if text =~ /#\s*depends_on\s+(.+)\s*$/
problems << " * Commented-out dep #{$1}."