1 BEGIN { $ENV{DBICTEST_ANFANG_DEFANG} = 1 }
7 # there is talk of possible perl compilations where -T is fatal or just
8 # doesn't work. We don't want to have the user deal with that.
9 BEGIN { unless ($INC{'t/lib/DBICTest/WithTaint.pm'}) {
11 if ( $^O eq 'MSWin32' and $^X =~ /\x20/ ) {
12 print "1..0 # SKIP Running this test on Windows with spaces within the perl executable path (\$^X) is not possible due to https://rt.perl.org/Ticket/Display.html?id=123907\n";
16 # it is possible the test itself is initially invoked in taint mode
17 # and with relative paths *and* with a relative $^X and some other
18 # craziness... in short: just be proactive
21 if (length $ENV{PATH}) {
22 ( $ENV{PATH} ) = join ( $Config{path_sep},
23 map { length($_) ? File::Spec->rel2abs($_) : () }
24 split /\Q$Config{path_sep}/, $ENV{PATH}
28 my ($perl) = $^X =~ /\A(.+)\z/;
31 local $ENV{PATH} = "/nosuchrootbindir";
32 system( $perl => -T => -e => '
35 eval { my $x = $ENV{PATH} . (kill (0)); 1 } or exit 42;
40 if ( ($? >> 8) != 42 ) {
41 print "1..0 # SKIP Your perl does not seem to like/support -T...\n";
45 exec( $perl, qw( -I. -Mt::lib::DBICTest::WithTaint -T ), __FILE__ );
48 # When in taint mode, PERL5LIB is ignored (but *not* unset)
49 # Put it back in INC so that local-lib users can actually
50 # run this test. Use lib.pm instead of an @INC unshift as
51 # it will correctly add any arch subdirs encountered
55 map { split /\Q$Config{path_sep}\E/, (/^(.*)$/)[0] } # untainting regex
57 @ENV{qw(PERL5LIB PERLLIB)} # precedence preserved by lib
60 # We need to specify 'lib' here as well because even if it was already in
61 # @INC, the above will have put our local::lib in front of it, so now an
62 # installed DBIx::Class will take precedence over the one we're trying to test.
63 # In some cases, prove will have supplied ./lib as an absolute path so it
64 # doesn't seem worth trying to remove the second copy since it won't hurt
66 use lib qw(t/lib lib);
73 sub { $ENV{PATH} . (kill (0)) },
74 qr/Insecure dependency in kill/,
76 ) if length $ENV{PATH};
79 package DBICTest::Taint::Classes;
84 use base qw/DBIx::Class::Schema/;
87 __PACKAGE__->load_classes(qw/Manual/);
88 ok( __PACKAGE__->source('Manual'), 'The Classes::Manual source has been registered' );
89 __PACKAGE__->_unregister_source (qw/Manual/);
90 }, 'Loading classes with explicit load_classes worked in taint mode' );
93 __PACKAGE__->load_classes();
94 ok( __PACKAGE__->source('Auto'), 'The Classes::Auto source has been registered' );
95 ok( __PACKAGE__->source('Auto'), 'The Classes::Manual source has been re-registered' );
96 }, 'Loading classes with Module::Find/load_classes worked in taint mode' );
100 package DBICTest::Taint::Namespaces;
105 use base qw/DBIx::Class::Schema/;
108 __PACKAGE__->load_namespaces();
109 ok( __PACKAGE__->source('Test'), 'The Namespaces::Test source has been registered' );
110 }, 'Loading classes with Module::Find/load_namespaces worked in taint mode' );
113 # check that we can create a database and all
115 my $s = DBICTest->init_schema( sqlite_use_file => 1 );
116 my $art = $s->resultset('Artist')->search({}, {
117 prefetch => 'cds', order_by => 'artistid',
119 is ($art->artistid, 1, 'got artist');