Skip to content

feat(redact): add DEFAULT_REDACT_PATTERNS and apply them on every record run#13

Merged
protosphinx merged 1 commit intomainfrom
bot/default-redact-patterns
May 5, 2026
Merged

feat(redact): add DEFAULT_REDACT_PATTERNS and apply them on every record run#13
protosphinx merged 1 commit intomainfrom
bot/default-redact-patterns

Conversation

@protosphinx
Copy link
Copy Markdown
Member

Why

The README and GOALS.md document that record mode always strips a set
of well-known credential keys (authorization headers, *_token, *_key,
*_secret) by default. However, no such constant existed in redact.ts
and record() applied zero patterns unless the caller explicitly passed
redact: [...]. This closes that spec gap: recording now redacts common
credentials automatically, matching the documented "belt and suspenders"
promise without any caller change required.

What

  • src/redact.ts: export DEFAULT_REDACT_PATTERNS constant containing
    ["authorization", "*_token", "*_key", "*_secret"].
  • src/record.ts: merge DEFAULT_REDACT_PATTERNS with caller-supplied
    opts.redact patterns so defaults are always active. Callers can still
    extend the list; they can no longer accidentally opt out of the basics.
  • Simplified the two redact.length > 0 guards in the passthrough
    helpers (now always true, so the ternary was dead weight).
  • test/redact.test.ts: 11 new tests covering the array walk path, the
    exported constant's contents, and each of the four default patterns in
    isolation and in combination with nested structures.

Tests

  • npm run lint && npm run build && npm test all pass locally.
  • 91 tests total (was 80), 11 added in this PR.
  • New tests cover: array traversal, each default pattern by name, each
    default pattern applied via redactDeep, nested credential key
    redaction, and non-sensitive keys left unchanged.

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (added + removed): 86 lines
  • no public-API surface change (src/index.ts not touched)
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended (11 new tests in test/redact.test.ts)

Generated by Claude Code

…ord run

The README documents that recording always strips authorization headers,
*_token, *_key, and *_secret keys by default, but no such constant existed
in redact.ts and record() applied zero patterns unless the caller passed
redact: [...]. This closes the gap: export DEFAULT_REDACT_PATTERNS from
redact.ts, merge it into the effective pattern list in record(), and add
11 tests covering each pattern and common nested credential shapes.
@protosphinx protosphinx added the automated Opened by the daily bot label May 5, 2026 — with Claude
@protosphinx protosphinx merged commit 66c09e6 into main May 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant