fixed possible vulnerability loading help files

This commit is contained in:
Doug Bell 2010-08-11 15:54:48 -05:00
parent 39e3c4fb7c
commit 6b1e02f764
3 changed files with 17 additions and 9 deletions

View file

@ -15,13 +15,14 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Operation::Help;
use Test::More;
use Test::Exception;
#The goal of this test is to verify that all entries in the lib/WebGUI/Help
#directory compile. This test is necessary because WebGUI::Operation::Help
#will return an empty hash if it won't compile, and the help will simply
#disappear.
use Test::More;
my $numTests = 0;
my $session = WebGUI::Test->session;
@ -30,10 +31,18 @@ my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session);
$numTests = scalar @helpFileSet; #One for each help compile
plan tests => $numTests;
plan tests => $numTests + 2;
foreach my $helpSet (@helpFileSet) {
my $helpName = $helpSet->[1];
my $help = WebGUI::Operation::Help::_load($session, $helpName);
ok(keys %{ $help }, "$helpName compiled");
}
#----------------------------------------------------------------------------
# Test invalid help files
WebGUI::Test->interceptLogging;
lives_ok { WebGUI::Operation::Help::_load( $session, '::HI::' ) } "invalid help module doesnt die";
like( $WebGUI::Test::logger_error, qr/^Help failed to compile/, 'invalid help module errored' );
WebGUI::Test->restoreLogging;