Merge branch 'ent-12522-mejoras-en-audit-log' into 'develop'

Ent 12522 Mejoras en audit log

See merge request artica/pandorafms!6816
This commit is contained in:
Rafael Ameijeiras 2024-01-25 14:00:56 +00:00
commit e19f520eb0
10 changed files with 66 additions and 23 deletions

View File

@ -280,18 +280,17 @@ function dbmgr_extension_main()
if (is_array($result) === false) { if (is_array($result) === false) {
echo '<strong>Output: <strong>'.$result; echo '<strong>Output: <strong>'.$result;
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'DB Interface Extension. SQL',
false,
false,
$sql
);
return; return;
} }
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'DB Interface Extension. SQL',
false,
false,
$sql
);
echo "<div class='overflow'>"; echo "<div class='overflow'>";
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';

View File

@ -250,6 +250,12 @@ if ($delete_layout || $copy_layout) {
$result = db_process_sql_insert('tlayout', $values); $result = db_process_sql_insert('tlayout', $values);
$auditMessage = ((bool) $result !== false) ? 'Copy visual console' : 'Fail try to copy visual console';
db_pandora_audit(
AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
sprintf('%s %s #%s', $auditMessage, $visualConsoleName, $id_layout)
);
$idNewVisualConsole = $result; $idNewVisualConsole = $result;
if ($result) { if ($result) {

View File

@ -626,7 +626,7 @@ switch ($action) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_REPORT_MANAGEMENT, AUDIT_LOG_REPORT_MANAGEMENT,
sprintf('%s #%s', $auditMessage, $idReport) sprintf('%s %s #%s', $auditMessage, $report['name'], $idReport)
); );
ui_print_result_message( ui_print_result_message(
@ -1465,7 +1465,7 @@ switch ($action) {
$auditMessage = ($resultOperationDB === true) ? 'Update report' : 'Fail try to update report'; $auditMessage = ($resultOperationDB === true) ? 'Update report' : 'Fail try to update report';
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_REPORT_MANAGEMENT, AUDIT_LOG_REPORT_MANAGEMENT,
sprintf('%s #%s', $auditMessage, $idReport) sprintf('%s %s #%s', $auditMessage, $new_values['name'], $idReport),
); );
} else { } else {
$resultOperationDB = false; $resultOperationDB = false;
@ -1517,7 +1517,7 @@ switch ($action) {
] ]
); );
$auditMessage = ((bool) $idOrResult === true) ? sprintf('Create report #%s', $idOrResult) : 'Fail try to create report'; $auditMessage = ((bool) $idOrResult === true) ? sprintf('Create report %s #%s', $reportName, $idOrResult) : 'Fail try to create report';
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_REPORT_MANAGEMENT, AUDIT_LOG_REPORT_MANAGEMENT,
$auditMessage $auditMessage

View File

@ -300,7 +300,7 @@ switch ($activeTab) {
ui_update_name_fav_element($idVisualConsole, 'Visual_Console', $values['name']); ui_update_name_fav_element($idVisualConsole, 'Visual_Console', $values['name']);
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT, AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
sprintf('Update visual console #%s', $idVisualConsole) sprintf('Update visual console %s #%s', io_safe_output($values['name']), $idVisualConsole)
); );
$action = 'edit'; $action = 'edit';
$statusProcessInDB = [ $statusProcessInDB = [
@ -320,7 +320,7 @@ switch ($activeTab) {
} else { } else {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT, AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
sprintf('Fail update visual console #%s', $idVisualConsole) sprintf('Fail update visual console %s #%s', $values['name'], $idVisualConsole)
); );
$statusProcessInDB = [ $statusProcessInDB = [
'flag' => false, 'flag' => false,
@ -339,7 +339,7 @@ switch ($activeTab) {
if ($idVisualConsole !== false) { if ($idVisualConsole !== false) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT, AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
sprintf('Create visual console #%s', $idVisualConsole) sprintf('Create visual console %s #%s', io_safe_output($values['name']), $idVisualConsole)
); );
$action = 'edit'; $action = 'edit';
$statusProcessInDB = [ $statusProcessInDB = [
@ -359,7 +359,7 @@ switch ($activeTab) {
} else { } else {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT, AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
'Fail try to create visual console' sprintf('Fail try to create visual console %s #%s', io_safe_output($values['name']), $idVisualConsole)
); );
$statusProcessInDB = [ $statusProcessInDB = [
'flag' => false, 'flag' => false,

View File

@ -819,6 +819,7 @@ define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management');
define('AUDIT_LOG_UMC', 'Warp Manager'); define('AUDIT_LOG_UMC', 'Warp Manager');
define('AUDIT_LOG_NMS_VIOLATION', 'NMS Violation'); define('AUDIT_LOG_NMS_VIOLATION', 'NMS Violation');
define('AUDIT_LOG_ENTERPRISE_VIOLATION', 'Enterprise Violation'); define('AUDIT_LOG_ENTERPRISE_VIOLATION', 'Enterprise Violation');
define('AUDIT_LOG_CRON_TASK', 'Cron task');
// MIMEs. // MIMEs.
define( define(

View File

@ -104,6 +104,7 @@ function config_update_value($token, $value, $noticed=false, $password=false)
return true; return true;
} }
$prev_value = $config[$token];
$config[$token] = $value; $config[$token] = $value;
$value = io_safe_output($value); $value = io_safe_output($value);
@ -117,13 +118,24 @@ function config_update_value($token, $value, $noticed=false, $password=false)
return true; return true;
} else { } else {
// Something in setup changes. // Something in setup changes.
if ($noticed === false) { $value_token = (empty($config[$token]) === true) ? 0 : $config[$token];
$prev_value = (empty($prev_value) === true) ? 0 : $prev_value;
if (is_array($prev_value) === true) {
$prev_value = implode(';', $prev_value);
}
if ($noticed === true && $prev_value !== $value_token) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_SETUP, AUDIT_LOG_SETUP,
'Setup has changed', 'Setup has changed',
false, false,
false, false,
sprintf('Token << %s >> updated.', $token) sprintf(
'Token << %s >> updated %s -> %s',
$token,
$prev_value,
$value_token
)
); );
} }
@ -2094,11 +2106,6 @@ function config_update_config()
} else { } else {
$config['error_config_update_config'] = []; $config['error_config_update_config'] = [];
$config['error_config_update_config']['correct'] = true; $config['error_config_update_config']['correct'] = true;
db_pandora_audit(
AUDIT_LOG_SETUP,
'Setup has changed'
);
} }
if (count($errors) > 0) { if (count($errors) > 0) {

View File

@ -426,6 +426,14 @@ function cron_task_run(
WHERE id=".$id_user_task; WHERE id=".$id_user_task;
} }
db_pandora_audit(
AUDIT_LOG_CRON_TASK,
'Executed cron task: '.$task['name'].' #'.$task['id'],
false,
false,
''
);
db_process_sql($sql); db_process_sql($sql);
db_process_sql($sql2); db_process_sql($sql2);
} }

View File

@ -564,6 +564,13 @@ class Manager implements PublicLogin
]; ];
} }
$auditMessage = ($res === false) ? sprintf('Fail try update dashboard %s #%s', $values['name'], $this->dashboardId) : sprintf('Dashboard update %s #%s', $values['name'], $this->dashboardId);
db_pandora_audit(
AUDIT_LOG_DASHBOARD_MANAGEMENT,
$auditMessage,
false,
);
return $result; return $result;
} }
@ -744,6 +751,13 @@ class Manager implements PublicLogin
} }
} }
$auditMessage = ($result === false) ? sprintf('Fail try copy dashboard %s #%s', $values['name'], $this->dashboardId) : sprintf('Copy dashboard %s #%s', $values['name'], $this->dashboardId);
db_pandora_audit(
AUDIT_LOG_DASHBOARD_MANAGEMENT,
$auditMessage,
false,
);
return $result; return $result;
} }

View File

@ -428,6 +428,13 @@ echo '</div>';
ui_include_time_picker(); ui_include_time_picker();
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/'); ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
db_pandora_audit(
AUDIT_LOG_REPORT_MANAGEMENT,
sprintf('Report visualized %s #%s.', $report['name'], $report['id_report']),
false,
false
);
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">

View File

@ -524,6 +524,7 @@ sub exec_recon_app ($$$) {
logger($pa_config, 'Invalid summary for recon app ID ' . $task->{'id_app'}, 10); logger($pa_config, 'Invalid summary for recon app ID ' . $task->{'id_app'}, 10);
} else { } else {
db_do($dbh, "UPDATE trecon_task SET summary=? WHERE id_rt=?", $summary_json, $task->{'id_rt'}); db_do($dbh, "UPDATE trecon_task SET summary=? WHERE id_rt=?", $summary_json, $task->{'id_rt'});
pandora_audit ($pa_config, 'Discovery task' . ' Executed task '.$task->{'name'}.'#'.$task->{'id_app'}, 'SYSTEM', 'Discovery task', $dbh);
} }
update_recon_task($dbh, $task->{'id_rt'}, $status); update_recon_task($dbh, $task->{'id_rt'}, $status);