Hi Folks,

Does anyone know what's going on here? I will be very thankful for a response!!

Does YAML::Tiny require one to untaint data read from a yaml file?

I recently changed my config file from Config::Tiny to YAML::Tiny

and after doing it I get a taint error message.

>>>> Insecure dependency in open while running with -T switch at testyc.pl ...

I have reduced the problem to test case below showing what's going on with using both config::tiny and yaml::tiny.

Using data from Config::Tiny does not produce an error when opening a file for output but data from YAML::Tiny does.

???

I am running:

This is perl, v5.10.0 built for i486-linux-gnu-thread-multi I have tried this w/ 1.39 and 1.41 of YAML::Tiny.

===== file: test.configtiny [dirs] dir_output_base=./ ===== file: test.yaml dirs: dir_output_base: ./ ===== testyc.pl (run as perl -wT testyc.pl ===== #!/usr/bin/perl -wT use strict; # ====================== use YAML::Tiny; my $yaml = YAML::Tiny->new; $yaml = YAML::Tiny->read( 'test.yaml' ); my $file1="testyc1.txt"; print "Printing to dir: " . $yaml->[0]->{dirs}->{dir_output_base}; print "\n"; print "Printing to file: " . $file1; print "\n"; # choose one of the following lines for tainted or untainted # my $ut = $yaml->[0]->{dirs}->{dir_output_base}; my $ut = $1 if ($yaml->[0]->{dirs}->{dir_output_base} =~ /(.*)/); + # the above line untaints anything, just for testing purpose here. open (my $outfile1, '>', $ut . $file1); print $outfile1 "hello from testyc.pl\n"; close($outfile1); # ====================== use Config::Tiny; my $config=Config::Tiny->read('test.configtiny'); my $file2="testyc2.txt"; print "Printing to dir: " . $config->{dirs}->{dir_output_base}; print "\n"; print "Printing to file: " . $file2; print "\n"; open (my $outfile2, '>', $config->{dirs}->{dir_output_base} . $fil +e2); print $outfile2 "hello from testyc.pl\n"; close($outfile2);

In reply to Do I really need to untaint from YAML::Tiny file? by proggerguy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.