Support route/path output

This commit is contained in:
Andy Miller
2018-10-06 17:52:46 -06:00
parent 6070bfc46e
commit fff9c657d4
2 changed files with 13 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ namespace Grav\Common;
class Security
{
public static function detectXssFromPages($pages, callable $status = null)
public static function detectXssFromPages($pages, $route = true, callable $status = null)
{
$routes = $pages->routes();
@@ -20,11 +20,11 @@ class Security
$list = [];
// // This needs Symfony 4.1 to work
// $status && $status([
// 'type' => 'count',
// 'steps' => count($routes),
// ]);
// This needs Symfony 4.1 to work
$status && $status([
'type' => 'count',
'steps' => count($routes),
]);
foreach ($routes as $path) {
@@ -43,7 +43,12 @@ class Security
$results = Security::detectXssFromArray($data);
if (!empty($results)) {
$list[$page->filePathClean()] = $results;
if ($route) {
$list[$page->route()] = $results;
} else {
$list[$page->filePathClean()] = $results;
}
}
} catch (\Exception $e) {

View File

@@ -61,7 +61,7 @@ class SecurityCommand extends ConsoleCommand
$io = new SymfonyStyle($this->input, $this->output);
$io->title('Grav Security Check');
$output = Security::detectXssFromPages($grav['pages'], [$this, 'outputProgress']);
$output = Security::detectXssFromPages($grav['pages'], false, [$this, 'outputProgress']);
$io->newline(2);