From e4f24b2452433320571476477f9a3b94f68182e3 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Thu, 5 Apr 2018 16:57:26 +0200 Subject: [PATCH] Fixed json in audit log --- .../godmode/alerts/alert_actions.php | 9 +- .../godmode/alerts/alert_commands.php | 2 +- .../godmode/alerts/alert_special_days.php | 6 +- .../alerts/configure_alert_command.php | 2 +- .../alerts/configure_alert_template.php | 2 - .../massive/massive_add_action_alerts.php | 11 +- .../godmode/massive/massive_copy_modules.php | 11 +- .../massive/massive_delete_action_alerts.php | 13 +- .../godmode/massive/massive_delete_agents.php | 7 +- .../godmode/massive/massive_delete_alerts.php | 9 +- .../massive/massive_delete_modules.php | 7 +- .../massive/massive_delete_profiles.php | 7 +- .../godmode/massive/massive_edit_agents.php | 8 +- .../godmode/massive/massive_edit_modules.php | 2 +- .../massive/massive_enable_disable_alerts.php | 4 +- .../massive/massive_standby_alerts.php | 4 +- .../godmode/users/profile_list.php | 117 +++++++----------- 17 files changed, 99 insertions(+), 122 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index e2a061b550..b60388e6fa 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -168,9 +168,8 @@ if ($create_action) { $result = alerts_create_alert_action ($name, $id_alert_command, $values); - $info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command . - $info_fields . ' Group: ' . $values['id_group'] . - ' Action threshold: ' . $values['action_threshold']; + $info = '{"Name":"'.$name.'", "ID alert Command":"'.$id_alert_command.'", "Field information":"'.$info_fields.'", "Group":"'.$values['id_group'].'", + "Action threshold":"'.$values['action_threshold'].'"}'; } if ($result) { @@ -245,10 +244,6 @@ if ($update_action) { } else { $result = alerts_update_alert_action ($id, $values); - - $info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command . - $info_fields . ' Group: ' . $group . - ' Action threshold: ' . $action_threshold; } if ($result) { diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 10edc6bead..09e868f951 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -294,7 +294,7 @@ if ($create_command) { $result = alerts_create_alert_command ($name, $command, $values); - $info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description. ' ' .$info_fields; + $info = '{"Name":"'.$name.'","Command":"'.$command.'","Description":"'.$description. ' '.$info_fields.'"}'; } else { $result = ''; diff --git a/pandora_console/godmode/alerts/alert_special_days.php b/pandora_console/godmode/alerts/alert_special_days.php index 8a872267e6..c221f963af 100644 --- a/pandora_console/godmode/alerts/alert_special_days.php +++ b/pandora_console/godmode/alerts/alert_special_days.php @@ -133,7 +133,7 @@ if ($create_special_day) { } else { $result = alerts_create_alert_special_day ($date, $same_day, $values); - $info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $values['description']; + $info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$values['description'].'"}'; } } @@ -186,12 +186,12 @@ if ($update_special_day) { } else { $result = alerts_update_alert_special_day ($id, $values); - $info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $description; + $info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}'; } } else { $result = alerts_update_alert_special_day ($id, $values); - $info = 'Date: ' . $date . ' Same day of the week: ' . $same_day . ' Description: ' . $description; + $info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}'; } } diff --git a/pandora_console/godmode/alerts/configure_alert_command.php b/pandora_console/godmode/alerts/configure_alert_command.php index ca173e4569..983b8d90ff 100644 --- a/pandora_console/godmode/alerts/configure_alert_command.php +++ b/pandora_console/godmode/alerts/configure_alert_command.php @@ -79,7 +79,7 @@ if ($update_command) { } else { $result = alerts_update_alert_command ($id, $values); - $info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description. ' ' .$info_fields; + $info = '{"Name":"'.$name.'","Command":"'.$command.'","Description":"'.$description. ' '.$info_fields.'"}'; } if ($result) { diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index d2cc13a702..cdd9186946 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -418,13 +418,11 @@ if ($create_template) { $result = ''; } if ($result) { - //db_pandora_audit("Command management", "Create alert command " . $result, false, false, json_encode($values)); db_pandora_audit("Template alert management", "Create alert template #" . $result, false, false, json_encode($values)); } else { - //db_pandora_audit("Command management", "Fail try to create alert command", false, false, json_encode($values)); db_pandora_audit("Template alert management", "Fail try to create alert template", false, false, json_encode($values)); diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index ca4c33e262..faec370e12 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -104,11 +104,12 @@ if ($add) { $results = false; } } - - db_pandora_audit("Massive management", "Add alert action " . json_encode($id_agents), false, false, 'Agents: ' . - json_encode($id_agents) . ' Alerts : ' . json_encode($agent_alerts) . - ' Fires Min: ' . $fires_min . ' Fires Max: ' . $fires_max . ' Actions: ' . implode(',',$actions)); - + $info = array('Agents' => implode(',',$id_agents), + 'Alerts' => addslashes(io_json_mb_encode($agent_alerts)), + 'Fires Min' => $fires_min, + 'Fires_max' => $fires_max, + 'Actions' => implode(',',$actions)); + db_pandora_audit("Massive management", "Add alert action " . json_encode($id_agents), false, false, json_encode($info)); ui_print_result_message ($results, __('Successfully added'), __('Could not be added')); } } diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 3d51a85a51..aae7d4e2df 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -43,15 +43,18 @@ $do_operation = (bool) get_parameter ('do_operation'); if ($do_operation) { $result = agents_process_manage_config($source_id_agent, $destiny_id_agents); + + $info = array('Source agent' => $source_id_agent, + 'Destinity agent' => implode(",",$destiny_id_agents)); if ($result) { + + db_pandora_audit("Massive management", "Copy modules", false, - false, - 'Source agent: ' . json_encode($source_id_agent) . ' Destinity agent: ' . json_encode($destiny_id_agents)); + false, json_encode($info)); } else { db_pandora_audit("Massive management", - "Fail to try copy modules", false, false, - 'Source agent: ' . json_encode($source_id_agent) . ' Destinity agent: ' . json_encode($destiny_id_agents)); + "Fail to try copy modules", false, false,json_encode($info)); } } diff --git a/pandora_console/godmode/massive/massive_delete_action_alerts.php b/pandora_console/godmode/massive/massive_delete_action_alerts.php index a36363d19f..cc80206a20 100644 --- a/pandora_console/godmode/massive/massive_delete_action_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_action_alerts.php @@ -98,16 +98,15 @@ if ($delete) { } } } - + $info = array('Agents' => implode(',',$id_agents), + 'Alert templates' => implode(",",$id_alert_templates), + 'Actions' => implode(',',$actions)); + if ($results) { - db_pandora_audit("Massive management", "Delete alert action", false, false, - 'Agent: ' . json_encode($id_agents) . ' Alert templates: ' . json_encode($id_alert_templates) . - ' Actions: ' . implode(',',$actions)); + db_pandora_audit("Massive management", "Delete alert action", false, false,json_encode($info)); } else { - db_pandora_audit("Massive management", "Fail try to delete alert action", false, false, - 'Agent: ' . json_encode($id_agents) . ' Alert templates: ' . json_encode($id_alert_templates) . - ' Actions: ' . implode(',',$actions)); + db_pandora_audit("Massive management", "Fail try to delete alert action", false, false, json_encode($info)); } ui_print_result_message ($results, diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index 295411c92a..a9e8dcc08c 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -76,13 +76,12 @@ $delete = (bool) get_parameter_post ('delete'); if ($delete) { $result = process_manage_delete ($id_agents); + $info = '{"Agent":"'.implode(",",$id_agents).'"}'; if ($result) { - db_pandora_audit("Massive management", "Delete agent ", false, false, - 'Agent: ' . json_encode($id_agents)); + db_pandora_audit("Massive management", "Delete agent ", false, false,$info); } else { - db_pandora_audit("Massive management", "Fail try to delete agent", false, false, - 'Agent: ' . json_encode($id_agents)); + db_pandora_audit("Massive management", "Fail try to delete agent", false, false,$info); } } diff --git a/pandora_console/godmode/massive/massive_delete_alerts.php b/pandora_console/godmode/massive/massive_delete_alerts.php index fd7d04f860..eb0fd60dc3 100755 --- a/pandora_console/godmode/massive/massive_delete_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_alerts.php @@ -170,13 +170,14 @@ $delete = (bool) get_parameter_post ('delete'); if ($delete) { $result = process_manage_delete ($id_alert_template, $id_agents, $module_names); + $info = array('Agent' => implode(",",$id_agents), + 'Template' => $id_alert_template, 'Module' => implode(",",$module_names)); + if ($result) { - db_pandora_audit("Massive management", "Delete alert ", false, false, - 'Agent: ' . json_encode($id_agents) . ' Template: ' . $id_alert_template . ' Module: ' . $module_names); + db_pandora_audit("Massive management", "Delete alert ", false, false,json_encode($info)); } else { - db_pandora_audit("Massive management", "Fail try to delete alert", false, false, - 'Agent: ' . json_encode($id_agents) . ' Template: ' . $id_alert_template . ' Module: ' . $module_names); + db_pandora_audit("Massive management", "Fail try to delete alert", false, false,json_encode($info)); } } diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index 580c86c26c..d1dd485db2 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -349,13 +349,12 @@ if ($delete) { $result = process_manage_delete ($modules_, $agents_, $modules_selection_mode); } + $info = array('Agent' => implode(",",$agents_), 'Module' => implode(",",$modules_)); if ($result) { - db_pandora_audit("Massive management", "Delete module ", false, false, - 'Agent: ' . json_encode($agents_) . ' Module: ' . $module_name); + db_pandora_audit("Massive management", "Delete module ", false, false, json_encode($info)); } else { - db_pandora_audit("Massive management", "Fail try to delete module", false, false, - 'Agent: ' . json_encode($agents_) . ' Module: ' . $module_name); + db_pandora_audit("Massive management", "Fail try to delete module", false, false, json_encode($info)); } } diff --git a/pandora_console/godmode/massive/massive_delete_profiles.php b/pandora_console/godmode/massive/massive_delete_profiles.php index daf9e91246..3d958d7a94 100644 --- a/pandora_console/godmode/massive/massive_delete_profiles.php +++ b/pandora_console/godmode/massive/massive_delete_profiles.php @@ -74,13 +74,12 @@ if ($delete_profiles) { } } + $info = array('Profiles' => implode(",",$profiles_id), 'Groups' => implode(",",$groups_id), 'Users' => implode(",",$users_id)); if ($result) { - db_pandora_audit("Massive management", "Delete profile ", false, false, - 'Profiles: ' . json_encode($profiles_id) . ' Groups: ' . $groups_id . ' Users: ' . $users_id); + db_pandora_audit("Massive management", "Delete profile ", false, false, json_encode($info)); } else { - db_pandora_audit("Massive management", "Fail try to delete profile", false, false, - 'Profiles: ' . json_encode($profiles_id) . ' Groups: ' . $groups_id . ' Users: ' . $users_id); + db_pandora_audit("Massive management", "Fail try to delete profile", false, false, json_encode($info)); } ui_print_result_message ($result, diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index 99837ca824..3918ada3be 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -197,14 +197,18 @@ if ($update_agents) { } } + $info = array(); // Update Custom Fields foreach ($fields as $field) { + $info[$field['id_field']] = $field['name']; if (get_parameter_post ('customvalue_' . $field['id_field'], '') != '') { $key = $field['id_field']; $value = get_parameter_post ('customvalue_' . $field['id_field'], ''); $old_value = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agent, 'id_field' => $key)); + + if ($old_value === false) { // Create custom field if not exist $result = db_process_sql_insert ('tagent_custom_data', @@ -225,11 +229,11 @@ if ($update_agents) { if ($result !== false) { - db_pandora_audit("Massive management", "Update agent " . $id_agent, false, false, json_encode($fields)); + db_pandora_audit("Massive management", "Update agent " . $id_agent, false, false, json_encode($info)); } else { if (isset ($id_agent)) { - db_pandora_audit("Massive management", "Try to update agent " . $id_agent, false, false, json_encode($fields)); + db_pandora_audit("Massive management", "Try to update agent " . $id_agent, false, false, json_encode($info)); } } diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index b0889bd5ea..a7c8626fce 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -162,7 +162,7 @@ if ($update) { __('Successfully updated') . "(" . $success . "/" . $count . ")", $error_msg); - $info = 'Modules: ' . json_encode($modules_) . ' Agents: ' . json_encode($agents_); + $info = '{"Modules":"'.implode(",",$modules_).'","Agents":"'.implode(",",$agents_).'"}'; if ($success > 0) { db_pandora_audit("Massive management", "Edit module", false, false, $info); } diff --git a/pandora_console/godmode/massive/massive_enable_disable_alerts.php b/pandora_console/godmode/massive/massive_enable_disable_alerts.php index 7d799c1f70..aa82305865 100644 --- a/pandora_console/godmode/massive/massive_enable_disable_alerts.php +++ b/pandora_console/godmode/massive/massive_enable_disable_alerts.php @@ -77,7 +77,7 @@ switch ($action) { ui_print_result_message ($result, __('Successfully enabled'), __('Could not be enabled')); - $info = 'Alert: ' . json_encode($id_disabled_alerts); + $info = '{"Alert":"'.implode(",",$id_disabled_alerts).'"}'; if ($result) { db_pandora_audit("Massive management", "Enable alert", false, false, $info); } @@ -95,7 +95,7 @@ switch ($action) { ui_print_result_message ($result, __('Successfully disabled'), __('Could not be disabled')); - $info = 'Alert: ' . json_encode($id_enabled_alerts); + $info = '{"Alert":"'.implode(",",$id_enabled_alerts).'"}'; if ($result) { db_pandora_audit("Massive management", "Disable alert", false, false, $info); } diff --git a/pandora_console/godmode/massive/massive_standby_alerts.php b/pandora_console/godmode/massive/massive_standby_alerts.php index 6af3940680..496e72707c 100644 --- a/pandora_console/godmode/massive/massive_standby_alerts.php +++ b/pandora_console/godmode/massive/massive_standby_alerts.php @@ -77,7 +77,7 @@ switch($action) { ui_print_result_message ($result, __('Successfully set off standby'), __('Could not be set off standby')); - $info = 'Alert: ' . json_encode($id_standby_alerts); + $info = '{"Alert":"'.implode(",",$id_standby_alerts).'"}'; if ($result) { db_pandora_audit("Massive management", "Set off standby alerts", false, false, $info); } @@ -95,7 +95,7 @@ switch($action) { ui_print_result_message ($result, __('Successfully set standby'), __('Could not be set standby')); - $info = 'Alert: ' . json_encode($id_not_standby_alerts); + $info = '{"Alert":"'.implode(",",$id_not_standby_alerts).'"}'; if ($result) { db_pandora_audit("Massive management", "Set on standby alerts", false, false, $info); } diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php index cde2fe80d9..f593be58d0 100644 --- a/pandora_console/godmode/users/profile_list.php +++ b/pandora_console/godmode/users/profile_list.php @@ -182,40 +182,30 @@ if ($update_profile) { if ($name) { $ret = db_process_sql_update('tperfil', $values, array('id_perfil' => $id_profile)); if ($ret !== false) { - $info = 'Name: ' . $name . - - ' Incident view: ' . $incident_view . - ' Incident edit: ' . $incident_edit . - ' Incident management: ' . $incident_management . - - ' Agent view: ' . $agent_view . - ' Agent edit: ' . $agent_edit . - ' Agent disable: ' . $agent_disable . - - ' Alert edit: ' . $alert_edit . - ' Alert management: ' . $alert_management . - - ' User management: ' . $user_management . - - ' DB management: ' . $db_management . - - ' Event view: ' . $event_view . - ' Event edit: ' . $event_edit . - ' Event management: ' . $event_management . - - ' Report view: ' . $report_view . - ' Report edit: ' . $report_edit . - ' Report management: ' . $report_management . - - ' Network map view: ' . $map_view . - ' Network map edit: ' . $map_edit . - ' Network map management: ' . $map_management . - - ' Visual console view: ' . $vconsole_view . - ' Visual console edit: ' . $vconsole_edit . - ' Visual console management: ' . $vconsole_management . - - ' Pandora Management: ' . $pandora_management; + $info = '{"Name":"'.$incident_view.'", + "Incident view":"'.$incident_view.'", + "Incident edit":"'.$incident_edit.'", + "Incident management":"'.$incident_management.'", + "Agent view":"'.$agent_view.'", + "Agent edit":"'.$agent_edit.'", + "Agent disable":"'.$agent_disable.'", + "Alert edit":"'.$alert_edit.'", + "Alert management":"'.$alert_management.'", + "User management":"'.$user_management.'", + "DB management":"'.$db_management.'", + "Event view":"'.$event_view.'", + "Event edit":"'.$event_edit.'", + "Event management":"'.$event_management.'", + "Report view":"'.$report_view.'", + "Report edit":"'.$report_edit.'", + "Report management":"'.$report_management.'", + "Network map view":"'.$map_view.'", + "Network map edit":"'.$map_edit.'", + "Network map management":"'.$map_management.'", + "Visual console view":"'.$vconsole_view.'", + "Visual console edit":"'.$vconsole_edit.'", + "Visual console management":"'.$vconsole_management.'", + "Pandora Management":"'.$pandora_management.'"}'; db_pandora_audit("User management", "Update profile ". $name, false, false, $info); @@ -239,41 +229,30 @@ if ($create_profile) { if ($ret !== false) { ui_print_success_message(__('Successfully created')); - - $info = 'Name: ' . $name . - - ' Incident view: ' . $incident_view . - ' Incident edit: ' . $incident_edit . - ' Incident management: ' . $incident_management . - - ' Agent view: ' . $agent_view . - ' Agent edit: ' . $agent_edit . - ' Agent disable: ' . $agent_disable . - - ' Alert edit: ' . $alert_edit . - ' Alert management: ' . $alert_management . - - ' User management: ' . $user_management . - - ' DB management: ' . $db_management . - - ' Event view: ' . $event_view . - ' Event edit: ' . $event_edit . - ' Event management: ' . $event_management . - - ' Report view: ' . $report_view . - ' Report edit: ' . $report_edit . - ' Report management: ' . $report_management . - - ' Network map view: ' . $map_view . - ' Network map edit: ' . $map_edit . - ' Network map management: ' . $map_management . - - ' Visual console view: ' . $vconsole_view . - ' Visual console edit: ' . $vconsole_edit . - ' Visual console management: ' . $vconsole_management . - - ' Pandora Management: ' . $pandora_management; + $info = '{"Name":"'.$incident_view.'", + "Incident view":"'.$incident_view.'", + "Incident edit":"'.$incident_edit.'", + "Incident management":"'.$incident_management.'", + "Agent view":"'.$agent_view.'", + "Agent edit":"'.$agent_edit.'", + "Agent disable":"'.$agent_disable.'", + "Alert edit":"'.$alert_edit.'", + "Alert management":"'.$alert_management.'", + "User management":"'.$user_management.'", + "DB management":"'.$db_management.'", + "Event view":"'.$event_view.'", + "Event edit":"'.$event_edit.'", + "Event management":"'.$event_management.'", + "Report view":"'.$report_view.'", + "Report edit":"'.$report_edit.'", + "Report management":"'.$report_management.'", + "Network map view":"'.$map_view.'", + "Network map edit":"'.$map_edit.'", + "Network map management":"'.$map_management.'", + "Visual console view":"'.$vconsole_view.'", + "Visual console edit":"'.$vconsole_edit.'", + "Visual console management":"'.$vconsole_management.'", + "Pandora Management":"'.$pandora_management.'"}'; db_pandora_audit("User management", "Created profile ". $name, false, false, $info);