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,6 +280,8 @@ function dbmgr_extension_main()
if (is_array($result) === false) {
echo '<strong>Output: <strong>'.$result;
return;
}
db_pandora_audit(
AUDIT_LOG_SYSTEM,
@ -289,9 +291,6 @@ function dbmgr_extension_main()
$sql
);
return;
}
echo "<div class='overflow'>";
$table = new stdClass();
$table->width = '100%';

View File

@ -250,6 +250,12 @@ if ($delete_layout || $copy_layout) {
$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;
if ($result) {

View File

@ -626,7 +626,7 @@ switch ($action) {
db_pandora_audit(
AUDIT_LOG_REPORT_MANAGEMENT,
sprintf('%s #%s', $auditMessage, $idReport)
sprintf('%s %s #%s', $auditMessage, $report['name'], $idReport)
);
ui_print_result_message(
@ -1465,7 +1465,7 @@ switch ($action) {
$auditMessage = ($resultOperationDB === true) ? 'Update report' : 'Fail try to update report';
db_pandora_audit(
AUDIT_LOG_REPORT_MANAGEMENT,
sprintf('%s #%s', $auditMessage, $idReport)
sprintf('%s %s #%s', $auditMessage, $new_values['name'], $idReport),
);
} else {
$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(
AUDIT_LOG_REPORT_MANAGEMENT,
$auditMessage

View File

@ -300,7 +300,7 @@ switch ($activeTab) {
ui_update_name_fav_element($idVisualConsole, 'Visual_Console', $values['name']);
db_pandora_audit(
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';
$statusProcessInDB = [
@ -320,7 +320,7 @@ switch ($activeTab) {
} else {
db_pandora_audit(
AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
sprintf('Fail update visual console #%s', $idVisualConsole)
sprintf('Fail update visual console %s #%s', $values['name'], $idVisualConsole)
);
$statusProcessInDB = [
'flag' => false,
@ -339,7 +339,7 @@ switch ($activeTab) {
if ($idVisualConsole !== false) {
db_pandora_audit(
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';
$statusProcessInDB = [
@ -359,7 +359,7 @@ switch ($activeTab) {
} else {
db_pandora_audit(
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 = [
'flag' => false,

View File

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

View File

@ -104,6 +104,7 @@ function config_update_value($token, $value, $noticed=false, $password=false)
return true;
}
$prev_value = $config[$token];
$config[$token] = $value;
$value = io_safe_output($value);
@ -117,13 +118,24 @@ function config_update_value($token, $value, $noticed=false, $password=false)
return true;
} else {
// 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(
AUDIT_LOG_SETUP,
'Setup has changed',
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 {
$config['error_config_update_config'] = [];
$config['error_config_update_config']['correct'] = true;
db_pandora_audit(
AUDIT_LOG_SETUP,
'Setup has changed'
);
}
if (count($errors) > 0) {

View File

@ -426,6 +426,14 @@ function cron_task_run(
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($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;
}
@ -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;
}

View File

@ -428,6 +428,13 @@ echo '</div>';
ui_include_time_picker();
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">

View File

@ -524,6 +524,7 @@ sub exec_recon_app ($$$) {
logger($pa_config, 'Invalid summary for recon app ID ' . $task->{'id_app'}, 10);
} else {
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);