Re: how can i untain $ARGV from a perl script extending snmp? [solved]



En/na Raymond Wan ha escrit:

Hi Jordi,


Jordi Moles Blanco wrote:

1. how can i "untain" that var?
2. can i modify the way that snmp works to disable that "-T" flag when it passes the control to the perl script?

i've tried to untain the var with any means i've found, like this one:

*********
$path =~ s/;//g;
*********

but none has worked so far.

do you have any ideas?



I can't answer your second question, but as for your first question, take a look at web sites such as:

http://www.webreference.com/programming/perl/taint/

As it says, you need to clean tainted data by running a regular expression over it and *then* selecting some part of it using a sub-pattern ($1, $2, ...).

For example, you could do:

if ($path =~ /^(.*)$/) {
$path = $1;
}
else {
## Well, this won't happen
}

however, you are (a) losing all the benefits of tainting and worse of all, (b) may be giving someone else reading your code a false sense of security...they think tainted is turned on and that everything is being checked.

You might want to at least check if it is an absolute path, any ..'s in it, or if the path is within some part of the directory structure which you accept.

Hope this helps!

Ray





Thanks a lot for that info, that was all i needed :)

I was doing the first part, but no the $path=$1 step .

no it's working like a charm :)

thanks.

.



Relevant Pages

  • Re: how can i untain $ARGV from a perl script extending snmp?
    ... Jordi Moles Blanco wrote: ... I can't answer your second question, but as for your first question, take a look at web sites such as: ... As it says, you need to clean tainted data by running a regular expression over it and *then* selecting some part of it using a sub-pattern. ... You might want to at least check if it is an absolute path, any ..'s in it, or if the path is within some part of the directory structure which you accept. ...
    (perl.beginners)
  • Re: Vat cut
    ... answer to the second question relates partly to the first question. ... The system was conveniently designed to incorporate knobs, ... and all that would be necessary is to adjust one of them (this doesn't ...
    (uk.finance)
  • Re: Two Questions
    ... First question pretty much answered already.. ... > to pass a test for the .net certification. ... > Second Question: ... > another newsgroup to post to. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Datamodel Diagram
    ... for the first question check to see in file => page setup if the page is set ... Regarding the second question, that's just the ... I want to reverse engineer an existing database with numerous tables. ... prior to performing the reverse engineer, the resultant datamodel diagram ...
    (microsoft.public.visio.general)
  • Re: Fermats Last theorem short proof
    ... I may have forgotten to answer your second question ... What about my first question? ... For a purpose of FLT I have defined as ... That can't be generalized to n where n is odd integer, the generalization would be something looks different from the identity I have already established for n when it is odd prime only. ...
    (sci.math)