From abb173c1a7af425fe6830e3dcb8ed55d5a471405 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 18 Aug 2023 10:27:55 +0200 Subject: [PATCH] #11807 new report top checks more frequent --- .../reporting_builder.item_editor.php | 11 +++++ .../godmode/reporting/reporting_builder.php | 12 +++++ .../include/functions_reporting.php | 7 +++ .../include/functions_reporting_html.php | 49 ++++++++++++++++++- pandora_console/include/functions_reports.php | 5 ++ 5 files changed, 83 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 6ecaf98f0d..efd9da896c 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1031,6 +1031,12 @@ switch ($action) { $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; break; + case 'top_n_checks_failed': + $group = $item['id_group']; + $recursion = $item['recursion']; + $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; + break; + case 'vul_by_cat': $group = $item['id_group']; $recursion = $item['recursion']; @@ -7473,6 +7479,11 @@ function chooseType() { $("#row_max_items").show(); break; + case 'top_n_checks_failed': + $("#row_group").show(); + $("#row_max_items").show(); + break; + case 'vul_by_cat': $("#row_group").show(); $("#row_cat_security_hardening").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 1517de9fc1..7ac62c9c45 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1993,6 +1993,12 @@ switch ($action) { $good_format = true; break; + case 'top_n_checks_failed': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + case 'vul_by_cat': $values['id_group'] = get_parameter('combo_group'); $values['cat_security_hardening'] = get_parameter('cat_security_hardening'); @@ -2882,6 +2888,12 @@ switch ($action) { $good_format = true; break; + case 'top_n_checks_failed': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + case 'vul_by_cat': $values['id_group'] = get_parameter('combo_group'); $values['cat_security_hardening'] = get_parameter('cat_security_hardening'); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6561fe9389..b61b005e2d 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -942,6 +942,13 @@ function reporting_make_reporting_data( ); break; + case 'top_n_checks_failed': + $report['contents'][] = reporting_top_n_checks_failed( + $report, + $content + ); + break; + case 'vul_by_cat': $report['contents'][] = reporting_vul_by_categories( $report, diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index bf144cd518..d532061d80 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -468,6 +468,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) reporting_html_top_n_agents_sh($table, $item); break; + case 'top_n_checks_failed': + reporting_html_top_n_checks_failed($table, $item); + break; + case 'vul_by_cat': reporting_vul_by_cat_graph($table, $item); break; @@ -486,18 +490,61 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) } +/** + * Function to print HTML top checks failed. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * + * @return void + */ +function reporting_html_top_n_checks_failed($table, $item) +{ + global $config; + $table->rowclass[0] = ''; + $table->data[1][0] = ''.__('Id').''; + $table->data[1][1] = ''.__('Title').''; + $table->data[1][2] = ''.__('Total Failed').''; + + $row = 2; + foreach ($item['data'] as $key => $check) { + $table->data[$row][0] = $check['id']; + $table->data[$row][1] = $check['title']; + $table->data[$row][2] = $check['total']; + $row++; + } +} + + +/** + * Function to print HTML top categories in graph. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * + * @return void + */ function reporting_vul_by_cat_graph($table, $item) { + $table->rowclass[0] = ''; $table->colspan['chart']['cell'] = 3; $table->cellstyle['chart']['cell'] = 'text-align: center;'; $table->data['chart']['cell'] = $item['chart']; } +/** + * Function to print HTML top n agents from security hardening. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * + * @return void + */ function reporting_html_top_n_agents_sh($table, $item) { global $config; - + $table->rowclass[0] = ''; $table->data[1][0] = ''.__('Agent').''; $table->data[1][1] = ''.__('Last audit scan').''; $table->data[1][2] = ''.__('Score').''; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index fca253153e..f4f1f6499e 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -969,6 +969,11 @@ function reports_get_report_types($template=false, $not_editor=false) 'name' => __('Top-N agents with the worst score'), ]; + $types['top_n_checks_failed'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Top-N most frequent failed checks'), + ]; + $types['vul_by_cat'] = [ 'optgroup' => __('Security hardening'), 'name' => __('Vulnerabilities by category'),