diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 65e93478e3..a54fdefc34 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -117,6 +117,7 @@ $period = SECONDS_1DAY; $search = ''; $full_text = 0; $log_number = 1000; +$inventory_regular_expression = ''; // Added support for projection graphs. $period_pg = SECONDS_5DAY; $projection_period = SECONDS_5DAY; @@ -940,6 +941,7 @@ switch ($action) { $inventory_modules = $es['inventory_modules']; $id_agents = $es['id_agents']; $recursion = $item['recursion']; + $inventory_regular_expression = $es['inventory_regular_expression']; $idAgent = $es['id_agents']; $idAgentModule = $inventory_modules; @@ -2196,6 +2198,15 @@ $class = 'databox filters'; + + + + + + + @@ -6445,6 +6456,7 @@ function chooseType() { $("#row_date").hide(); $("#row_agent_multi").hide(); $("#row_module_multi").hide(); + $('#row_regular_expression').hide(); $("#row_event_graphs").hide(); $("#row_event_graph_by_agent").hide(); $("#row_event_graph_by_user").hide(); @@ -7154,6 +7166,7 @@ function chooseType() { $("#row_group").show(); $("#row_agent_multi").show(); $("#row_module_multi").show(); + $('#row_regular_expression').show(); $("#row_date").show(); $("#id_agents") diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 6fc2056587..cd049f1d83 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1756,6 +1756,7 @@ switch ($action) { $es['inventory_modules'] = get_parameter( 'inventory_modules' ); + $es['inventory_regular_expression'] = get_parameter('inventory_regular_expression', ''); $description = get_parameter('description'); $values['external_source'] = json_encode($es); $good_format = true; @@ -2538,6 +2539,7 @@ switch ($action) { $es['inventory_modules'] = get_parameter( 'inventory_modules' ); + $es['inventory_regular_expression'] = get_parameter('inventory_regular_expression', ''); $values['external_source'] = json_encode($es); $good_format = true; break; diff --git a/pandora_console/include/functions_inventory.php b/pandora_console/include/functions_inventory.php index dc0c23a31c..5b3efedc93 100644 --- a/pandora_console/include/functions_inventory.php +++ b/pandora_console/include/functions_inventory.php @@ -36,7 +36,8 @@ function inventory_get_data( $return_mode=false, $order_by_agent=false, $node='', - $pagination_url_parameters=[] + $pagination_url_parameters=[], + $regular_expression='' ) { global $config; @@ -268,7 +269,15 @@ function inventory_get_data( $i++; } - $data[] = $temp_row; + if ($regular_expression !== '') { + if (is_array(preg_grep('/'.$regular_expression.'/', $temp_row))) { + if (count(preg_grep('/'.$regular_expression.'/', $temp_row)) > 0) { + $data[] = $temp_row; + } + } + } else { + $data[] = $temp_row; + } } } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 9c99d47a2a..deb37fda73 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3170,6 +3170,7 @@ function reporting_inventory($report, $content, $type) $date = $es['date']; $description = $content['description']; + $inventory_regular_expression = $es['inventory_regular_expression']; switch ($type) { case 'data': @@ -3179,7 +3180,11 @@ function reporting_inventory($report, $content, $type) $date, '', false, - 'csv' + 'csv', + false, + '', + [], + $inventory_regular_expression ); break; @@ -3190,7 +3195,11 @@ function reporting_inventory($report, $content, $type) $date, '', false, - 'hash' + 'hash', + false, + '', + [], + $inventory_regular_expression ); break; } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index e1e68b94f0..f37df709c4 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -1996,6 +1996,13 @@ function reporting_html_inventory($table, $item, $pdf=0) && is_array($type_modules) === true ) { foreach ($type_modules as $key_type_module => $type_module) { + $print_table = true; + foreach ($type_module as $key => $module) { + if (count($module['data']) == 0) { + unset($type_module[$key]); + } + } + $table1 = new stdClass(); $table1->width = '99%'; $table1->class = 'info_table'; @@ -2006,57 +2013,62 @@ function reporting_html_inventory($table, $item, $pdf=0) if (isset($type_module) === true && is_array($type_module) === true ) { - foreach ($type_module as $key_type => $module) { - if (isset($module['data']) === true - && is_array($module['data']) === true - ) { - array_pop($module['data']); - foreach ($module['data'] as $k_module => $v_module) { - $str_key = $key_type_module.'-'.$key_type.'-'.$k_module; - $table1->head[0] = __('Agent'); - $table1->head[1] = __('Module'); - $table1->head[2] = __('Date'); - $table1->headstyle[0] = 'text-align: left'; - $table1->headstyle[1] = 'text-align: left'; - $table1->headstyle[2] = 'text-align: left'; - $table1->cellstyle[$str_key][0] = 'text-align: left;'; - $table1->cellstyle[$str_key][1] = 'text-align: left;'; - $table1->cellstyle[$str_key][2] = 'text-align: left;'; - $table1->data[$str_key][0] = $module['agent_name']; - $table1->data[$str_key][1] = $key_type_module; - $dateModule = explode(' ', $module['timestamp']); - $table1->data[$str_key][2] = $dateModule[0]; - if (isset($v_module) === true - && is_array($v_module) === true - ) { - foreach ($v_module as $k => $v) { - $table1->head[$k] = $k; - $table1->headstyle[$k] = 'text-align: left'; - $table1->cellstyle[$str_key][$k] = 'text-align: left;'; - if ($pdf === 0) { - $table1->data[$str_key][$k] = $v; - } else { - // Workaround to prevent table columns from growing indefinitely in PDFs. - $table1->data[$str_key][$k] = preg_replace( - '/([^\s]{30})(?=[^\s])/', - '$1'.'
', - $v - ); + if (count($type_module) > 0) { + foreach ($type_module as $key_type => $module) { + if (isset($module['data']) === true + && is_array($module['data']) === true + ) { + foreach ($module['data'] as $k_module => $v_module) { + $str_key = $key_type_module.'-'.$key_type.'-'.$k_module; + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); + $table1->head[2] = __('Date'); + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->cellstyle[$str_key][0] = 'text-align: left;'; + $table1->cellstyle[$str_key][1] = 'text-align: left;'; + $table1->cellstyle[$str_key][2] = 'text-align: left;'; + $table1->data[$str_key][0] = $module['agent_name']; + $table1->data[$str_key][1] = $key_type_module; + $dateModule = explode(' ', $module['timestamp']); + $table1->data[$str_key][2] = $dateModule[0]; + if (isset($v_module) === true + && is_array($v_module) === true + ) { + foreach ($v_module as $k => $v) { + $table1->head[$k] = $k; + $table1->headstyle[$k] = 'text-align: left'; + $table1->cellstyle[$str_key][$k] = 'text-align: left;'; + if ($pdf === 0) { + $table1->data[$str_key][$k] = $v; + } else { + // Workaround to prevent table columns from growing indefinitely in PDFs. + $table1->data[$str_key][$k] = preg_replace( + '/([^\s]{30})(?=[^\s])/', + '$1'.'
', + $v + ); + } } } } } } + } else { + $print_table = false; } + } else { + $print_table = false; } - if ($pdf === 0) { + if ($pdf === 0 && $print_table === true) { $table->colspan[$key_type_module]['cell'] = 3; $table->data[$key_type_module]['cell'] = html_print_table( $table1, true ); - } else { + } else if ($print_table === true) { $return_pdf .= html_print_table( $table1, true @@ -5988,7 +6000,7 @@ function reporting_get_events($data, $links=false) $tooltip = ui_print_help_tip( __( - "Event count corresponds to events within the last hour" + 'Event count corresponds to events within the last hour' ), true );