1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
## name 2 evil variables
## parms {variables => '$[ $SIG{__DIE__}'}
## failures 2
## cut
print 'First subscript is ', $[, "\n";
local $SIG{__DIE__} = sub {warn "I cannot die!"};
#-----------------------------------------------------------------------------
## name evil variables with brackets
## parms { variables => '${^WIN32_SLOPPY_STAT} %{^_Fubar}' }
## failures 2
## cut
${^WIN32_SLOPPY_STAT} and print "We are being sloppy\n";
our %{^_Fubar};
#-----------------------------------------------------------------------------
## name subscripted evil variables with brackets
## parms { variables => '%{^_Fubar}' }
## failures 1
## cut
print "The value of \${^_Fubar}{baz} is ", ${^_Fubar}{baz}, "\n";
#-----------------------------------------------------------------------------
## name No evil variables
## parms {variables => '$[ $SIG{__DIE__}'}
## failures 0
## cut
print 'Perl version is ', $], "\n";
local $SIG{__WARN__} = sub {print {STDERR} "Danger Will Robinson!\n"};
#-----------------------------------------------------------------------------
## name 2 evil variables, with pattern matching
## parms { variables => '/\[/ /\bSIG\b/ ' }
## failures 2
## cut
print 'First subscript is ', $[, "\n";
local $SIG{__DIE__} = sub {warn "I cannot die!"};
#-----------------------------------------------------------------------------
## name More evil variables, with mixed config
## parms { variables => ' $[ /\bSIG\b/ $^S' }
## failures 5
## cut
print 'First subscript is ', $[, "\n";
local $SIG{__DIE__} = sub {warn "I cannot die!"};
print $^S ? 'Executing eval' : defined $^S ? 'Otherwise' : 'Parsing';
local $SIG{__WARN__} = sub {print {STDERR} "Danger, Will Robinson!\n";
#-----------------------------------------------------------------------------
## name Recognize use of elements of evil arrays and hashes
## parms { variables => '%SIG @INC' }
## failures 2
## cut
local $SIG{__DIE__} = sub {warn "I cannot die!"};
print '$INC[0] is ', $INC[0], "\n";
#-----------------------------------------------------------------------------
## name Regexes with modifiers
## parms { variables => ' /(?x: \b SIG \b )/ /(?i:\binc\b)/ /(?ix: acme )/ ' }
## failures 4
## cut
local $SIG{__DIE__} = sub {warn "I cannot die!"};
print '$INC[0] is ', $INC[0], "\n";
print '$inc[0] is ', $inc[0], "\n";
my $Acme = 'For the discerning coyote';
#-----------------------------------------------------------------------------
## name More evil variables, with more pattern matching
## parms { variables => '/foo|bar|baz/ ' }
## failures 4
## cut
my $foo;
my $bar;
my $baz;
my $foonly;
#-----------------------------------------------------------------------------
## name Pattern matching exceptions
## parms { variables => '/(/' }
## failures 0
## error /invalid regular expression/
## cut
print 'Hello World';
#-----------------------------------------------------------------------------
## name Providing the description for variables, no regular expressions.
## parms { variables => q'$[ {Found use of $[. Code for first index = 0 instead} $SIG{__DIE__} <Found use of $SIG{__DIE__}. Use END{} or override CORE::GLOBAL::die instead>' }
## failures 2
## cut
print 'First subscript is ', $[, "\n";
local $SIG{__DIE__} = sub {warn "I cannot die!"};
#-----------------------------------------------------------------------------
## name Providing the description for variables, regular expressions.
## parms { variables => q' /\bSIG\b/ {Found use of SIG. Do not use signals} /\bINC\b/ {Found use of INC. Do not manipulate @INC directly} ' }
## failures 2
## cut
local $SIG{__DIE__} = sub {warn "I cannot die!"};
print '$INC[0] is ', $INC[0], "\n";
#-----------------------------------------------------------------------------
## name Providing the description for variables, regular expressions with modifiers.
## parms { variables => ' /(?x: \b SIG \b )/{We do not like signals.} /(?i:\binc\b)/[Do not fiddle with INC, no mater how it is capitalized] ' }
## failures 3
## cut
local $SIG{__DIE__} = sub {warn "I cannot die!"};
print '$INC[0] is ', $INC[0], "\n";
print '$inc[0] is ', $inc[0], "\n";
#-----------------------------------------------------------------------------
## name Providing the description for variables from file, no regular expressions.
## parms { variables_file => 't/Variables/ProhibitEvilVariables.d/variables-no-regular-expressions.txt' }
## failures 4
## cut
print 'First subscript is ', $[, "\n";
local $SIG{__DIE__} = sub {warn "I cannot die!"};
print $^S ? 'Executing eval' : defined $^S ? 'Otherwise' : 'Parsing';
#-----------------------------------------------------------------------------
## name Providing the description for variables from file, regular expressions.
## parms { variables_file => 't/Variables/ProhibitEvilVariables.d/variables-regular-expressions.txt' }
## failures 4
## cut
print 'First subscript is ', $[, "\n";
local $SIG{__DIE__} = sub {warn "I cannot die!"};
print $^S ? 'Executing eval' : defined $^S ? 'Otherwise' : 'Parsing';
#-----------------------------------------------------------------------------
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 78
# indent-tabs-mode: nil
# c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :
|