update id_source_event

This commit is contained in:
marcos 2019-11-22 13:38:08 +01:00
parent ab1a64a2e6
commit 21bf49c218
9 changed files with 67 additions and 23 deletions

View File

@ -47,9 +47,10 @@ CREATE TABLE `tremote_command_target` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tconfig`(`token`, `value`) VALUES ('welcome_state', -1);
ALTER TABLE tevent_filter ADD COLUMN id_source_event int(10);
ALTER TABLE `tcredential_store` MODIFY COLUMN `product` enum('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP') default 'CUSTOM';
ALTER TABLE `tevent_filter` ADD COLUMN `id_source_event` int(10);
COMMIT;

View File

@ -1358,7 +1358,7 @@ 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;
ALTER TABLE tevent_filter ADD COLUMN id_source_event int(10);
ALTER TABLE tevent_filter ADD COLUMN `id_source_event` int(10);
ALTER TABLE `tevent_filter` MODIFY COLUMN `user_comment` text NOT NULL;
-- ---------------------------------------------------------------------

View File

@ -588,6 +588,18 @@ $table->data[23][1] = html_print_input_text('id_extra', $id_extra, '', 11, 255,
$table->data[24][0] = '<b>'.__('Comment').'</b>';
$table->data[24][1] = html_print_input_text('user_comment', $user_comment, '', 35, 255, true);
if (is_metaconsole()) {
$table->data[25][0] = '<b>'.__('Id souce event').'</b>';
$table->data[25][1] = html_print_input_text(
'id_source_event',
$id_source_event,
'',
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

@ -84,7 +84,7 @@ $delete_event = get_parameter('delete_event', 0);
$get_event_filters = get_parameter('get_event_filters', 0);
$get_comments = get_parameter('get_comments', 0);
$get_events_fired = (bool) get_parameter('get_events_fired');
$get_id_source_event = get_parameter('get_id_source_event');
if ($get_comments) {
$event = get_parameter('event', false);
$filter = get_parameter('filter', false);
@ -253,7 +253,7 @@ if ($save_event_filter) {
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
$exists = (bool) db_get_value_filter(
'id_filter',
'tevent_filter',
@ -300,6 +300,7 @@ if ($update_event_filter) {
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
if (io_safe_output($values['tag_with']) == '["0"]') {
$values['tag_with'] = '[]';
@ -465,6 +466,8 @@ function load_form_filter() {
$("#text-id_extra").val(val);
if (i == 'user_comment')
$("#text-user_comment").val(val);
if (i == 'id_source_event')
$("#text-id_source_event").val(val);
});
reorder_tags_inputs();
// Update the info with the loaded filter
@ -685,7 +688,8 @@ function save_new_filter() {
"date_to": $("#text-date_to").val(),
"source": $("#text-source").val(),
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val()
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val()
},
function (data) {
$("#info_box").hide();
@ -754,7 +758,9 @@ function save_update_filter() {
"date_to": $("#text-date_to").val(),
"source": $("#text-source").val(),
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val()
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val()
},
function (data) {
$(".info_box").hide();

View File

@ -928,6 +928,16 @@ function events_get_all(
);
}
if (is_metaconsole()) {
// Id source event.
if (!empty($filter['id_source_event'])) {
$sql_filters[] = sprintf(
' AND lower(te.id_source_event) like lower("%%%s%%") ',
$filter['id_source_event']
);
}
}
// User comment.
if (!empty($filter['user_comment'])) {
$sql_filters[] = sprintf(

View File

@ -50,12 +50,6 @@ if (!isset($date_to)) {
$date_to = '';
}
if ($id_source_event != 0 || $id_source_event != '') {
$filter_resume['id_source_event'] = $id_source_event;
} else {
$id_source_event = '';
}
if (($date_from === '') && ($date_to === '')) {
if ($event_view_hr > 0) {
$filter_resume['hours_max'] = $event_view_hr;
@ -237,6 +231,13 @@ if ($source != '') {
$sql_post .= " AND source LIKE '%$source%'";
}
if (is_metaconsole()) {
if ($id_source_event != '') {
$sql_post .= " AND id_source_event LIKE '%$id_source_event%'";
}
}
// In metaconsole mode the agent search is performed by name.
if ($meta) {
$text_agent = get_parameter('text_agent', '');

View File

@ -197,6 +197,10 @@ $history = get_parameter(
);
$section = get_parameter('section', false);
$id_source_event = get_parameter(
'filter[id_source_event]',
$filter['id_source_event']
);
// Ajax responses.
if (is_ajax()) {
$get_events = get_parameter('get_events', 0);
@ -396,6 +400,7 @@ if ($user_filter !== false) {
$source = $filter['source'];
$id_extra = $filter['id_extra'];
$user_comment = $filter['user_comment'];
$id_source_event = $filter['id_source_event'];
}
}
@ -1051,6 +1056,20 @@ $in = '<div class="filter_input"><label>'.__('Alert events').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
if (is_metaconsole()) {
$data = html_print_input_text(
'id_source_event',
$id_source_event,
'',
5,
255,
true
);
$in = '<div class="filter_input"><label>'.__('Id source event').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
}
// Gap.
$adv_inputs[] = '<div class="filter_input"></div>';

View File

@ -258,11 +258,6 @@ if ($user_filter != 0 && empty($id_name) && !$update_from_filter_table) {
$id_extra = $user_default_filter['id_extra'];
$user_comment = $user_default_filter['user_comment'];
$source = $user_default_filter['source'];
$id_source_event = $user_default_filter['id_source_event'];
if (is_metaconsole()) {
$id_source_event = $user_default_filter['id_source_event'];
}
if ($user_default_filter['search'] != '') {
$search = $user_default_filter['search'];
@ -1143,7 +1138,7 @@ if ($group_rep == 0) {
$sql = "SELECT DISTINCT te.*, 1 event_rep,
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name
FROM $event_table te $event_lj
WHERE 1=1 ".$sql_post."
WHERE 1=1 '.$sql_post.'
$order_sql LIMIT ".$offset.','.$pagination;
// Extract the events by filter (or not) from db.
@ -1216,10 +1211,10 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) {
}
if ($group_rep == 0) {
$sql = "SELECT COUNT(DISTINCT id_evento)
$sql = 'SELECT COUNT(DISTINCT id_evento)
FROM $event_table te
$event_lj
WHERE 1=1 $sql_post";
WHERE 1=1 $sql_post';
$total_events = (int) db_get_sql($sql);
} else if ($group_rep == 1) {
$total_events = events_get_events_grouped(
@ -1232,10 +1227,10 @@ if ($group_rep == 0) {
false
);
} else if ($group_rep == 2) {
$sql = "SELECT COUNT(*) FROM (select id_agente as total from $event_table te
$sql = 'SELECT COUNT(*) FROM (select id_agente as total from $event_table te
$event_lj
WHERE id_agente > 0
$sql_post GROUP BY id_agente ORDER BY id_agente ) AS t";
$sql_post GROUP BY id_agente ORDER BY id_agente ) AS t';
$total_events = (int) db_get_sql($sql);
}

View File

@ -1116,7 +1116,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`source` tinytext NOT NULL,
`id_extra` tinytext NOT NULL,
`user_comment` text NOT NULL,
`id_source_event` int(10) default NULL,
`id_source_event` int(10) NULL default 0,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;