in reply to How to safely define a CGI program's application base directory
If your app is itself located under AppBase, you could use dirname() and __FILE__ which are taint-free:
#!/usr/bin/perl -wT
use strict;
my $basedir;
use File::Basename qw(dirname);
BEGIN { $basedir = dirname(dirname(__FILE__)) };
use lib $basedir.'/lib';
use YAML; # Dummy - use fails if @INC is tainted
print "File = ", __FILE__, "\n";
print "Lib = @INC\n";
If that's not the case, I would just assume AppBase is always fine and "untaint" it through some regular expression (preferably with a comment why I did so).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to safely define a CGI program's application base directory
by Dallaylaen (Chaplain) on Feb 11, 2013 at 13:58 UTC | |
by Anonymous Monk on Feb 11, 2013 at 14:00 UTC |