diff --git a/server/src/__tests__/feedback-redaction.test.ts b/server/src/__tests__/feedback-redaction.test.ts index 868cbb399a7..85c8aa6059c 100644 --- a/server/src/__tests__/feedback-redaction.test.ts +++ b/server/src/__tests__/feedback-redaction.test.ts @@ -81,6 +81,18 @@ describe("feedback redaction", () => { expect(output).toContain("[REDACTED_PHONE]"); }); + it("keeps run ids and dates intact while still redacting a phone number beside them", () => { + const state = createFeedbackRedactionState(); + const runId = "9224d1c8-1dbf-4314-9924-e16fcf3ad1fa"; + const allDigitId = "12345678-1234-4234-9234-123456789012"; + const input = `Run ${runId} and ${allDigitId} on 2026-11-12 at 2026-11-12 00:43:37; call +1 (415) 555-1234.`; + + expect(sanitizeFeedbackText(input, state, "body", 10_000)).toBe( + `Run ${runId} and ${allDigitId} on 2026-11-12 at 2026-11-12 00:43:37; call [REDACTED_PHONE].`, + ); + expect(finalizeFeedbackRedactionSummary(state).counts).toEqual({ phone: 1 }); + }); + it("preserves nested metadata while masking structured secrets", () => { const state = createFeedbackRedactionState(); const input = { diff --git a/server/src/services/feedback-redaction.ts b/server/src/services/feedback-redaction.ts index e57341407d5..43db38d6eac 100644 --- a/server/src/services/feedback-redaction.ts +++ b/server/src/services/feedback-redaction.ts @@ -17,8 +17,12 @@ type RedactionPattern = { kind: string; regex: RegExp; replacement: PatternReplacement; + preservesIdentifiers?: boolean; }; +const PUBLIC_IDENTIFIER_RE = + /\b(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?)\b/gi; + const SECRET_ASSIGNMENT_RE = /\b(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)\s*[:=]\s*([^\s,;]+)/gi; @@ -67,6 +71,7 @@ const FREE_TEXT_PATTERNS: RedactionPattern[] = [ kind: "phone", regex: /(? { const replacement = typeof pattern.replacement === "function"