Skip to content

test(secrets): Cover the key-header decoy in the miss text of a run with the token - #51

Merged
dcramer merged 1 commit into
mainfrom
test/main-thread-miss-rule
Nov 5, 2026
Merged

dcramer merged 1 commit into
mainfrom
test/main-thread-miss-rule

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Adds one test to packages/service/tests/redaction.test.ts. No code changes.

#47 made the main-thread miss path for write-token runs (recorder.ts, redactedText) pass the rule to secrets.redactRequest. No test failed when that rule was dropped, so nothing guarded it.

The test: "does not let a key header take the place of a form field in the text of a miss"

  1. An auto run with the write token records note=y&password=hunter2-SECRET-xyz with x-trace: b. Its sample keeps its text.
  2. A replay run with the token sends note=x&password=hunter2-SECRET-xyz with x-trace: a&password=<<redacted>>. The rule has values: {v: "x&"} and keyHeaders: ["x-trace"].
  3. The request must be missed with no change, and neither the recording nor the request sample may contain SECRET. The recorder sets miss.request only when the miss has a change, so this also keeps the password out of the miss.request span attribute.

Checked on Node 24.22.2: pnpm check and pnpm test:coverage pass, with 107 tests. When redactRequest(keyed.text, request, rule) changes to redactRequest(keyed.text, request, {}), the test fails with expected { …(2) } to be undefined: the miss gets a change, and its text keeps the password.

via @dcramer.

--

View Session [Sentry]

…ith the token

A run with the write token redacts the text of a miss on the main
thread. That path must pass the rule, so only the body is checked. With
`{}` in place of the rule, the key header stands in for the password
field, and the miss gets a change with the password.
@dcramer
dcramer marked this pull request as ready for review November 5, 2026 16:50
@dcramer
dcramer merged commit 5cff326 into main Nov 5, 2026
16 checks passed
@dcramer
dcramer deleted the test/main-thread-miss-rule branch November 5, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant