File: taint.t

package info (click to toggle)
libtest-taint-perl 1.06-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 168 kB
  • ctags: 126
  • sloc: perl: 499; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!perl -T

use warnings;
use strict;

BEGIN {
    for($0, $^X) { ## no critic (Variables::ProhibitPunctuationVars)
        ($_) = /(.*)/;
    }
}

use Test::More;
use Test::Taint tests => 10;

use constant VAR => 'VAR'; ## no critic (ValuesAndExpressions::ProhibitConstantPragma)

taint_checking_ok();

my $foo = 43;
untainted_ok( $foo, 'Starts clean' );
taint($foo);
tainted_ok( $foo, 'Gets dirty' );
$foo =~ /(\d+)/ or die;
$foo = $1;
untainted_ok( $foo, 'Reclean' );

my $bar = 'bar';
untainted_ok( $bar, 'Starts clean' );
taint($bar);
tainted_ok( $bar, 'Gets dirty' );
is($bar, 'bar', 'String value stays the same');

untainted_ok( VAR, 'Starts clean' );
taint(VAR);
untainted_ok( VAR, 'Stays clean' );
is(VAR, 'VAR', 'String value stays the same');