Added source, comment and id_extra in event filter

This commit is contained in:
danielmaya 2018-08-31 16:25:12 +02:00
parent 43a7d4973b
commit 5b30aa5560
8 changed files with 120 additions and 5 deletions

View File

@ -1 +1,9 @@
ALTER TABLE treport_content ADD COLUMN `recursion` TINYINT(1) default NULL;
START TRANSACTION;
ALTER TABLE treport_content ADD COLUMN `recursion` TINYINT(1) default NULL;
ALTER TABLE tevent_filter ADD COLUMN `user_comment` text NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `source` tinytext NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `id_extra` tinytext NOT NULL;
COMMIT;

View File

@ -1213,6 +1213,9 @@ UPDATE `tlink` SET `link` = 'https://github.com/pandorafms/pandorafms/issues' WH
-- ---------------------------------------------------------------------
ALTER TABLE tevent_filter ADD COLUMN `date_from` date DEFAULT NULL;
ALTER TABLE tevent_filter ADD COLUMN `date_to` date DEFAULT NULL;
ALTER TABLE tevent_filter ADD COLUMN `user_comment` text NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `source` tinytext NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `id_extra` tinytext NOT NULL;
-- ---------------------------------------------------------------------
-- Table `tusuario`
-- ---------------------------------------------------------------------

View File

@ -65,6 +65,9 @@ if ($id) {
$group_rep = $filter['group_rep'];
$date_from = str_replace("-","/",$filter['date_from']);
$date_to = str_replace("-","/",$filter['date_to']);
$source = $filter['source'];
$id_extra = $filter['id_extra'];
$user_comment = $filter['user_comment'];
$tag_with_json = $filter['tag_with'];
$tag_with_json_clean = io_safe_output($tag_with_json);
@ -130,6 +133,9 @@ if ($update || $create) {
$group_rep = get_parameter('group_rep', '');
$date_from = get_parameter('date_from', '');
$date_to = get_parameter('date_to', '');
$source = get_parameter('source');
$id_extra = get_parameter('id_extra');
$user_comment = get_parameter('user_comment');
$tag_with_base64 = get_parameter('tag_with', json_encode(array()));
$tag_with_json = io_safe_input(base64_decode($tag_with_base64));
@ -158,6 +164,9 @@ if ($update || $create) {
'tag_without' => $tag_without_json,
'date_from' => $date_from,
'date_to' => $date_to,
'source' => $source,
'id_extra' => $id_extra,
'user_comment' => $user_comment,
'filter_only_alert' => $filter_only_alert);
}
@ -390,6 +399,16 @@ if (!is_metaconsole()) {
$text_module, false, true, '', array(), true, $id_agent_module);
}
$sources = events_get_all_source();
$table ->data[22][0] = '<b>' . __('Source') . '</b>';
$table ->data[22][1] = html_print_select ($sources, 'source', $source, '', '', '', true);
$table ->data[23][0] = '<b>' . __('Extra ID') . '</b>';
$table ->data[23][1] = html_print_input_text ('id_extra', $id_extra, '', 11, 255, true);
$table ->data[24][0] = '<b>' . __('Comment') . '</b>';
$table ->data[24][1] = html_print_input_text ('user_comment', $user_comment, '', 35, 255, true);
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events&section=edit_filter&pure='.$config['pure'].'">';
html_print_table ($table);

View File

@ -1529,7 +1529,31 @@ function events_get_all_status ($report = false) {
}
return $fields;
}
}
/**
* Return all event source.
*
* @return array event source array.
*/
function events_get_all_source () {
$event_table = events_get_events_table(is_metaconsole(),false);
$fields = array ();
$fields[''] = __('All');
if (users_is_admin()) {
$sources = db_get_all_rows_sql("SELECT DISTINCT(source) FROM ". $event_table);
} else {
$groups_user = users_get_groups ($config['id_user'], "ER", true);
$sources = db_get_all_rows_sql("SELECT DISTINCT(source) FROM ". $event_table. " WHERE id_grupo IN (" .implode(",",array_keys($groups_user)) .")");
}
foreach ($sources as $key => $source) {
$fields[$source['source']] = $source['source'];
}
return $fields;
}
/**
* Decode a numeric status into status description.

View File

@ -149,6 +149,18 @@ if ($severity != -1) {
}
}
if ($id_extra != '') {
$sql_post .= " AND id_extra LIKE '%$id_extra%'";
}
if ($user_comment != '') {
$sql_post .= " AND user_comment LIKE '%$user_comment%'";
}
if ($source != '') {
$sql_post .= " AND source LIKE '$source'";
}
// In metaconsole mode the agent search is performed by name
if ($meta) {
$text_agent = get_parameter("text_agent","");

View File

@ -261,6 +261,9 @@ $time_to = (string)get_parameter('time_to', '');
$server_id = (int)get_parameter('server_id', 0);
$text_agent = (string) get_parameter("text_agent");
$refr = (int) get_parameter ('refresh');
$id_extra = (string) get_parameter('id_extra');
$user_comment = (string) get_parameter('user_comment');
$source = (string) get_parameter('source');
if ($id_agent != 0) {
$text_agent = agents_get_alias($id_agent);

View File

@ -89,7 +89,10 @@ if (is_ajax()) {
$values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from');
$values['date_to'] = get_parameter('date_to');
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$exists = (bool)db_get_value_filter(
'id_filter', 'tevent_filter', $values);
@ -129,6 +132,10 @@ if (is_ajax()) {
$values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from');
$values['date_to'] = get_parameter('date_to');
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
if (io_safe_output($values['tag_with']) == "[\"0\"]") {
$values['tag_with'] = "[]";
}
@ -189,6 +196,10 @@ if ($user_filter != 0 && empty($id_name) && !$update_from_filter_table) {
$status = $user_default_filter['status'];
$event_view_hr = $user_default_filter['event_view_hr'];
$group_rep = $user_default_filter['group_rep'];
$id_extra = $user_default_filter['id_extra'];
$user_comment = $user_default_filter['user_comment'];
$source = $user_default_filter['source'];
if ($user_default_filter['search'] != "") {
$search = $user_default_filter['search'];
}
@ -654,6 +665,17 @@ $data[2] .= html_print_select ($repeated_sel, "group_rep", $group_rep, '', '', 0
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$sources = events_get_all_source();
$data[0] = __('Source') . $jump;
$data[0] .= html_print_select ($sources, 'source', $source, '', '', '', true);
$data[1] = __('Extra ID') . $jump;
$data[1] .= html_print_input_text ('id_extra', $id_extra, '', 11, 255, true);
$data[2] = __("Comment") . $jump;
$data[2] .= html_print_input_text ('user_comment', $user_comment, '', 35, 255, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$data[0] = ui_toggle(html_print_table($table_advanced, true),
__('Advanced options'), '', true, true);
@ -952,6 +974,12 @@ $(document).ready( function() {
$("#filter_only_alert").val(val);
if (i == 'id_group_filter')
$("#id_group_filter").val(val);
if (i == 'source')
$("#source").val(val);
if (i == 'id_extra')
$("#text-id_extra").val(val);
if (i == 'user_comment')
$("#text-user_comment").val(val);
});
reorder_tags_inputs();
// Update the info with the loaded filter
@ -990,6 +1018,9 @@ $(document).ready( function() {
$("#pagination").val(20);
$("#update_from_filter_table").val(1);
$("#text_id_agent").val("");
$("#source").val('');
$("#text-id_extra").val('');
$("#text-user_comment").val('');
clear_tags_inputs();
@ -1058,6 +1089,12 @@ $(document).ready( function() {
$("#text-date_to").val(val.replace(/\-/g,"/"));
}
}
if (i == 'source')
$("#source").val(val);
if (i == 'id_extra')
$("#text-id_extra").val(val);
if (i == 'user_comment')
$("#text-user_comment").val(val);
});
reorder_tags_inputs();
// Update the info with the loaded filter
@ -1123,7 +1160,10 @@ $(document).ready( function() {
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group_filter").val(),
"date_from": $("#text-date_from").val(),
"date_to": $("#text-date_to").val()
"date_to": $("#text-date_to").val(),
"source": $("#source").val(),
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val()
},
function (data) {
$(".info_box").hide();
@ -1220,7 +1260,10 @@ $(document).ready( function() {
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group_filter").val(),
"date_from": $("#text-date_from").val(),
"date_to": $("#text-date_to").val()
"date_to": $("#text-date_to").val(),
"source": $("#source").val(),
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val()
},
function (data) {
$(".info_box").hide();

View File

@ -1079,6 +1079,9 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`filter_only_alert` int(10) NOT NULL default -1,
`date_from` date default NULL,
`date_to` date default NULL,
`source` tinytext NOT NULL,
`id_extra` tinytext NOT NULL,
`user_comment` text NOT NULL,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;