X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fweb%2Fpath-traversal.t;h=8207265ef8741141ce94da8fb1d4eec387d7cba2;hb=96af02574ea6b1b59f81a1215330b682a8dee635;hp=5d5c954a15a4f6d46386ed9d5d5bc5b355b19312;hpb=85e677b86fc37c54e6de2b06340351a28f5a5916;p=freeside.git diff --git a/rt/t/web/path-traversal.t b/rt/t/web/path-traversal.t index 5d5c954a1..8207265ef 100644 --- a/rt/t/web/path-traversal.t +++ b/rt/t/web/path-traversal.t @@ -1,35 +1,37 @@ use strict; use warnings; -use RT::Test tests => 22; +use RT::Test tests => undef; my ($baseurl, $agent) = RT::Test->started_ok; +ok($agent->login); $agent->get("$baseurl/NoAuth/../Elements/HeaderJavascript"); is($agent->status, 400); -$agent->warning_like(qr/Invalid request.*aborting/,); +$agent->warning_like(qr/Invalid request.*aborting/); $agent->get("$baseurl/NoAuth/../%45lements/HeaderJavascript"); is($agent->status, 400); -$agent->warning_like(qr/Invalid request.*aborting/,); +$agent->warning_like(qr/Invalid request.*aborting/); $agent->get("$baseurl/NoAuth/%2E%2E/Elements/HeaderJavascript"); is($agent->status, 400); -$agent->warning_like(qr/Invalid request.*aborting/,); +$agent->warning_like(qr/Invalid request.*aborting/); $agent->get("$baseurl/NoAuth/../../../etc/RT_Config.pm"); is($agent->status, 400); -SKIP: { - skip "Apache rejects busting up above / for us", 2 if $ENV{RT_TEST_WEB_HANDLER} =~ /^apache/; - $agent->warning_like(qr/Invalid request.*aborting/,); -}; +$agent->warning_like(qr/Invalid request.*aborting/) unless $ENV{RT_TEST_WEB_HANDLER} =~ /^apache/; -$agent->get("$baseurl/NoAuth/css/web2/images/../../../../../../etc/RT_Config.pm"); -is($agent->status, 400); -SKIP: { - skip "Apache rejects busting up above / for us", 2 if $ENV{RT_TEST_WEB_HANDLER} =~ /^apache/; - $agent->warning_like(qr/Invalid request.*aborting/,); -}; +$agent->get("$baseurl/static/css/web2/images/../../../../../../etc/RT_Config.pm"); +# Apache hardcodes a 400m but the static handler returns a 403 for traversal too high +is($agent->status, $ENV{RT_TEST_WEB_HANDLER} =~ /^apache/ ? 400 : 403); + +# Do not reject a simple /. in the URL, for downloading uploaded +# dotfiles, for example. +$agent->get("$baseurl/Ticket/Attachment/28/9/.bashrc"); +is($agent->status, 200); # Even for a file not found, we return 200 +$agent->next_warning_like(qr/could not be loaded/, "couldn't loaded warning"); +$agent->content_like(qr/Attachment \S+ could not be loaded/); # do not reject these URLs, even though they contain /. outside the path $agent->get("$baseurl/index.html?ignored=%2F%2E"); @@ -44,3 +46,5 @@ is($agent->status, 200); $agent->get("$baseurl/index.html#/."); is($agent->status, 200); +undef $agent; +done_testing;