http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlsec.pod#Laundering_and_Detecting_Tainted_Data
Laundering and Detecting Tainted Data To test whether a variable contains tainted data, and whose use would +thus trigger an "Insecure dependency" message, you can use the tainte +d() function of the Scalar::Util module, available in your nearby CPA +N mirror, and included in Perl starting from the release 5.8.0. Or yo +u may be able to use the following is_tainted() function. sub is_tainted { return ! eval { eval("#" . substr(join("", @_), 0, 0)); 1 }; } This function makes use of the fact that the presence of tainted data +anywhere within an expression renders the entire expression tainted. +It would be inefficient for every operator to test every argument for + taintedness. Instead, the slightly more efficient and conservative a +pproach is used that if any tainted value has been accessed within th +e same expression, the whole expression is considered tainted. But testing for taintedness gets you only so far. Sometimes you have j +ust to clear your data's taintedness. Values may be untainted by usin +g them as keys in a hash; otherwise the only way to bypass the tainti +ng mechanism is by referencing subpatterns from a regular expression +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. T +hat 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") rath +er 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.

In reply to Re: is_tainted function by Anonymous Monk
in thread is_tainted function by perlknight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.