#11807 added new report scoring

This commit is contained in:
Daniel Cebrian 2023-08-24 09:24:31 +02:00
parent 61839db7ff
commit ae288e3dd4
5 changed files with 69 additions and 1 deletions

View File

@ -1058,6 +1058,11 @@ switch ($action) {
$idAgent = $item['id_agent']; $idAgent = $item['id_agent'];
break; break;
case 'scoring':
$group = $item['id_group'];
$recursion = $item['recursion'];
break;
default: default:
// It's not possible. // It's not possible.
break; break;
@ -7538,6 +7543,10 @@ function chooseType() {
$("#row_cat_security_hardening").show(); $("#row_cat_security_hardening").show();
$("#row_status_check").show(); $("#row_status_check").show();
break; break;
case 'scoring':
$("#row_group").show();
break;
} }
switch (type) { switch (type) {

View File

@ -2022,6 +2022,11 @@ switch ($action) {
$good_format = true; $good_format = true;
break; break;
case 'scoring':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
default: default:
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period');
$values['top_n'] = get_parameter( $values['top_n'] = get_parameter(
@ -2930,6 +2935,11 @@ switch ($action) {
$good_format = true; $good_format = true;
break; break;
case 'scoring':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
default: default:
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period');
$values['top_n'] = get_parameter( $values['top_n'] = get_parameter(

View File

@ -970,6 +970,13 @@ function reporting_make_reporting_data(
); );
break; break;
case 'scoring':
$report['contents'][] = reporting_scoring(
$report,
$content
);
break;
default: default:
// Default. // Default.
break; break;

View File

@ -483,6 +483,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
case 'list_checks': case 'list_checks':
reporting_html_list_checks($table, $item); reporting_html_list_checks($table, $item);
break; break;
case 'scoring':
reporting_html_scoring($table, $item);
break;
} }
if ($item['type'] == 'agent_module') { if ($item['type'] == 'agent_module') {
@ -498,6 +502,38 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
} }
/**
* Function to print the agents scoring.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
*
* @return void
*/
function reporting_html_scoring($table, $item)
{
global $config;
$table1 = new stdClass();
$table1->width = '100%';
$table1->class = 'databox filters';
$table1->styleTable = 'border: 0px;';
$table1->data[0][0] = '<b>'.__('Date').'</b>';
$table1->data[0][1] = '<b>'.__('Agent').'</b>';
$table1->data[0][2] = '<b>'.__('Score').'</b>';
$row = 1;
foreach ($item['data'] as $key => $check) {
$table1->data[$row][1] = date($config['date_format'], $check['date']);
$table1->data[$row][2] = $check['agent'];
$table1->data[$row][3] = $check['scoring'].' %';
$row++;
}
$table->colspan[2][0] = 3;
$table->data[2][0] = html_print_table($table1, true);
}
/** /**
* Function to print HTML checks filtered by agent and category. * Function to print HTML checks filtered by agent and category.
* *
@ -509,7 +545,8 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
function reporting_html_list_checks($table, $item) function reporting_html_list_checks($table, $item)
{ {
$table->rowclass[0] = ''; $table->rowclass[0] = '';
$table->colspan[0][1] = 3; $table->colspan[0][1] = 2;
$table->align[3] = 'center';
$table->data[1][0] = '<b>'.__('Id').'</b>'; $table->data[1][0] = '<b>'.__('Id').'</b>';
$table->data[1][1] = '<b>'.__('Title').'</b>'; $table->data[1][1] = '<b>'.__('Title').'</b>';
$table->data[1][2] = '<b>'.__('Category').'</b>'; $table->data[1][2] = '<b>'.__('Category').'</b>';

View File

@ -988,6 +988,11 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Security hardening'), 'optgroup' => __('Security hardening'),
'name' => __('List of checks'), 'name' => __('List of checks'),
]; ];
$types['scoring'] = [
'optgroup' => __('Security hardening'),
'name' => __('Scoring'),
];
} }
return $types; return $types;