From d6b1166ba40b783423b008a4ef02181194012ba9 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 23 Nov 2023 13:36:41 +0100 Subject: [PATCH] #12498 validated regex in widget --- .../include/lib/Dashboard/Widgets/top_n.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php index 5a603501c0..3ab2f922a3 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php @@ -420,6 +420,20 @@ class TopNWidget extends Widget // Prevent double safe input in agents_get_group_agents function. $agentRegex = io_safe_output($agentRegex); + // Validate regex. + if (@preg_match('/'.$agentRegex.'/', '') === false + || @preg_match('/'.$this->values['module'].'/', '') === false + ) { + $output .= '
'; + $output .= \ui_print_info_message( + __('Invalid regex'), + '', + true + ); + $output .= '
'; + return $output; + } + // This function check ACL. $agents = @agents_get_group_agents(0, ['aliasRegex' => $agentRegex]); $agentsId = \array_keys($agents);