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

Commit

Permalink
security: Fix ZF2019-01
Browse files Browse the repository at this point in the history
Ensures all configured toolbar entries are examined when determining
whether or not to enable them.
  • Loading branch information
weierophinney committed Mar 27, 2019
1 parent 8427584 commit ce27f46
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public function setToolbar(array $options)
foreach ($value as $collector => $template) {
if ($template === false || $template === null) {
unset($this->toolbar[$key][$collector]);
break;
continue;
}

$this->toolbar[$key][$collector] = $template;
Expand Down
46 changes: 46 additions & 0 deletions test/OptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,50 @@ public function testStatusOfDefaultConfiguration()
$this->assertTrue($options->isEnabled());
$this->assertTrue($options->isToolbarEnabled());
}

public function blacklistFlags()
{
yield 'null' => [null];
yield 'false' => [false];
}

/**
* @see https://framework.zend.com/security/advisory/ZF2019-01
* @dataProvider blacklistFlags
* @param null|bool $flagValue
*/
public function testOnlyWhitelistedToolbarEntriesShouldBeEnabled($flagValue)
{
$reportMock = $this->prophesize(ReportInterface::class)->reveal();
$options = new Options([], $reportMock);
$toolbarOptions = [
'enabled' => true,
'entries' => [
'request' => $flagValue,
'time' => true,
'config' => $flagValue,
],
];

$options->setToolbar($toolbarOptions);

$this->assertTrue($options->isToolbarEnabled());

$entries = $options->getToolbarEntries();
$this->assertArrayNotHasKey(
'request',
$entries,
'Request key found in toolbar entries, and should not have been'
);
$this->assertArrayHasKey(
'time',
$entries,
'Time key NOT found in toolbar entries, and should have been'
);
$this->assertArrayNotHasKey(
'config',
$entries,
'Config key found in toolbar entries, and should not have been'
);
}
}

0 comments on commit ce27f46

Please # to comment.