Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: harden fidelity diagnostic redaction per review (#11724)
[._.]/ Adam Eivy4168abc93ba7
diff --git a/scripts/lib/fidelityDiagnostic.js b/scripts/lib/fidelityDiagnostic.jsindex d2c3c5b66e..a0cac15d36 100644--- a/scripts/lib/fidelityDiagnostic.js+++ b/scripts/lib/fidelityDiagnostic.js@@ -2,10 +2,14 @@// depends on this text; it only names what failed without leaking secrets or// machine-identifying paths into terminal output that may be pasted into issues.const MAX_REASON = 200;+// Only built-in error classes are named; a custom name is untrusted text.+const KNOWN_ERROR_NAMES = new Set(['TypeError', 'RangeError', 'SyntaxError', 'ReferenceError', 'AbortError', 'TimeoutError']);const REDACTIONS = [[/\b(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]{8,}/g, '<token>'],[/\b(Bearer|Basic|token)\s+[A-Za-z0-9._~+/=-]{8,}/gi, '$1 <token>'],- [/\b([\w.-]*(?:token|secret|password|passwd|api[_-]?key|auth|cookie|credential)[\w.-]*)\s*[=:]\s*\S+/gi, '$1=<redacted>'],+ [/\b([\w.-]*(?:token|secret|password|passwd|api[_-]?key|auth|cookie|credential)[\w.-]*)\s*[=:]\s*(?:"[^"]*"|'[^']*'|\S+)/gi, '$1=<redacted>'],+ [/\b\d{1,3}(?:\.\d{1,3}){3}\b/g, '<ip>'],+ [/\b(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}\b/gi, '<ip>'],[/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g, '<email>'],[/\b[A-Za-z0-9+/_-]{32,}={0,2}/g, '<redacted>'],[/[A-Za-z]:\\[^\s'"]+/g, '<path>'],@@ -16,7 +20,8 @@ export function safeFailureReason(error) {const raw = error instanceof Error ? error.message : typeof error === 'string' ? error : '';let text = raw.replace(/[^\x20-\x7E]/g, ' ');for (const [pattern, replacement] of REDACTIONS) text = text.replace(pattern, replacement);- text = text.replace(/\s+/g, ' ').trim().slice(0, MAX_REASON);- const kind = error instanceof Error && error.name && error.name !== 'Error' ? `${error.name}: ` : '';- return text ? `${kind}${text}` : '';+ text = text.replace(/\s+/g, ' ').trim();+ if (!text) return '';+ const kind = error instanceof Error && KNOWN_ERROR_NAMES.has(error.name) ? `${error.name}: ` : '';+ return `${kind}${text}`.slice(0, MAX_REASON);}diff --git a/scripts/lib/fidelityDiagnostic.test.js b/scripts/lib/fidelityDiagnostic.test.jsindex 67cd1ab65c..353c4d4bda 100644--- a/scripts/lib/fidelityDiagnostic.test.js+++ b/scripts/lib/fidelityDiagnostic.test.js@@ -16,6 +16,8 @@ describe('safeFailureReason', () => {['long opaque value', `blob ${'Ab1'.repeat(20)}`, 'Ab1Ab1Ab1Ab1'],['posix home path', 'ENOENT /Users/alice/secret-project/receipt.json', 'alice'],['linux home path', 'cannot read /home/bob/.config/gh/hosts.yml', 'bob'],+ ['IPv4 address', 'connect ECONNREFUSED 192.0.2.10:443', '192.0.2.10'],+ ['quoted secret', 'password="alpha beta" rejected', 'beta'],['windows path', 'missing C:\\Users\\carol\\AppData\\x.json', 'carol'],])('redacts %s', (_label, message, secret) => {const reason = safeFailureReason(Error(message));@@ -23,6 +25,13 @@ describe('safeFailureReason', () => {expect(reason.length).toBeGreaterThan(0);});+ it('never echoes a custom error name and bounds the whole reason', () => {+ const custom = Object.assign(Error('boom'), { name: 'Leak /Users/alice\nsecret' });+ expect(safeFailureReason(custom)).toBe('boom');+ const long = Object.assign(new TypeError('word '.repeat(200)));+ expect(safeFailureReason(long).length).toBeLessThanOrEqual(200);+ });+it('bounds length and returns empty for non-errors', () => {expect(safeFailureReason(Error('word '.repeat(200))).length).toBeLessThanOrEqual(200);expect(safeFailureReason(undefined)).toBe('');