Skip to content

Commit

Permalink
Fixing security vulnerabilities in the test suite runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 23, 2010
1 parent 215333e commit 813a3af
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cake/tests/lib/test_manager.php
Expand Up @@ -70,7 +70,7 @@ function TestManager() {
$this->appTest = true; $this->appTest = true;
} }
if (isset($_GET['plugin'])) { if (isset($_GET['plugin'])) {
$this->pluginTest = $_GET['plugin']; $this->pluginTest = htmlentities($_GET['plugin']);
} }
} }


Expand Down Expand Up @@ -131,8 +131,11 @@ function runAllTests(&$reporter, $testing = false) {
function runTestCase($testCaseFile, &$reporter, $testing = false) { function runTestCase($testCaseFile, &$reporter, $testing = false) {
$testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile; $testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile;


if (!file_exists($testCaseFileWithPath)) { if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) {
trigger_error(sprintf(__('Test case %s cannot be found', true), $testCaseFile), E_USER_ERROR); trigger_error(
sprintf(__("Test case %s cannot be found", true), htmlentities($testCaseFile)),
E_USER_ERROR
);
return false; return false;
} }


Expand All @@ -156,8 +159,14 @@ function runTestCase($testCaseFile, &$reporter, $testing = false) {
function runGroupTest($groupTestName, &$reporter) { function runGroupTest($groupTestName, &$reporter) {
$filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension; $filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension;


if (!file_exists($filePath)) { if (!file_exists($filePath) || strpos($testCaseFileWithPath, '..')) {
trigger_error(sprintf(__('Group test %s cannot be found at %s', true), $groupTestName, $filePath), E_USER_ERROR); trigger_error(sprintf(
__("Group test %s cannot be found at %s", true),
htmlentities($groupTestName),
htmlentities($filePath)
),
E_USER_ERROR
);
} }


require_once $filePath; require_once $filePath;
Expand Down

0 comments on commit 813a3af

Please sign in to comment.