#11807 new report top n failed by checks

This commit is contained in:
Daniel Cebrian 2023-08-22 09:53:35 +02:00
parent 0696ca60da
commit dd453507d2
5 changed files with 65 additions and 0 deletions

View File

@ -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();

View File

@ -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');

View File

@ -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,

View File

@ -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] = '<b>'.__('Id').'</b>';
$table->data[1][1] = '<b>'.__('Category').'</b>';
$table->data[1][2] = '<b>'.__('Total Failed').'</b>';
$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.
*

View File

@ -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'),