diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php index 8fa00e136..4f1862226 100644 --- a/system/src/Grav/Common/Security.php +++ b/system/src/Grav/Common/Security.php @@ -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) { diff --git a/system/src/Grav/Console/Cli/SecurityCommand.php b/system/src/Grav/Console/Cli/SecurityCommand.php index 3361d44ce..8e8cf6313 100644 --- a/system/src/Grav/Console/Cli/SecurityCommand.php +++ b/system/src/Grav/Console/Cli/SecurityCommand.php @@ -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);