Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit ce27f46

Browse files
committed
security: Fix ZF2019-01
Ensures all configured toolbar entries are examined when determining whether or not to enable them.
1 parent 8427584 commit ce27f46

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

src/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public function setToolbar(array $options)
357357
foreach ($value as $collector => $template) {
358358
if ($template === false || $template === null) {
359359
unset($this->toolbar[$key][$collector]);
360-
break;
360+
continue;
361361
}
362362

363363
$this->toolbar[$key][$collector] = $template;

test/OptionsTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,50 @@ public function testStatusOfDefaultConfiguration()
2121
$this->assertTrue($options->isEnabled());
2222
$this->assertTrue($options->isToolbarEnabled());
2323
}
24+
25+
public function blacklistFlags()
26+
{
27+
yield 'null' => [null];
28+
yield 'false' => [false];
29+
}
30+
31+
/**
32+
* @see https://framework.zend.com/security/advisory/ZF2019-01
33+
* @dataProvider blacklistFlags
34+
* @param null|bool $flagValue
35+
*/
36+
public function testOnlyWhitelistedToolbarEntriesShouldBeEnabled($flagValue)
37+
{
38+
$reportMock = $this->prophesize(ReportInterface::class)->reveal();
39+
$options = new Options([], $reportMock);
40+
$toolbarOptions = [
41+
'enabled' => true,
42+
'entries' => [
43+
'request' => $flagValue,
44+
'time' => true,
45+
'config' => $flagValue,
46+
],
47+
];
48+
49+
$options->setToolbar($toolbarOptions);
50+
51+
$this->assertTrue($options->isToolbarEnabled());
52+
53+
$entries = $options->getToolbarEntries();
54+
$this->assertArrayNotHasKey(
55+
'request',
56+
$entries,
57+
'Request key found in toolbar entries, and should not have been'
58+
);
59+
$this->assertArrayHasKey(
60+
'time',
61+
$entries,
62+
'Time key NOT found in toolbar entries, and should have been'
63+
);
64+
$this->assertArrayNotHasKey(
65+
'config',
66+
$entries,
67+
'Config key found in toolbar entries, and should not have been'
68+
);
69+
}
2470
}

0 commit comments

Comments
 (0)