in reply to Re: Re: Insecure dependency message ?
in thread Insecure dependency message ?
From the man page
The only way to bypass the tainting mechanism is by referencing subpatterns from a regular expres- sion match. Perl presumes that if you reference a substring using $1, $2, etc., that you knew what you were doing when you wrote the pattern. That means using a bit of thought--don't just blindly untaint anything, or you defeat the entire mechanism. It's better to verify that the variable has only good characters (for certain values of "good") rather than checking whether it has any bad characters. That's because it's far too easy to miss bad characters that you never thought of.If $input is 12345, and 12345 comes from $cgi->param(....), then a simple regexp pattern of...
Your regexp should test and assign out the various ()'s. You can do 3 ()'s at a time, or just one... but only assign $1... $9 ONLY if your regexp matches. doing $input=~/(...)/ and then $input = $1 without an if statement might screw things up BIG time. $1 gets assigned on a successful match. It doesn't get undef'd if a match is unsuccessful.if($input=~/(\d+)/) { $input = $1; } else{ $input = undef }
You don't have to copy $1 back to $input either. I only did it to create less variables. You can do $verifiedInput = $1 too. But remember to program around the cases when the regexp matches or doesn't.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Insecure dependency message ?
by peterr (Scribe) on Jan 06, 2004 at 04:52 UTC | |
by exussum0 (Vicar) on Jan 06, 2004 at 04:57 UTC | |
by peterr (Scribe) on Jan 07, 2004 at 01:21 UTC |