diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 9fd0d8c7ef..557b855e09 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -922,22 +922,25 @@ $tableAdvancedAgent->data['safe_operation'][] = html_print_label_input_block( ) ); -$tableAdvancedAgent->data['vul_scan_enabled'][] = html_print_label_input_block( - __('Vulnerability scanning'), - html_print_select( - [ - 0 => __('Disabled'), - 1 => __('Enabled'), - 2 => __('Use global settings'), - ], - 'vul_scan_enabled', - $vul_scan_enabled, - '', - '', - 0, - true - ) -); +if (enterprise_installed() === true) { + $tableAdvancedAgent->data['vul_scan_enabled'][] = html_print_label_input_block( + __('Vulnerability scanning'), + html_print_select( + [ + 0 => __('Disabled'), + 1 => __('Enabled'), + 2 => __('Use global settings'), + ], + 'vul_scan_enabled', + $vul_scan_enabled, + '', + '', + 0, + true + ) + ); +} + ui_toggle( html_print_table($tableAdvancedAgent, true), diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 794605bdaa..58dd396fbf 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1116,6 +1116,18 @@ switch ($action) { $vul_av = (empty($es['vul_av']) === true) ? 'all' : $es['vul_av']; break; + case 'top_n_agents_vuls': + $group = $item['id_group']; + $recursion = $item['recursion']; + $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; + break; + + case 'top_n_vuls_count': + $group = $item['id_group']; + $recursion = $item['recursion']; + $top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value']; + break; + default: // It's not possible. break; @@ -5922,6 +5934,21 @@ $(document).ready (function () { return false; } break; + + case 'top_n_agents_vuls': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; + + case 'top_n_vuls_count': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; + default: break; } @@ -6082,7 +6109,18 @@ $(document).ready (function () { return false; } break; - + case 'top_n_agents_vuls': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; + case 'top_n_vuls_count': + if ($("#text-max_items").val() == '') { + dialog_message('#message_no_max_item'); + return false; + } + break; default: break; } @@ -8080,6 +8118,16 @@ function chooseType() { updatePackages(); }); break; + + case 'top_n_agents_vuls': + $("#row_group").show(); + $("#row_max_items").show(); + break; + + case 'top_n_vuls_count': + $("#row_group").show(); + $("#row_max_items").show(); + break; } switch (type) { diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index a69704abdd..8b07b6263f 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2083,6 +2083,18 @@ switch ($action) { $good_format = true; break; + case 'top_n_agents_vuls': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_vuls_count': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -3053,6 +3065,18 @@ switch ($action) { $good_format = true; break; + case 'top_n_agents_vuls': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + + case 'top_n_vuls_count': + $values['id_group'] = get_parameter('combo_group'); + $values['top_n_value'] = get_parameter('max_items'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 9e128191c1..0588b9b972 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1063,6 +1063,22 @@ function reporting_make_reporting_data( ); break; + case 'top_n_agents_vuls': + $report['contents'][] = reporting_top_n_agents_vuls( + $report, + $content, + $type + ); + break; + + case 'top_n_vuls_count': + $report['contents'][] = reporting_top_n_vuls_count( + $report, + $content, + $type + ); + break; + default: // Default. break; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index b78fadab88..40d3d6e6b2 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -527,6 +527,14 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust case 'vuls_info_agent': reporting_html_vuls_info_agent($table, $item); break; + + case 'top_n_agents_vuls': + reporting_html_top_n_agents_vuls($table, $item); + break; + + case 'top_n_vuls_count': + reporting_html_top_n_vuls_count($table, $item); + break; } if ($item['type'] == 'agent_module') { @@ -542,6 +550,94 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust } +/** + * Function to print top vulnerabiries more common. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_top_n_vuls_count($table, $item, $pdf=0) +{ + global $config; + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle = []; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = __('Vulnerability'); + $table1->head[2] = __('Total'); + + $row = 2; + foreach ($item['data'] as $key => $vul) { + $table1->data[$row][0] = $vul['cve_id']; + $table1->data[$row][2] = $vul['count']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + +/** + * Function to print top agents with worst score. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_top_n_agents_vuls($table, $item, $pdf=0) +{ + global $config; + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle = []; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = __('Agent'); + $table1->head[2] = __('Risk'); + + $row = 2; + foreach ($item['data'] as $key => $agent) { + $table1->data[$row][0] = $agent['alias']; + $table1->data[$row][2] = $agent['score']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + if ($pdf === 1) { + return html_print_table($table, true); + } +} + + /** * Function to print vulnerabilities of agent. * @@ -582,21 +678,21 @@ function reporting_html_vuls_info_agent($table, $item, $pdf=0) $row = 1; foreach ($item['data'] as $key => $vul) { - $table1->data[$row][0] = $vul['name']; - $table1->data[$row][1] = $vul['cve']; - $table1->data[$row][2] = $vul['version']; - $table1->data[$row][3] = $vul['score']; - $table1->data[$row][4] = $vul['detection_time']; - $table1->data[$row][5] = $vul['severity']; - $table1->data[$row][6] = $vul['CVSS']; - $table1->data[$row][7] = $vul['AV']; - $table1->data[$row][8] = $vul['AC']; - $table1->data[$row][9] = $vul['PR']; - $table1->data[$row][10] = $vul['UI']; - $table1->data[$row][11] = $vul['S']; - $table1->data[$row][12] = $vul['C']; - $table1->data[$row][13] = $vul['I']; - $table1->data[$row][14] = $vul['A']; + $table1->data[$row][0] = (key_exists('name', $vul) === true) ? $vul['name'] : ''; + $table1->data[$row][1] = (key_exists('cve', $vul) === true) ? $vul['cve'] : ''; + $table1->data[$row][2] = (key_exists('version', $vul) === true) ? $vul['version'] : ''; + $table1->data[$row][3] = (key_exists('score', $vul) === true) ? $vul['score'] : ''; + $table1->data[$row][4] = (key_exists('detection_time', $vul) === true) ? $vul['detection_time'] : ''; + $table1->data[$row][5] = (key_exists('severity', $vul) === true) ? $vul['severity'] : ''; + $table1->data[$row][6] = (key_exists('CVSS', $vul) === true) ? $vul['CVSS'] : ''; + $table1->data[$row][7] = (key_exists('AV', $vul) === true) ? $vul['AV'] : ''; + $table1->data[$row][8] = (key_exists('AC', $vul) === true) ? $vul['AC'] : ''; + $table1->data[$row][9] = (key_exists('PR', $vul) === true) ? $vul['PR'] : ''; + $table1->data[$row][10] = (key_exists('UI', $vul) === true) ? $vul['UI'] : ''; + $table1->data[$row][11] = (key_exists('S', $vul) === true) ? $vul['S'] : ''; + $table1->data[$row][12] = (key_exists('C', $vul) === true) ? $vul['C'] : ''; + $table1->data[$row][13] = (key_exists('I', $vul) === true) ? $vul['I'] : ''; + $table1->data[$row][14] = (key_exists('A', $vul) === true) ? $vul['A'] : ''; $row++; } diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 7c46469a7c..e5b8f52b7b 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -1028,6 +1028,16 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Vulnerabilities'), 'name' => __('Vulnerabilities of agent'), ]; + + $types['top_n_agents_vuls'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Top-N agents with more risk'), + ]; + + $types['top_n_vuls_count'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Top-N common vulnerabilities'), + ]; } return $types;