From dd453507d23b7a8056b506338525269ace2fd1dd Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 22 Aug 2023 09:53:35 +0200 Subject: [PATCH] #11807 new report top n failed by checks --- .../reporting_builder.item_editor.php | 11 +++++++ .../godmode/reporting/reporting_builder.php | 12 ++++++++ .../include/functions_reporting.php | 7 +++++ .../include/functions_reporting_html.php | 30 +++++++++++++++++++ pandora_console/include/functions_reports.php | 5 ++++ 5 files changed, 65 insertions(+) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index efd9da896c..1aeaa8a1a6 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1037,6 +1037,12 @@ switch ($action) { $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; break; + case 'top_n_categories_checks': + $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']; @@ -7484,6 +7490,11 @@ function chooseType() { $("#row_max_items").show(); break; + case 'top_n_categories_checks': + $("#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 8b5cea5236..48805131d7 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2002,6 +2002,12 @@ switch ($action) { $good_format = true; break; + case 'top_n_categories_checks': + $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'); @@ -2897,6 +2903,12 @@ switch ($action) { $good_format = true; break; + case 'top_n_categories_checks': + $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 b61b005e2d..67c12f73a7 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -949,6 +949,13 @@ function reporting_make_reporting_data( ); break; + case 'top_n_categories_checks': + $report['contents'][] = reporting_top_n_categories_checks( + $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 d532061d80..887c3d5fcb 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -472,6 +472,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) reporting_html_top_n_checks_failed($table, $item); break; + case 'top_n_categories_checks': + reporting_html_top_n_categories_checks($table, $item); + break; + case 'vul_by_cat': reporting_vul_by_cat_graph($table, $item); break; @@ -490,6 +494,32 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) } +/** + * Function to print HTML top checks failed by category + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * + * @return void + */ +function reporting_html_top_n_categories_checks($table, $item) +{ + global $config; + $table->rowclass[0] = ''; + $table->data[1][0] = ''.__('Id').''; + $table->data[1][1] = ''.__('Category').''; + $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['category']; + $table->data[$row][2] = $check['total']; + $row++; + } +} + + /** * Function to print HTML top checks failed. * diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index f4f1f6499e..9e26be5998 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -974,6 +974,11 @@ function reports_get_report_types($template=false, $not_editor=false) 'name' => __('Top-N most frequent failed checks'), ]; + $types['top_n_categories_checks'] = [ + 'optgroup' => __('Security hardening'), + 'name' => __('Top-N checks failed by category'), + ]; + $types['vul_by_cat'] = [ 'optgroup' => __('Security hardening'), 'name' => __('Vulnerabilities by category'),