summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2014-10-06 17:52:33 +0200
committerDavid Lawrence <dkl@mozilla.com>2014-10-06 17:52:33 +0200
commitaafa79dbed67514aede45f884572c30934854107 (patch)
treedef39520441fdc097877f222a32cc86e5e6fda40 /t
parentc034487bf62423265d0832197e0ff490f82330eb (diff)
parent3e1e67bed36bbe454c654f1e0a16ce73e724a5e0 (diff)
downloadbugzilla-aafa79dbed67514aede45f884572c30934854107.tar.gz
bugzilla-aafa79dbed67514aede45f884572c30934854107.tar.xz
merged with upstream 4.2
Diffstat (limited to 't')
-rw-r--r--t/002goodperl.t33
1 files changed, 32 insertions, 1 deletions
diff --git a/t/002goodperl.t b/t/002goodperl.t
index e9726cb8c..77b014f6a 100644
--- a/t/002goodperl.t
+++ b/t/002goodperl.t
@@ -32,7 +32,7 @@ use lib 't';
use Support::Files;
-use Test::More tests => (scalar(@Support::Files::testitems) * 3);
+use Test::More tests => (scalar(@Support::Files::testitems) * 4);
my @testitems = @Support::Files::testitems; # get the files to test.
@@ -126,4 +126,35 @@ foreach my $file (@testitems) {
close(FILE);
}
+
+# Forbird the { foo => $cgi->param() } syntax, for security reasons.
+foreach my $file (@testitems) {
+ $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
+ next unless $file; # skip null entries
+ if (!open(FILE, $file)) {
+ ok(0, "could not open $file --WARNING");
+ next;
+ }
+ my $lineno = 0;
+ my @unsafe_args;
+
+ while (my $file_line = <FILE>) {
+ $lineno++;
+ $file_line =~ s/^\s*(.+)\s*$/$1/; # Remove leading and trailing whitespaces.
+ if ($file_line =~ /^[^#]+=> \$cgi\->param/) {
+ push(@unsafe_args, "$file_line on line $lineno");
+ }
+ }
+
+ if (@unsafe_args) {
+ ok(0, "$file incorrectly passes a CGI argument to a hash --ERROR\n" .
+ join("\n", @unsafe_args));
+ }
+ else {
+ ok(1, "$file has no vulnerable hash syntax");
+ }
+
+ close(FILE);
+}
+
exit 0;