fix: add safe clock diagnostics to debug reports

This commit is contained in:
2026-08-24 09:53:16 +03:30
parent 656fc907a9
commit 322f484144
6 changed files with 282 additions and 24 deletions
+72 -13
View File
@@ -8,24 +8,83 @@
body { margin: 2rem; color: #1d2327; background: #f0f0f1; font: 14px/1.5 monospace; }
main { max-width: 1100px; margin: auto; padding: 2rem; background: #fff; border-left: 4px solid #d63638; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
h1 { margin-top: 0; color: #d63638; font: 24px/1.3 sans-serif; }
dt { margin-top: 1rem; font-weight: 700; }
dd { margin: .25rem 0 0; overflow-wrap: anywhere; }
pre { overflow: auto; padding: 1rem; color: #f0f0f1; background: #1d2327; white-space: pre-wrap; }
h2 { margin-top: 2rem; font: 20px/1.3 sans-serif; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem; border: 1px solid #c3c4c7; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th { width: 220px; background: #f6f7f7; }
pre, textarea { box-sizing: border-box; width: 100%; padding: 1rem; color: #f0f0f1; background: #1d2327; white-space: pre-wrap; }
textarea { min-height: 240px; resize: vertical; }
button { padding: .55rem 1rem; border: 1px solid #2271b1; border-radius: 3px; color: #fff; background: #2271b1; cursor: pointer; }
#copy-status { margin-left: .75rem; font-family: sans-serif; }
.privacy-note { padding: .75rem; border-left: 4px solid #72aee6; background: #f0f6fc; font-family: sans-serif; }
</style>
</head>
<body>
<main>
<h1>Mahak Authentication Error</h1>
<dl>
<dt>Exception</dt>
<dd><?= esc_html(get_class($exception)) ?></dd>
<dt>Message</dt>
<dd><?= esc_html($exception->getMessage()) ?></dd>
<dt>Location</dt>
<dd><?= esc_html($exception->getFile().':'.$exception->getLine()) ?></dd>
</dl>
<h2>Stack trace</h2>
<pre><?= esc_html($exception->getTraceAsString()) ?></pre>
<h2>Exception</h2>
<table>
<?php foreach ($report['exception'] as $label => $value): ?>
<tr><th><?= esc_html($label) ?></th><td><?= esc_html($value) ?></td></tr>
<?php endforeach; ?>
</table>
<h2>WordPress server diagnostics</h2>
<table>
<?php foreach ($report['server'] as $label => $value): ?>
<tr><th><?= esc_html($label) ?></th><td><?= esc_html($value) ?></td></tr>
<?php endforeach; ?>
</table>
<h2>JWT timing claims</h2>
<?php if ($report['jwt_timestamps'] === []): ?>
<p>No readable JWT timing claims were available.</p>
<?php else: ?>
<table>
<?php foreach ($report['jwt_timestamps'] as $label => $value): ?>
<tr><th><?= esc_html($label) ?></th><td><?= esc_html($value) ?></td></tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<h2>Sanitized stack trace</h2>
<pre><?= esc_html($report['trace']) ?></pre>
<p class="privacy-note">JWT contents, request parameters, and function arguments are intentionally omitted.</p>
<h2>Copyable report</h2>
<p><button type="button" id="copy-markdown">Copy Markdown</button><span id="copy-status" role="status"></span></p>
<textarea id="debug-markdown" readonly><?= esc_textarea($report['markdown']) ?></textarea>
</main>
<script>
(function () {
var button = document.getElementById('copy-markdown');
var report = document.getElementById('debug-markdown');
var status = document.getElementById('copy-status');
button.addEventListener('click', function () {
var copied = function () { status.textContent = 'Copied.'; };
var failed = function () {
report.focus();
report.select();
status.textContent = 'Select the report and copy it manually.';
};
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(report.value).then(copied, failed);
return;
}
report.focus();
report.select();
try {
document.execCommand('copy') ? copied() : failed();
} catch (error) {
failed();
}
});
}());
</script>
</body>
</html>