Add sanitized provisioning diagnostics
This commit is contained in:
+9
-1
@@ -50,6 +50,12 @@ function dashboard_status(string $status): string {
|
||||
default => ucfirst($status),
|
||||
};
|
||||
}
|
||||
function dashboard_debug_detail(Throwable $exception): string {
|
||||
$detail = trim($exception->getMessage());
|
||||
$detail = preg_replace('/(?:X-API-Key|Authorization|Bearer)\s*:\s*[^\s,;]+/i', '[credential redacted]', $detail) ?? $detail;
|
||||
$detail = preg_replace('/("?(?:token|password|api[_-]?key|secret)"?\s*[:=]\s*)[^,;\s}]+/i', '$1[redacted]', $detail) ?? $detail;
|
||||
return substr($detail !== '' ? $detail : 'Keine technische Fehlerbeschreibung vorhanden.', 0, 800);
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (!pnpaas_valid_csrf((string)($_POST['csrf_token'] ?? ''))) {
|
||||
@@ -164,8 +170,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (in_array(($action ?? ''), ['approve_instance', 'instance_action'], true) && isset($instanceId)) {
|
||||
try { pnpaas_db()->prepare('UPDATE instances SET status = "error", error_message = :error WHERE id = :id')->execute(['error' => 'Die Bereitstellung oder Aktion konnte nicht abgeschlossen werden.', 'id' => $instanceId]); } catch (Throwable) {}
|
||||
}
|
||||
error_log('PnPaaS instance action error: ' . $exception->getMessage());
|
||||
$debugDetail = dashboard_debug_detail($exception);
|
||||
error_log('PnPaaS instance action error: ' . $debugDetail);
|
||||
$error = 'Die angeforderte Aktion konnte nicht ausgeführt werden. Bitte versuchen Sie es erneut.';
|
||||
if ($isAdmin) $error .= ' Technischer Hinweis: ' . $debugDetail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user