Merge branch 'ent-5229-filtro-event-report' into 'develop'

Added string exclude filter to events reports

See merge request artica/pandorafms!3748
This commit is contained in:
Daniel Rodriguez 2021-03-01 15:28:18 +00:00
commit 23cddae261
4 changed files with 168 additions and 68 deletions

View File

@ -140,6 +140,8 @@ $visual_format = 0;
// Others.
$filter_search = '';
$filter_exclude = '';
// Added for select fields.
$total_time = true;
@ -556,6 +558,8 @@ switch ($action) {
$include_extended_events = $item['show_extended_events'];
$filter_search = $style['event_filter_search'];
$filter_exclude = $style['event_filter_exclude'];
break;
case 'event_report_group':
@ -570,6 +574,7 @@ switch ($action) {
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$filter_search = $style['event_filter_search'];
$filter_exclude = $style['event_filter_exclude'];
$filter_event_severity = json_decode($style['filter_event_severity'], true);
$filter_event_status = json_decode($style['filter_event_status'], true);
@ -607,6 +612,8 @@ switch ($action) {
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$filter_search = $style['event_filter_search'];
$filter_exclude = $style['event_filter_exclude'];
$include_extended_events = $item['show_extended_events'];
break;
@ -2744,10 +2751,20 @@ $class = 'databox filters';
</tr>
<tr id="row_filter_search" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Free search'); ?></td>
<td style="font-weight:bold;"><?php echo __('Include filter'); ?></td>
<td>
<?php
html_print_input_text('filter_search', $filter_search);
ui_print_help_tip(__('Free text string search on event description'));
?>
</td>
</tr>
<tr id="row_filter_exclude" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Exclude filter'); ?></td>
<td>
<?php
html_print_input_text('filter_exclude', $filter_exclude);
ui_print_help_tip(__('Free text string search on event description'));
?>
</td>
</tr>
@ -5141,6 +5158,7 @@ function chooseType() {
$("#row_resolution").hide();
$("#row_last_value").hide();
$("#row_filter_search").hide();
$("#row_filter_exclude").hide();
$("#row_percentil").hide();
$("#log_help_tip").css("visibility", "hidden");
$("#agents_row").hide();
@ -5191,6 +5209,8 @@ function chooseType() {
$("#row_extended_events").show();
$("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_event_severity").show();
$("#row_event_status").show();
@ -5484,6 +5504,8 @@ function chooseType() {
$("#row_extended_events").show();
$("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_historical_db_check").hide();
break;
@ -5507,6 +5529,8 @@ function chooseType() {
$('#agent_autocomplete').hide();
$('#agent_autocomplete_events').show();
$("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_historical_db_check").hide();
break;
@ -5529,6 +5553,8 @@ function chooseType() {
$('#agent_autocomplete').hide();
$('#agent_autocomplete_events').show();
$("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_historical_db_check").hide();
break;

View File

@ -1881,6 +1881,11 @@ switch ($action) {
''
);
$event_filter_exclude = get_parameter(
'filter_exclude',
''
);
// If metaconsole is activated.
if (is_metaconsole() === true) {
if (($values['type'] == 'custom_graph')
@ -2018,6 +2023,8 @@ switch ($action) {
$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;
if ($label != '') {
$style['label'] = $label;
@ -2622,6 +2629,12 @@ switch ($action) {
''
);
$event_filter_exclude = get_parameter(
'filter_exclude',
''
);
// Added for events items.
$style['show_summary_group'] = $show_summary_group;
$style['filter_event_severity'] = json_encode(
@ -2639,6 +2652,8 @@ switch ($action) {
$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;
if ($label != '') {
$style['label'] = $label;
} else {

View File

@ -2878,20 +2878,21 @@ function events_get_group_events_steps(
*
* The returned events will be in the time interval ($date - $period, $date]
*
* @param integer $id_agent Agent id to get events.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $history History.
* @param boolean $show_summary_group Show_summary_group.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $id_group Id_group.
* @param boolean $events_group Events_group.
* @param boolean $id_agent_module Id_agent_module.
* @param boolean $events_module Events_module.
* @param boolean $id_server Id_server.
* @param integer $id_agent Agent id to get events.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $history History.
* @param boolean $show_summary_group Show_summary_group.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $id_group Id_group.
* @param boolean $events_group Events_group.
* @param boolean $id_agent_module Id_agent_module.
* @param boolean $events_module Events_module.
* @param boolean $id_server Id_server.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
*
* @return array An array with all the events happened.
*/
@ -2909,7 +2910,8 @@ function events_get_agent(
$events_group=false,
$id_agent_module=false,
$events_module=false,
$id_server=false
$id_server=false,
$filter_event_filter_exclude=false
) {
global $config;
@ -3017,6 +3019,10 @@ function events_get_agent(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
}
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
if ($events_group) {
$secondary_groups = sprintf(
' INNER JOIN tgrupo tg
@ -5114,14 +5120,15 @@ function events_clean_tags($tags)
*
* The returned events will be in the time interval ($date - $period, $date]
*
* @param mixed $id_group Group id to get events for.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param mixed $id_group Group id to get events for.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
*
* @return array An array with all the events happened.
*/
@ -5133,7 +5140,8 @@ function events_get_count_events_by_agent(
$filter_event_type=false,
$filter_event_status=false,
$filter_event_filter_search=false,
$dbmeta=false
$dbmeta=false,
$filter_event_filter_exclude=false
) {
global $config;
@ -5233,6 +5241,10 @@ function events_get_count_events_by_agent(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
}
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$tagente = 'tagente';
$tevento = 'tevento';
@ -5285,14 +5297,15 @@ function events_get_count_events_by_agent(
*
* The returned events will be in the time interval ($date - $period, $date]
*
* @param array $filter Use target filter.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param array $filter Use target filter.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
*
* @return array An array with all the events happened.
*/
@ -5304,7 +5317,8 @@ function events_get_count_events_validated_by_user(
$filter_event_type=false,
$filter_event_status=false,
$filter_event_filter_search=false,
$dbmeta=false
$dbmeta=false,
$filter_event_filter_exclude=false
) {
global $config;
$tevento = 'tevento';
@ -5426,6 +5440,10 @@ function events_get_count_events_validated_by_user(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
}
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$sql = sprintf(
'SELECT
te.id_usuario,
@ -5474,14 +5492,15 @@ function events_get_count_events_validated_by_user(
*
* The returned events will be in the time interval ($date - $period, $date]
*
* @param mixed $filter Target filter.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param mixed $filter Target filter.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
*
* @return array An array with all the events happened.
*/
@ -5493,7 +5512,8 @@ function events_get_count_events_by_criticity(
$filter_event_type=false,
$filter_event_status=false,
$filter_event_filter_search=false,
$dbmeta=false
$dbmeta=false,
$filter_event_filter_exclude=false
) {
global $config;
@ -5617,6 +5637,10 @@ function events_get_count_events_by_criticity(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
}
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$sql = sprintf(
'SELECT
te.criticity,
@ -5656,14 +5680,15 @@ function events_get_count_events_by_criticity(
*
* The returned events will be in the time interval ($date - $period, $date]
*
* @param mixed $filter Target filter.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param mixed $filter Target filter.
* @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
*
* @return array An array with all the events happened.
*/
@ -5675,7 +5700,8 @@ function events_get_count_events_validated(
$filter_event_type=false,
$filter_event_status=false,
$filter_event_filter_search=false,
$dbmeta=false
$dbmeta=false,
$filter_event_filter_exclude=false
) {
global $config;
$tevento = 'tevento';
@ -5828,6 +5854,10 @@ function events_get_count_events_validated(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
}
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$sql = sprintf(
'SELECT
te.estado,

View File

@ -1868,6 +1868,10 @@ function reporting_event_report_group(
$return['subtitle'] .= ' ('.$content['style']['event_filter_search'].')';
}
if (!empty($content['style']['event_filter_exclude'])) {
$return['subtitle'] .= ' ('.__('Exclude ').$content['style']['event_filter_exclude'].')';
}
$return['description'] = $content['description'];
$return['show_extended_events'] = $content['show_extended_events'];
$return['date'] = reporting_get_date_text($report, $content);
@ -1880,6 +1884,7 @@ function reporting_event_report_group(
$filter_event_type = json_decode($event_filter['filter_event_type'], true);
$filter_event_status = json_decode($event_filter['filter_event_status'], true);
$filter_event_filter_search = $event_filter['event_filter_search'];
$filter_event_filter_exclude = $event_filter['event_filter_exclude'];
// Graphs.
$event_graph_by_agent = $event_filter['event_graph_by_agent'];
@ -1919,7 +1924,11 @@ function reporting_event_report_group(
$filter_event_status,
$filter_event_filter_search,
$content['id_group'],
true
true,
false,
false,
false,
$filter_event_filter_exclude
);
if (empty($data)) {
@ -1965,7 +1974,8 @@ function reporting_event_report_group(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$return['chart']['by_agent'] = pie_graph(
@ -1990,7 +2000,8 @@ function reporting_event_report_group(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$return['chart']['by_user_validator'] = pie_graph(
@ -2044,7 +2055,8 @@ function reporting_event_report_group(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$return['chart']['validated_vs_unvalidated'] = pie_graph(
@ -2189,6 +2201,7 @@ function reporting_event_report_module(
true
);
$filter_event_filter_search = $event_filter['event_filter_search'];
$filter_event_filter_exclude = $event_filter['event_filter_exclude'];
// Graphs.
$event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
@ -2218,7 +2231,8 @@ function reporting_event_report_module(
$event_graph_validated_vs_unvalidated,
$ttl,
$id_server,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
if (empty($data)) {
@ -3259,6 +3273,7 @@ function reporting_event_report_agent(
$filter_event_type = json_decode($style['filter_event_type'], true);
$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'];
// Graph.
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
@ -3276,7 +3291,8 @@ function reporting_event_report_agent(
$filter_event_severity,
$filter_event_type,
$filter_event_status,
$filter_event_filter_search
$filter_event_filter_search,
$filter_event_filter_exclude
);
reporting_set_conf_charts(
@ -3316,7 +3332,8 @@ function reporting_event_report_agent(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$return['chart']['by_user_validator'] = pie_graph(
@ -3341,7 +3358,8 @@ function reporting_event_report_agent(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$colors = get_criticity_pie_colors($data_graph);
@ -3370,7 +3388,8 @@ function reporting_event_report_agent(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$return['chart']['validated_vs_unvalidated'] = pie_graph(
@ -9406,7 +9425,8 @@ function reporting_get_module_detailed_event(
$event_graph_validated_vs_unvalidated=false,
$ttl=1,
$id_server=false,
$metaconsole_dbtable=false
$metaconsole_dbtable=false,
$filter_event_filter_exclude=false
) {
global $config;
@ -9442,7 +9462,8 @@ function reporting_get_module_detailed_event(
false,
$id_module,
true,
$id_server
$id_server,
$filter_event_filter_exclude
);
// total_events
@ -9470,7 +9491,8 @@ function reporting_get_module_detailed_event(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$event['chart']['by_user_validator'] = pie_graph(
@ -9495,7 +9517,8 @@ function reporting_get_module_detailed_event(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$colors = get_criticity_pie_colors($data_graph);
@ -9524,7 +9547,8 @@ function reporting_get_module_detailed_event(
$filter_event_type,
$filter_event_status,
$filter_event_filter_search,
$metaconsole_dbtable
$metaconsole_dbtable,
$filter_event_filter_exclude
);
$event['chart']['validated_vs_unvalidated'] = pie_graph(
@ -9573,7 +9597,8 @@ function reporting_get_agents_detailed_event(
$filter_event_severity=false,
$filter_event_type=false,
$filter_event_status=false,
$filter_event_filter_search=false
$filter_event_filter_search=false,
$filter_event_filter_exclude=false
) {
global $config;
@ -9605,7 +9630,11 @@ function reporting_get_agents_detailed_event(
$filter_event_status,
$filter_event_filter_search,
false,
false
false,
false,
false,
false,
$filter_event_filter_exclude
);
if (empty($event)) {