Merge remote-tracking branch 'origin/develop' into ent-12019-api-2-0

Conflicts:
	pandora_console/include/constants.php
This commit is contained in:
daniel 2024-01-25 15:46:40 +01:00
commit f1e3328f37
14 changed files with 121 additions and 41 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

@ -308,13 +308,18 @@ $table->head[0] = __('Actions');
$table->style[0] = 'font-weight: bold; text-align: left;'; $table->style[0] = 'font-weight: bold; text-align: left;';
if (count($actions) == 1 && isset($actions[0])) { if (count($actions) == 1 && isset($actions[0])) {
$table->head[1] = __('Every time that the alert is fired'); if (!empty($actions[0]['name'])) {
$table->data[0][0] = $actions[0]['name']; $table->head[1] = __('Every time that the alert is fired');
$table->data[0][1] = html_print_image( $table->data[0][0] = $actions[0]['name'];
'images/tick.png', $table->data[0][1] = html_print_image(
true, 'images/tick.png',
['class' => 'invert_filter'] true,
); ['class' => 'invert_filter']
);
} else {
$table->colspan[0] = 2;
$table->data[0] = __('No action defined.');
}
} else { } else {
foreach ($actions as $kaction => $action) { foreach ($actions as $kaction => $action) {
$table->data[$kaction][0] = $action['name']; $table->data[$kaction][0] = $action['name'];

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

@ -1900,12 +1900,24 @@ if (check_login()) {
unset($expl[$exist]); unset($expl[$exist]);
} }
array_push($expl, '1', '2'); array_push($expl, '1', '2', '3', '4', '5');
$status = implode(',', $expl); $status = implode(',', $expl);
} }
if (empty($status) === false) { if (str_contains($status, '5') === true) {
$expl = explode(',', $status);
$exist = array_search('5', $expl);
if (isset($exist) === true) {
unset($expl[$exist]);
}
array_push($expl, '4', '5');
$status = implode(',', $expl);
}
if (empty($status) === false || $status === '0') {
$where .= sprintf( $where .= sprintf(
' AND tagente_estado.estado IN (%s) ' AND tagente_estado.estado IN (%s)
AND tagente_modulo.delete_pending = 0', AND tagente_modulo.delete_pending = 0',
@ -2148,24 +2160,25 @@ if (check_login()) {
); );
switch ((int) $row['estado']) { switch ((int) $row['estado']) {
case 0: case AGENT_MODULE_STATUS_NORMAL:
$status_img = ui_print_status_image(STATUS_MODULE_OK, __('Normal'), true); $status_img = ui_print_status_image(STATUS_MODULE_OK, __('Normal'), true);
break; break;
case 1: case AGENT_MODULE_STATUS_CRITICAL_BAD:
case 6: case AGENT_MODULE_STATUS_NOT_NORMAL:
$status_img = ui_print_status_image(STATUS_MODULE_CRITICAL, __('Critical'), true); $status_img = ui_print_status_image(STATUS_MODULE_CRITICAL, __('Critical'), true);
break; break;
case 2: case AGENT_MODULE_STATUS_WARNING:
$status_img = ui_print_status_image(STATUS_MODULE_WARNING, __('Warning'), true); $status_img = ui_print_status_image(STATUS_MODULE_WARNING, __('Warning'), true);
break; break;
case 3: case AGENT_MODULE_STATUS_UNKNOWN:
$status_img = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('Unknown'), true); $status_img = ui_print_status_image(STATUS_MODULE_UNKNOWN, __('Unknown'), true);
break; break;
case 5: case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_NOT_INIT:
$status_img = ui_print_status_image(STATUS_MODULE_NO_DATA, __('Not init'), true); $status_img = ui_print_status_image(STATUS_MODULE_NO_DATA, __('Not init'), true);
break; break;

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');
define('AUDIT_LOG_EVENT', 'Events'); define('AUDIT_LOG_EVENT', 'Events');
// MIMEs. // MIMEs.

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

@ -523,7 +523,19 @@ class ModulesByStatus extends Widget
unset($expl[$exist]); unset($expl[$exist]);
} }
array_push($expl, '1', '2'); array_push($expl, '1', '2', '3', '4', '5');
$status = implode(',', $expl);
}
if (str_contains($status, '5') === true) {
$expl = explode(',', $status);
$exist = array_search('5', $expl);
if (isset($exist) === true) {
unset($expl[$exist]);
}
array_push($expl, '4', '5');
$status = implode(',', $expl); $status = implode(',', $expl);
} }

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

@ -418,8 +418,10 @@ sub process_xml_data ($$$$$) {
# A module with No-learn mode (modo = 0) creates its modules on database only when it is created # A module with No-learn mode (modo = 0) creates its modules on database only when it is created
my $new_agent = 0; my $new_agent = 0;
# Get agent id # Get agent id from tagente.
my $agent_id = get_agent_id ($dbh, $agent_name); my $agent_id = get_db_value ($dbh, "SELECT id_agente FROM tagente WHERE nombre = ?", safe_input($agent_name));
$agent_id = -1 unless defined($agent_id);
my $group_id = 0; my $group_id = 0;
if ($agent_id < 1) { if ($agent_id < 1) {
if ($pa_config->{'autocreate'} == 0) { if ($pa_config->{'autocreate'} == 0) {
@ -627,6 +629,11 @@ sub process_xml_data ($$$$$) {
my $module_type = get_tag_value ($module_data, 'type', 'generic_data'); my $module_type = get_tag_value ($module_data, 'type', 'generic_data');
# Apply timezone offset to module if timestamp is set.
if (defined($module_data->{'timestamp'} && $module_data->{'timestamp'} ne '')) {
$module_data->{'timestamp'} = strftime ("%Y-%m-%d %H:%M:%S", localtime($module_data->{'timestamp'} + ($timezone_offset * 3600)));
}
# Single data # Single data
if (! defined ($module_data->{'datalist'})) { if (! defined ($module_data->{'datalist'})) {
my $data_timestamp = get_tag_value ($module_data, 'timestamp', $timestamp); my $data_timestamp = get_tag_value ($module_data, 'timestamp', $timestamp);

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);