bliako has asked for the wisdom of the Perl Monks concerning the following question:
Hi there Monkees,
Are test scripts without taint mode on generally a bad practice when part of a CPAN distribution?
I need to test an executable script and have resorted to Test::Script, like this:
#!perl -T use 5.008; use strict; use warnings; use Test::More; use Test::Script; my $num_tests = 0; my $infile = "abc.pl"; ok(-f $infile, "test file exists ($infile)."); $num_tests++; ok(-s $infile, "test file has content ($infile)."); $num_tests++; script_compiles($infile); $num_tests++; script_runs([$infile, '-i', $infile]); $num_tests++; script_stderr_is('', "stderr checked."); $num_tests++; done_testing($num_tests);
The above fails for script_compiles because of Insecure dependency in open while running with -T switch at /usr/local/share/perl5/Test/Script.pm line 137
Can I remove the taint mode? I would prefer not to, is there an alternative? Or have I got script testing wrong?
Edit: fixed some errors in a var name in the script pointed out by Anonymous Monk
bw, bliako
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: testing script execs without taint mode on (-T)
by Anonymous Monk on Apr 18, 2020 at 15:47 UTC | |
by bliako (Abbot) on Apr 18, 2020 at 16:18 UTC | |
|
Re: testing script execs without taint mode on (-T)
by jcb (Parson) on Apr 19, 2020 at 03:47 UTC |