From 7164bb0137011b7f5743a2deac121e1d0c18a813 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 28 Apr 2022 13:13:10 +0200 Subject: [PATCH] #8153 Added custom data --- .../reporting_builder.item_editor.php | 26 +++++++++- .../godmode/reporting/reporting_builder.php | 12 +++++ .../include/functions_reporting.php | 18 +++++-- .../include/functions_reporting_html.php | 51 ++++++++++++++++++- 4 files changed, 101 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 2186c455d2..b5c66651b1 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -606,6 +606,7 @@ switch ($action) { $event_graph_by_criticity = $style['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; $filter_search = $style['event_filter_search']; $filter_exclude = $style['event_filter_exclude']; @@ -631,6 +632,7 @@ switch ($action) { $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; break; case 'event_report_module': @@ -665,6 +667,7 @@ switch ($action) { $include_extended_events = $item['show_extended_events']; + $custom_data_events = $style['custom_data_events']; break; case 'general': @@ -2911,6 +2914,23 @@ $class = 'databox filters'; + + + + + + + + + @@ -5974,6 +5994,7 @@ function chooseType() { $("#row_event_graph_by_criticity").hide(); $("#row_event_graph_by_validated").hide(); $("#row_extended_events").hide(); + $("#row_custom_data_events").hide(); $("#row_netflow_filter").hide(); $("#row_max_values").hide(); $("#row_resolution").hide(); @@ -6044,6 +6065,7 @@ function chooseType() { $("#row_event_graph_by_criticity").show(); $("#row_event_graph_by_validated").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_filter_search").show(); $("#row_filter_exclude").show(); @@ -6371,6 +6393,7 @@ function chooseType() { $("#row_event_graph_by_validated").show(); $("#row_event_type").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_filter_search").show(); $("#row_filter_exclude").show(); @@ -6389,7 +6412,7 @@ function chooseType() { $("#row_event_graphs").show(); $("#row_event_type").show(); $("#row_extended_events").show(); - $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); @@ -6414,6 +6437,7 @@ function chooseType() { $("#row_event_graphs").show(); $("#row_event_type").show(); $("#row_extended_events").show(); + $("#row_custom_data_events").show(); $("#row_event_graph_by_user").show(); $("#row_event_graph_by_criticity").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 608f2f6a54..94c9e0b454 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2224,12 +2224,18 @@ switch ($action) { $filter_event_status ); + $custom_data_events = get_parameter_switch( + 'custom_data_events', + 0 + ); + $style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; $style['event_filter_exclude'] = $event_filter_exclude; + $style['custom_data_events'] = $custom_data_events; if ($label != '') { @@ -2957,6 +2963,11 @@ switch ($action) { '' ); + $custom_data_events = get_parameter_switch( + 'custom_data_events', + 0 + ); + // Added for events items. $style['show_summary_group'] = $show_summary_group; @@ -2976,6 +2987,7 @@ switch ($action) { $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_filter_search'] = $event_filter_search; $style['event_filter_exclude'] = $event_filter_exclude; + $style['custom_data_events'] = $custom_data_events; if ($label != '') { $style['label'] = $label; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6bf29c1235..ae40d03de3 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -810,7 +810,7 @@ function reporting_make_reporting_data( break; } - $report['contents'][] = $report_control; + $report['contents'][] = $report_control; break; case 'event_report_module': @@ -826,7 +826,7 @@ function reporting_make_reporting_data( break; } - $report['contents'][] = $report_control; + $report['contents'][] = $report_control; break; case 'event_report_group': @@ -1943,6 +1943,8 @@ function reporting_event_report_group( $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; + $return['show_custom_data'] = (isset($event_filter['custom_data_events']) === true) ? (bool) $event_filter['custom_data_events'] : false; + // Filter. $show_summary_group = $event_filter['show_summary_group']; $filter_event_severity = json_decode($event_filter['filter_event_severity'], true); @@ -2246,6 +2248,8 @@ function reporting_event_report_module( $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; + $return['show_custom_data'] = (isset($event_filter['custom_data_events']) === true) ? (bool) $event_filter['custom_data_events'] : false; + // Filter. $show_summary_group = $event_filter['show_summary_group']; $filter_event_severity = json_decode( @@ -3779,6 +3783,8 @@ function reporting_event_report_agent( $filter_event_status = json_decode($style['filter_event_status'], true); $filter_event_filter_search = $style['event_filter_search']; $filter_event_filter_exclude = $style['event_filter_exclude']; + $show_custom_data = (isset($style['custom_data_events']) === true) ? (bool) $style['custom_data_events'] : false; + $return['show_custom_data'] = $show_custom_data; // Graph. $event_graph_by_user_validator = $style['event_graph_by_user_validator']; @@ -3798,7 +3804,8 @@ function reporting_event_report_agent( $filter_event_status, $filter_event_filter_search, $filter_event_filter_exclude, - $id_server + $id_server, + $show_custom_data ); if (is_metaconsole() === true) { @@ -10594,7 +10601,8 @@ function reporting_get_agents_detailed_event( $filter_event_status=false, $filter_event_filter_search=false, $filter_event_filter_exclude=false, - $id_server=0 + $id_server=0, + $show_custom_data=false ) { global $config; @@ -10651,6 +10659,7 @@ function reporting_get_agents_detailed_event( 'validated_by' => $e['id_usuario'], 'timestamp' => $e['timestamp_rep'], 'id_evento' => $e['id_evento'], + 'custom_data' => ($show_custom_data === true) ? $e['custom_data'] : '', ]; } else { $return_data[] = [ @@ -10661,6 +10670,7 @@ function reporting_get_agents_detailed_event( 'validated_by' => $e['id_usuario'], 'timestamp' => $e['timestamp'], 'id_evento' => $e['id_evento'], + 'custom_data' => ($show_custom_data === true) ? $e['custom_data'] : '', ]; } } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index cd6af07794..d6450e37bd 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -1025,6 +1025,7 @@ function reporting_html_event_report_group($table, $item, $pdf=0) global $config; $show_extended_events = $item['show_extended_events']; + $show_custom_data = (bool) $item['show_custom_data']; if ($item['total_events']) { $table1 = new stdClass(); @@ -1060,6 +1061,10 @@ function reporting_html_event_report_group($table, $item, $pdf=0) $table1->head[6] = __('Timestamp'); } + if ($show_custom_data === true) { + $table1->head[8] = __('Custom data'); + } + foreach ($item['data'] as $k => $event) { // First pass along the class of this row. if ($item['show_summary_group']) { @@ -1132,6 +1137,16 @@ function reporting_html_event_report_group($table, $item, $pdf=0) $data[] = ''.date($config['date_format'], strtotime($event['timestamp'])).''; } + if ($show_custom_data === true) { + $custom_data = json_decode($event['custom_data'], true); + $custom_data_text = ''; + foreach ($custom_data as $key => $value) { + $custom_data_text .= $key.' = '.$value.'
'; + } + + $data[] = $custom_data_text; + } + array_push($table1->data, $data); if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) { @@ -1246,10 +1261,10 @@ function reporting_html_event_report_group($table, $item, $pdf=0) function reporting_html_event_report_module($table, $item, $pdf=0) { global $config; - $show_extended_events = $item['show_extended_events']; $show_summary_group = $item['show_summary_group']; + $show_custom_data = (bool) $item['show_custom_data']; if ($item['total_events']) { if (!empty($item['failed'])) { $table->colspan['events']['cell'] = 3; @@ -1279,6 +1294,10 @@ function reporting_html_event_report_module($table, $item, $pdf=0) $table1->style[0] = 'text-align: center;'; } + if ($show_custom_data === true) { + $table1->head[6] = __('Custom data'); + } + if (is_array($item['data']) || is_object($item['data'])) { $item_data = array_reverse($item['data']); } @@ -1331,6 +1350,16 @@ function reporting_html_event_report_module($table, $item, $pdf=0) $data[4] = date($config['date_format'], strtotime($event['timestamp'])); } + if ($show_custom_data === true) { + $custom_data = json_decode($event['custom_data'], true); + $custom_data_text = ''; + foreach ($custom_data as $key => $value) { + $custom_data_text .= $key.' = '.$value.'
'; + } + + $data[6] = $custom_data_text; + } + $table1->data[] = $data; if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) { @@ -2341,6 +2370,13 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) $table1->align[0] = 'center'; $table1->align[1] = 'center'; $table1->align[3] = 'center'; + if ((bool) $item['show_custom_data'] === true) { + if ($item['show_summary_group']) { + $table1->align[7] = 'left'; + } else { + $table1->align[6] = 'left'; + } + } $table1->data = []; @@ -2355,6 +2391,9 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) $table1->head[4] = __('Severity'); $table1->head[5] = __('Val. by'); $table1->head[6] = __('Timestamp'); + if ((bool) $item['show_custom_data'] === true) { + $table1->head[7] = __('Custom data'); + } foreach ($item['data'] as $i => $event) { if ($item['show_summary_group']) { @@ -2420,6 +2459,16 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) $data[] = ''.date($config['date_format'], strtotime($event['timestamp'])).''; } + if ((bool) $item['show_custom_data'] === true) { + $custom_data = json_decode($event['custom_data'], true); + $custom_data_text = ''; + foreach ($custom_data as $key => $value) { + $custom_data_text .= $key.' = '.$value.'
'; + } + + $data[] = $custom_data_text; + } + array_push($table1->data, $data); if ($show_extended_events == 1 && events_has_extended_info($event['id_evento'])) {