GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Taint(3) User Contributed Perl Documentation Taint(3)

Test::Taint - Tools to test taintedness

Version 1.08

    taint_checking_ok();        # We have to have taint checking on
    my $id = "deadbeef";        # Dummy session ID
    taint( $id );               # Simulate it coming in from the web
    tainted_ok( $id );
    $id = validate_id( $id );   # Your routine to check the $id
    untainted_ok( $id );        # Did it come back clean?
    ok( defined $id );

Tainted data is data that comes from an unsafe source, such as the command line, or, in the case of web apps, any GET or POST transactions. Read the perlsec man page for details on why tainted data is bad, and how to untaint the data.

When you're writing unit tests for code that deals with tainted data, you'll want to have a way to provide tainted data for your routines to handle, and easy ways to check and report on the taintedness of your data, in standard Test::More style.

All the "xxx_ok()" functions work like standard "Test::More"-style functions, where the last parm is an optional message, it outputs ok or not ok, and returns a boolean telling if the test passed.

Test::More-style test that taint checking is on. This should probably be the first thing in any *.t file that deals with taintedness.

Checks that $var is tainted.

    tainted_ok( $ENV{FOO} );

Checks that $var is not tainted.

    my $foo = my_validate( $ENV{FOO} );
    untainted_ok( $foo );

Checks that $var is tainted. If $var is a reference, it recursively checks every variable to make sure they are all tainted.

    tainted_ok_deeply( \%ENV );

Checks that $var is not tainted. If $var is a reference, it recursively checks every variable to make sure they are all not tainted.

    my %env = my_validate( \%ENV );
    untainted_ok_deeply( \%env );

These are all helper functions. Most are wrapped by an "xxx_ok()" counterpart, except for "taint" which actually does something, instead of just reporting it.

Returns true if taint checking is enabled via the -T flag.

Returns boolean saying if $var is tainted.

Returns boolean saying if $var is tainted. If $var is a reference it recursively checks every variable to make sure they are all tainted.

Marks each (apparently) taintable argument in @list as being tainted.

References can be tainted like any other scalar, but it doesn't make sense to, so they will not be tainted by this function.

Some "tie"d and magical variables may fail to be tainted by this routine, try as it may.

Similar to "taint", except that if any elements in @list are references, it walks deeply into the data structure and marks each taintable argument as being tainted.

If any variables are "tie"d this will taint all the scalars within the tied object.

Written by Andy Lester, "<andy@petdance.com>".

Copyright 2004-2019, Andy Lester.

You may use, modify, and distribute this package under the same terms as Perl itself.

2019-06-12 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.