From e38246521db38ce88f20174061b5353e9fd62fd6 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 14 Nov 2023 09:33:04 +0100 Subject: [PATCH] #12251 added info in security in agent contact --- pandora_console/include/functions_agents.php | 40 ++++++++++++++++++++ pandora_console/include/functions_ui.php | 11 ++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 720b0e6e55..4fb61875d5 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4845,6 +4845,46 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $data[1] = $time_elapsed; $table_contact->data[] = $data; + // SecurityMon line. + $id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security'); + $modules = db_get_all_rows_filter( + 'tagente_modulo', + [ + 'id_agente' => $agent['id_agente'], + 'id_module_group' => $id_module_group, + ] + ); + + if (is_array($modules) === true && count($modules) > 0) { + $secmon_status = secmon_status($agent['id_agente']); + $data = []; + $data[0] = ''.__('SecurityMon').''; + $data[1] = ui_print_status_secmon_div($secmon_status, __('Total security modules: %s', count($modules))); + $table_contact->data[] = $data; + } + + // Hardening line. + $module_score = modules_get_agentmodule_id(io_safe_input('Hardening - Score'), $agent['id_agente']); + $hardening = ''; + if (is_array($module_score) === true && key_exists('id_agente_modulo', $module_score) == true) { + $raw_data_score = modules_get_raw_data($module_score['id_agente_modulo'], 0, time()); + $hardening = format_numeric($raw_data_score[0]['datos'], 2); + $data = []; + $data[0] = ''.__('Hardening').''; + $data[1] = $hardening.' %'; + $table_contact->data[] = $data; + } + + // Vulnerabilities line. + $vuls = get_vulnerabilities($agent['id_agente']); + if (is_array($vuls) === true && count($vuls) > 0) { + $score = get_score($vuls); + $data = []; + $data[0] = ''.__('Vulnerability').''; + $data[1] = ui_print_status_vulnerability_div($score); + $table_contact->data[] = $data; + } + $agent_contact = html_print_div( [ 'class' => 'agent_details_header', diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 05eeeb483d..c3d14778d4 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -8252,18 +8252,21 @@ function ui_print_status_vulnerability_div(float $score) } -function ui_print_status_secmon_div($status) +function ui_print_status_secmon_div($status, $title=false) { $class = 'status_rounded_rectangles forced_title'; if (($status) === 'normal') { - return ui_print_div('group_view_ok '.$class, __('normal')); + $title = ($title === false) ? __('normal') : $title; + return ui_print_div('group_view_ok '.$class, $title); } if (($status) === 'warning') { - return ui_print_div('group_view_warn '.$class, __('warning')); + $title = ($title === false) ? __('warning') : $title; + return ui_print_div('group_view_warn '.$class, $title); } if (($status) === 'critical') { - return ui_print_div('group_view_crit '.$class, __('critical')); + $title = ($title === false) ? __('critical') : $title; + return ui_print_div('group_view_crit '.$class, $title); } } \ No newline at end of file