Taint(3)
π¦ Taint(3) π¦
Hey bestie, this is Taint(3) β the User Contributed Perl Documentation page for Test::Taint, aka Tools to test taintedness. π
π NAME π
Test::Taint β Tools to test taintedness.
π VERSION π
Version 1.08.
β¨ SYNOPSIS β¨
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 );
π DESCRIPTION π
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. Literally so handy. β¨
π Test::More"-style Functions π
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. No cap. π
π taint_checking_ok( [$message] ) π
Test::More-style test that taint checking is on. This should probably be the first thing in any *.t file that deals with taintedness. Like, put it first, bestie. π
π tainted_ok( $var [, $message ] ) π
Checks that $var is tainted.
tainted_ok( $ENV{FOO} );
π¦ untainted_ok( $var [, $message ] ) π¦
Checks that $var is not tainted.
my $foo = my_validate( $ENV{FOO} );
untainted_ok( $foo );
πΈ tainted_ok_deeply( $var [, $message ] ) πΈ
Checks that $var is tainted. If $var is a reference, it recursively checks every variable to make sure they are all tainted. Deep dive vibe check. π
tainted_ok_deeply( \%ENV );
β untainted_ok_deeply( $var [, $message ] ) β
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 );
π§ Helper Functions π§
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. Main character energy fr fr. π
π taint_checking() π
Returns true if taint checking is enabled via the -T flag.
π tainted( $var ) π
Returns boolean saying if $var is tainted.
π¦ tainted_deeply( $var ) π¦
Returns boolean saying if $var is tainted. If $var is a reference it recursively checks every variable to make sure they are all tainted.
πΈ taint( @list ) πΈ
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. π
β taint_deeply( @list ) β
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.
π AUTHOR π
Written by Andy Lester, <andy@petdance.com>. π
π COPYRIGHT π
Copyright 2004-2019, Andy Lester.
You may use, modify, and distribute this package under the same terms as Perl itself.
Later, bestie! This page is from perl v5.42.0, dated 2019-06-13, and it's Taint(3) β periodt π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Taint 1.08-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Test-Taint 1.08-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Test-Taint 1.08-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Test-Taint 1.08-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms