Repository navigation
fix(browser): keep declared scenario secrets out of redacted evidence - #1590
Conversation
A redaction marker such as [REDACTED:password] can contain the secret it replaced, and the byte replacer never scanned the marker it inserted. Cookie names, domains, paths, and storage keys were also stored raw. Choose a marker that does not contain a declared spelling, drop the result when a spelling remains, and redact storage identity fields.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: In my tests the PR fixes #1591. The secret ResultsI ran each case through
The last two rows are not caused by the PR. They are a separate gap, filed as #1608. With no secrets declared, main and the PR gave the same output once I set aside ids, timings and event order.
Main has one failing test of its own, Not run
Thanks, Adolanium, for the exact strings in the issue and for tests that fail on main. More cases, with short secretsEach row is main
The PR's choice to use The id Random-input checkI called
Emptying is the PR's fallback when no marker is safe. This alphabet is built to cause clashes, so real pages will hit it far less often. Commands# build each tree (Node 24.18.0), from git archive of the commit
git archive <sha> | tar -x -C <dir> && cd <dir> && npm ci && npm run build
# one run per case, secrets passed as environment variables
REA_SEC_<ID>='<made-up value>' node scripts/rea.mjs capture-browser-scenario scenario.json --json
# connect mode: a fresh headless Chromium and a new profile for every run
chromium-browser --headless=new --remote-debugging-port=9471 \
--user-data-dir=<new dir> --password-store=basic about:blank
# unit tests, on Node 22, 24 and 26
node scripts/run-development-tests.mjs focused \
src/browser/PlaywrightScenarioBrowser.test.ts \
src/browser/PlaywrightBrowserScenarioProvider.test.ts \
src/browser/PlaywrightExecutionBoundary.test.ts \
src/browser/PlaywrightScenarioArtifacts.test.ts \
src/browser/PlaywrightScenarioEvents.test.ts \
src/browser/BrowserScenario.test.ts
# on a git clone of the PR head
npm run check:fastEvery run used Raw output: where each made-up secret was found
The #1591 strings, called straight on the built functions: Test pagesOne page and one script per case, from a local server on The plain case used values like Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Welcome to REA, @Adolanium! Thanks for handling declared secrets that appear inside redaction markers, cookie names, and storage keys. Those are easy places to miss when redacting captured evidence, and the regression cases make the behavior clear. Squash-merged. |
Summary
Fixes #1591.
Declared scenario secrets could survive redaction when the marker
[REDACTED:<id>]contained the secret, and storage identity fields were copied unchanged.Problem and expected behavior
docs/browser-scenario-contract.mdsays declared secret values are removed from observed content, including a secret declared only so matching observations are removed.redactExplicitTextalready refuses a replacement that still contains a declared literal.BrowserScenarioSecrets.redactalways inserted[REDACTED:<secret_id>]. For secret idpasswordand valuepass, the resultseen [REDACTED:password] in the pagestill containspass.redactBytessearched only the original buffer, so a longer secret's marker could reintroduce a shorter secret. Cookiename,domain, andpath, andlocalStorage/sessionStoragekeys, were stored without redaction. Header names already went throughredact.Change and scope
Text, URL, and byte replacement now pick the first of
[REDACTED:<id>],[REDACTED],…, and an empty string that does not contain a declared spelling. If a spelling remains, text becomes empty, a URL is returned as redacted with an empty URL, and bytes become an empty buffer. Storage capture redacts cookie names, domains, paths, and storage keys through the same text redactor.Ordinary long secrets still use
[REDACTED:<id>]. Longest-first replacement is unchanged.Contract and boundary impact
docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
BrowserScenario.test.tscovers thepass/passwordmarker and a byte body whose longer marker would have containedpass.PlaywrightScenarioArtifacts.test.tscovers a secret used as a cookie name and a storage key.passremained inside[REDACTED:password], and a body containing onlysession-secret-valuegainedpassfrom[REDACTED:password].[REDACTED]when the id marker would contain a declared secret. Storage names that equal a secret are redacted.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/browser/BrowserScenario.test.ts src/browser/PlaywrightScenarioArtifacts.test.ts— 17 tests passed.npx tsc --noEmit --pretty false— no errors.npx oxlinton the four edited files — 0 errors.Compatibility, safety, and release
[REDACTED:<id>]marker still get that marker when it does not contain a declared spelling. A short secret that is a substring of its id now produces[REDACTED]instead of a marker that still contains the secret.Review checklist
type(scope): outcome.