Skip to content

Commit a08c09a

Browse files
committed
Fixing security vulnerabilities in the test suite runner.
1 parent 33a3811 commit a08c09a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

cake/tests/lib/test_manager.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct() {
6969
$this->appTest = true;
7070
}
7171
if (isset($_GET['plugin'])) {
72-
$this->pluginTest = $_GET['plugin'];
72+
$this->pluginTest = htmlentities($_GET['plugin']);
7373
}
7474
}
7575

@@ -127,8 +127,11 @@ public function runAllTests(&$reporter, $testing = false) {
127127
public function runTestCase($testCaseFile, &$reporter, $testing = false) {
128128
$testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile;
129129

130-
if (!file_exists($testCaseFileWithPath)) {
131-
trigger_error(sprintf(__('Test case %s cannot be found', true), $testCaseFile), E_USER_ERROR);
130+
if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) {
131+
trigger_error(
132+
sprintf(__("Test case %s cannot be found", true), htmlentities($testCaseFile)),
133+
E_USER_ERROR
134+
);
132135
return false;
133136
}
134137

@@ -151,8 +154,14 @@ public function runTestCase($testCaseFile, &$reporter, $testing = false) {
151154
public function runGroupTest($groupTestName, &$reporter) {
152155
$filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension;
153156

154-
if (!file_exists($filePath)) {
155-
trigger_error(sprintf(__('Group test %s cannot be found at %s', true), $groupTestName, $filePath), E_USER_ERROR);
157+
if (!file_exists($filePath) || strpos($testCaseFileWithPath, '..')) {
158+
trigger_error(sprintf(
159+
__("Group test %s cannot be found at %s", true),
160+
htmlentities($groupTestName),
161+
htmlentities($filePath)
162+
),
163+
E_USER_ERROR
164+
);
156165
}
157166

158167
require_once $filePath;

0 commit comments

Comments
 (0)