diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b63ac8b1504143648bd3e359f65be5fbcbf291d..d60cd2cdf3b14993db699c142b4fd2bf4105eccc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ - Correction de la correspondance simulateur/ftp pour les instances de développement #1240 +### Sécurité + +- Correction d'un message d'erreur trop verbeux #1246 + ## 5.1.0 - 2025-02-12 ## Dépréciations diff --git a/class/Helpers.php b/class/Helpers.php index 7416058afd2e3893e78b873992d4eb5c033eaa7e..a6e6c91a7c4bd0b441a1c2747bade50e85cbbfc9 100644 --- a/class/Helpers.php +++ b/class/Helpers.php @@ -651,21 +651,21 @@ class Helpers } /** - * @param string $var + * @param string|null $var * @param bool $nullable * @param $name - * @return mixed + * @return string|null */ public static function checkInt(?string $var, bool $nullable, $name): ?string { if (is_null($var) && !$nullable) { throw new UnexpectedValueException("$name est null "); } - if (is_null($var) && $nullable) { - return $var; + if (is_null($var)) { + return null; } - if ($var === "" && $nullable) { - return ""; + if ($var === '' && $nullable) { + return ''; } if (!ctype_digit($var) && !(is_null($var) && $nullable)) { throw new UnexpectedValueException("$name n'est pas un entier"); diff --git a/public.ssl/common/logs_get_timestamp.php b/public.ssl/common/logs_get_timestamp.php index 9836e336ee632a00699a5602057ac5b817a7f0e7..b79a4c1536b6c51294ae35b07f7371b2d1d24633 100644 --- a/public.ssl/common/logs_get_timestamp.php +++ b/public.ssl/common/logs_get_timestamp.php @@ -23,40 +23,46 @@ use S2lowLegacy\Class\User; $me = new User(); if (! $me->authenticate()) { - $_SESSION["error"] = "Échec de l'authentification"; - header("Location: " . Helpers::getLink("connexion-status")); + $_SESSION['error'] = "Échec de l'authentification"; + header('Location: ' . Helpers::getLink('connexion-status')); exit(); } -$id = Helpers::getVarFromGet("id"); +try { + $log_id = Helpers::getIntFromGet('id'); +} catch (Exception $e) { + $_SESSION['error'] = $e->getMessage(); + header('Location: ' . Helpers::getLink('/common/logs_view.php')); + exit(); +} -$myAuthority = new Authority($me->get("authority_id")); +$my_authority_id = new Authority($me->get('authority_id')); $log = new Log(); -if (isset($id) && ! empty($id)) { - $log->setId($id); +if (! empty($log_id)) { + $log->setId($log_id); if (! $log->init()) { - $_SESSION["error"] = "Erreur lors de l'initialisation de l'entrée de journal."; - header("Location: " . Helpers::getLink("/common/logs_view.php")); + $_SESSION['error'] = "Erreur lors de l'initialisation de l'entrée de journal."; + header('Location: ' . Helpers::getLink('/common/logs_view.php')); exit(); } } else { - $_SESSION["error"] = "Pas d'identifiant de log spécifié."; - header("Location: " . Helpers::getLink("/common/logs_view.php")); + $_SESSION['error'] = "Pas d'identifiant de log spécifié."; + header('Location: ' . Helpers::getLink('/common/logs_view.php')); exit(); } // Vérification des permissions sur l'entrée de journal if (! $log->canView($me)) { - $_SESSION["error"] = "Accès refusé."; - header("Location: " . Helpers::getLink("/common/logs_view.php")); + $_SESSION['error'] = 'Accès refusé.'; + header('Location: ' . Helpers::getLink('/common/logs_view.php')); exit(); } if (! $log->sendArchive()) { - $_SESSION["error"] = "Erreur de récupération de l'entrée de log et de son horodatage.<br />" . $log->getErrorMsg(); - header("Location: " . Helpers::getLink("/common/logs_view.php")); + $_SESSION['error'] = "Erreur de récupération de l'entrée de log et de son horodatage.<br />" . $log->getErrorMsg(); + header('Location: ' . Helpers::getLink('/common/logs_view.php')); } exit();