#11807 new report top checks more frequent

This commit is contained in:
Daniel Cebrian 2023-08-18 10:27:55 +02:00
parent 9327d50306
commit abb173c1a7
5 changed files with 83 additions and 1 deletions

View File

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

View File

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

View File

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

View File

@ -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] = '<b>'.__('Id').'</b>';
$table->data[1][1] = '<b>'.__('Title').'</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['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] = '<b>'.__('Agent').'</b>';
$table->data[1][1] = '<b>'.__('Last audit scan').'</b>';
$table->data[1][2] = '<b>'.__('Score').'</b>';

View File

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