Merge branch 'ent-12519-anadir-el-campo-event-custom-id-a-la-creacion-de-eventos-por-cli-y-api' into 'develop'

Ent-12519-anadir-el-campo-event-custom-id-a-la-creacion-de-eventos-por-cli-y-api

Closes pandora_enterprise#12519

See merge request artica/pandorafms!6769
This commit is contained in:
Diego Muñoz-Reja 2024-01-22 15:49:32 +00:00
commit 9bdcfb4b4d
3 changed files with 19 additions and 10 deletions

View File

@ -13182,6 +13182,12 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['id_extra'] = '';
}
if ($other['data'][21] != '') {
$values['event_custom_id'] = $other['data'][21];
}else{
$values['event_custom_id'] = '';
}
$custom_data = base64_decode($values['custom_data']);
$custom_data = mysql_escape_string_sql($custom_data);
@ -13204,7 +13210,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['server_id'],
$values['id_extra'],
$ack_utimestamp,
$values['event_custom_id'] ?? null
$values['event_custom_id']
);
if ($other['data'][12] != '') {

View File

@ -4273,13 +4273,15 @@ Generate an event.
=cut
##########################################################################
#sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$$) {
#sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$$$) {
sub pandora_event {
my ($pa_config, $evento, $id_grupo, $id_agente, $severity,
$id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh,
$source, $user_name, $comment, $id_extra, $tags,
$critical_instructions, $warning_instructions, $unknown_instructions, $custom_data,
$module_data, $module_status, $server_id) = @_;
$module_data, $module_status, $server_id, $event_custom_id) = @_;
$event_custom_id //= "";
my $agent = undef;
if (defined($id_agente) && $id_agente != 0) {
@ -4332,7 +4334,7 @@ sub pandora_event {
my $utimestamp = time ();
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
my $event_custom_id = undef;
$id_agentmodule = 0 unless defined ($id_agentmodule);
# Validate events with the same event id

View File

@ -200,7 +200,7 @@ sub help_screen{
help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system');
help_screen_line('--disable_double_auth', '<user_name>', 'Disable the double authentication for the specified user');
print "\nEVENTS:\n\n" unless $param ne '';
help_screen_line('--create_event', "<event> <event_type> <group_name> [<agent_name> <module_name>\n\t <event_status> <severity> <template_name> <user_name> <comment> \n\t <source> <id_extra> <tags> <custom_data_json> <force_create_agent> \n\t <critical_instructions> <warning_instructions> <unknown_instructions> <use_alias>]", 'Add event');
help_screen_line('--create_event', "<event> <event_type> <group_name> [<agent_name> <module_name>\n\t <event_status> <severity> <template_name> <user_name> <comment> <source> \n\t <id_extra> <tags> <custom_data_json> <force_create_agent> <critical_instructions> \n\t <warning_instructions> <unknown_instructions> <use_alias> <event_custom_id>]", 'Add event');
help_screen_line('--update_event_custom_id', "<event> <event_custom_id>", 'Update Event Custom ID');
help_screen_line('--validate_event', "<agent_name> <module_name> <datetime_min> <datetime_max>\n\t <user_name> <criticity> <template_name> [<use_alias>]", 'Validate events');
help_screen_line('--validate_event_id', '<event_id>', 'Validate event given a event id');
@ -4454,7 +4454,7 @@ sub cli_delete_profile() {
##############################################################################
sub cli_create_event() {
my ($event,$event_type,$group_name,$agent_name,$module_name,$event_status,$severity,$template_name, $user_name, $comment, $source, $id_extra, $tags, $custom_data,$force_create_agent,$c_instructions,$w_instructions,$u_instructions,$use_alias,$server_id) = @ARGV[2..21];
my ($event,$event_type,$group_name,$agent_name,$module_name,$event_status,$severity,$template_name, $user_name, $comment, $source, $id_extra, $tags, $custom_data,$force_create_agent,$c_instructions,$w_instructions,$u_instructions,$use_alias,$server_id,$event_custom_id) = @ARGV[2..22];
$event_status = 0 unless defined($event_status);
$severity = 0 unless defined($severity);
@ -4513,7 +4513,7 @@ sub cli_create_event() {
print_log "[INFO] Adding event '$event' for agent '$agent_name' \n\n";
pandora_event ($conf, $event, $id_group, $id_agent, $severity,
$id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, safe_input($comment), safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id);
$id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, safe_input($comment), safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id, safe_input($event_custom_id));
}
} else {
if (! $agent_name) {
@ -4562,7 +4562,7 @@ sub cli_create_event() {
print_log "[INFO] Adding event '$event' for agent '$agent_name' \n\n";
pandora_event ($conf, $event, $id_group, $id_agent, $severity,
$id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, $comment, safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id);
$id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, $comment, safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id, safe_input($event_custom_id));
}
}
@ -7943,10 +7943,11 @@ sub pandora_manage_main ($$$) {
{'name' => 'warning_instructions'},
{'name' => 'unknown_instructions'},
{'name' => 'use_alias'},
{'name' => 'metaconsole'}
{'name' => 'metaconsole'},
{'name' => 'event_custom_id'}
);
param_check($ltotal, 20, 17);
param_check($ltotal, 21, 18);
check_values(\@fields);