change storage format of custom data field in DB

This commit is contained in:
alejandro.campos@artica.es 2022-03-18 11:23:29 +01:00
parent de75277c8a
commit e1ec4ce40e
3 changed files with 26 additions and 3 deletions

View File

@ -2429,6 +2429,9 @@ function events_create_event(
$source = get_product_name();
}
$custom_data = base64_decode($custom_data);
$custom_data = mysql_escape_string_sql($custom_data);
$table_events = 'tevento';
if (is_metaconsole()) {
$table_events = 'tmetaconsole_event';

View File

@ -183,6 +183,29 @@ try {
);
break;
case 'custom_data':
$custom_data_array = json_decode(
$row[$key],
true
);
$custom_data = '';
$separator = ($config['csv_divider'] === ';') ? ',' : ';';
if ($custom_data_array !== null) {
array_walk(
$custom_data_array,
function (&$value, $field) {
$value = $field.'='.$value;
}
);
$custom_data = implode($separator, $custom_data_array);
}
echo io_safe_output($custom_data);
break;
default:
echo io_safe_output($row[$key]);
break;

View File

@ -4301,9 +4301,6 @@ sub cli_create_event() {
print_log "[INFO] Adding event '$event' for agent '$agent_name' \n\n";
# Base64 encode custom data
$custom_data = encode_base64 ($custom_data, '');
pandora_event ($conf, $event, $id_group, $id_agent, $severity,
$id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, safe_input($comment), $id_extra, $tags, $c_instructions, $w_instructions, $u_instructions, $custom_data);