Repository navigation
fix: redact stored credentials at export (#74) - #257
Conversation
memory_export serialised content and issue verbatim, so rows written before the write-side redaction leaked credentials into every exported JSONL. Redact the value being serialised via redactSecrets; the stored row is untouched, so export stays a read path. Update the two write-caps lines that pinned the verbatim-export defect (maintainer ruling, #74): the row is still asserted present via scope, the credential is now asserted replaced by [redacted].
There was a problem hiding this comment.
APPROVE — head 81da2b341a94642ee8176ef98a9b6d3b1e4c0841, merge-base bf7f6d2. Closes footer present (#74, authored by abogartz — trusted human).
Contract (#74 slice 1, verbatim criteria, each with independent evidence measured on this tree):
- "A new test file under
test/fails at the merge-base and passes on the branch. Report both pass/fail counts." — Measured:test/export-redaction.test.tsat merge-basebf7f6d2→ 3 pass / 2 fail, the two failures are the content- and issue-redaction tests (not.toContain(SK_TOKEN), e.g. :62) failing because base serialises the raw token; on branch → 5 pass / 0 fail. Fixed side clean, broken side fails for the stated reason. - "A row whose
contentholds ask--prefixed token exports JSONL that contains[redacted]and does not contain the token." — test/export-redaction.test.ts:51-57 asserts both directions; green. Code:content: redactSecrets(m.content)at src/portable/export.ts:159. - "Same guarantee for the
issuefield, which is free text." — test/export-redaction.test.ts:59-65; green. Code:issue: m.issue === undefined ? m.issue : redactSecrets(m.issue)at src/portable/export.ts:163 (undefined preserved, no key invention). - "A row with no credential-shaped text serialises byte-identically to today's output. No reformatting, no key reordering, no whitespace change." — test/export-redaction.test.ts:67-89 pins the full line against
JSON.stringifywith unchanged key order; green. - "The header line and the returned
countare unchanged." — test/export-redaction.test.ts:91-101 asserts_export,version,count: 2,exportedAt,res.count === 2;EXPORT_HEADER/EXPORT_VERSIONuntouched in diff; green. - "Export stays a read path: after exporting, re-read the store and assert the original row content is untouched." — test/export-redaction.test.ts:103-109 re-reads with
loadAll()and asserts the raw token remains in the store; green. Corroborated by write-caps.test.ts:159 (memory_recallstill returns the raw legacy secret). - "
bun run typecheck,bun run lintandbun run testall pass." — Measured (macOS, Bun 1.4.4): typecheck 0 errors; lint 498 warnings = baseline, 0 errors; test 865 pass / 14 skip / 0 fail.bun run test:e2e(src/ changed): 30 pass / 0 fail. CI lint / test / test-windows / smoke all pass. - "
git diff --name-onlyagainst the base listssrc/portable/export.ts, the one new test file, andtest/write-caps.test.ts— nothing else." — Measured: exactly those three files. Change confined to the two lines (currently 165-166) … still assert the row is present viascope, and must now assert the credential is replaced by[redacted]." — One line changed (166):toContain(legacySecret)→toContain("[redacted] stays addressable")(row content islegacy row containing <secret> stays addressable, so this asserts replacement in place); line 165toContain(scope)unchanged; no other assertion in the file changed.
Test-integrity check — new test file purely additive; write-caps change is the maintainer-ruled expectation amendment already baked into the ticket's criterion 8; no .skip, no deleted assertion, no widened tolerance.
Findings — no P0/P1. Nit (out of slice, no action): credential-shaped scope values still export verbatim (src/portable/export.ts:158; write-caps.test.ts:165 pins this); slice 1 deliberately limits the surface to content and issue, so this belongs to a follow-up on #74, not this PR.
Human merges.
|
🎉 This PR is included in version 0.15.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #74 (slice 1: redact at export).
What
memory_exportserialisedcontentandissueverbatim, so rows written before the write-side redaction (#67) leaked stored credentials into every exported JSONL. This appliesredactSecrets(existing helper,src/store/secrets.ts) to the value being serialised — never to the row, so export stays a read path.Acceptance criteria and evidence
test/export-redaction.test.ts: at merge-basebf7f6d23 pass / 2 fail (the content and issue redaction tests fail: the export contains the rawsk-token); on this branch 5 pass / 0 fail.contentwithsk-token — test asserts export JSONL does not contain the token and contains"content":"deploy note [redacted] kept for rotation".issuefield, same guarantee — test asserts export does not contain the token and contains"issue":"token in free text [redacted]".JSON.stringifywith the unchanged key order; no reformatting, no key reordering, no whitespace change.countunchanged — test asserts_export,version,count: 2,exportedAtpresent, andres.count === 2;EXPORT_HEADER/EXPORT_VERSIONuntouched.loadAll()after export and asserts the stored row still contains the raw token.bun run typecheckpass;bun run lintpass (498 pre-existing warnings, 0 errors);bun run test865 pass / 14 skip / 0 fail;bun run test:e2e(src/ changed) 30 pass / 0 fail.git diff --name-onlyagainst base lists exactlysrc/portable/export.ts,test/export-redaction.test.ts,test/write-caps.test.ts. Thewrite-capschange is the single line 166: row presence is still asserted viascope(line 165, unchanged), and the credential assertion now expects[redacted]in place. No other assertion in that file changed.Requirement taken from a comment (not the issue body)
fix:blockedcleared. Proceed."): "test/write-caps.test.tsis now in scope, limited to the two lines that assert a credential survives export. … Keep the purpose, change the expectation: assert the row is still present viascope, assert the credential is replaced by[redacted]. No other assertion in that file may change."Deliberately not changed
Day files, snapshots,
memory_undo,memory_import,writeExport's flags or mode,EXPORT_HEADER,EXPORT_VERSION, and any pattern insrc/store/secrets.ts— all out of scope per the ticket. The scrub tool, snapshot handling, and README policy statement remain open follow-ups on #74.