Skip to content

fix: redact stored credentials at export (#74) - #257

Merged
abogartz merged 3 commits into
mainfrom
fix-issue-74-20261102T200500
Nov 2, 2026
Merged

abogartz merged 3 commits into
mainfrom
fix-issue-74-20261102T200500

Conversation

@ocsi-fixer

@ocsi-fixer ocsi-fixer Bot commented Nov 2, 2026

Copy link
Copy Markdown

Closes #74 (slice 1: redact at export).

What

memory_export serialised content and issue verbatim, so rows written before the write-side redaction (#67) leaked stored credentials into every exported JSONL. This applies redactSecrets (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

  1. New test file fails at merge-base, passes on branch — test/export-redaction.test.ts: at merge-base bf7f6d2 3 pass / 2 fail (the content and issue redaction tests fail: the export contains the raw sk- token); on this branch 5 pass / 0 fail.
  2. content with sk- token — test asserts export JSONL does not contain the token and contains "content":"deploy note [redacted] kept for rotation".
  3. issue field, same guarantee — test asserts export does not contain the token and contains "issue":"token in free text [redacted]".
  4. Clean row byte-identical — test pins the full serialised line against JSON.stringify with the unchanged key order; no reformatting, no key reordering, no whitespace change.
  5. Header and count unchanged — test asserts _export, version, count: 2, exportedAt present, and res.count === 2; EXPORT_HEADER/EXPORT_VERSION untouched.
  6. Export stays a read path — test re-reads the store with loadAll() after export and asserts the stored row still contains the raw token.
  7. Proof commands, measured on this branch: bun run typecheck pass; bun run lint pass (498 pre-existing warnings, 0 errors); bun run test 865 pass / 14 skip / 0 fail; bun run test:e2e (src/ changed) 30 pass / 0 fail.
  8. Diff scope — git diff --name-only against base lists exactly src/portable/export.ts, test/export-redaction.test.ts, test/write-caps.test.ts. The write-caps change is the single line 166: row presence is still asserted via scope (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)

  • From abogartz, 2026-11-02 ("Ruling: criterion 8 amended, fix:blocked cleared. Proceed."): "test/write-caps.test.ts is 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 via scope, 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 in src/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.

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].
@abogartz abogartz added the review:requested Human-admitted for autonomous review by ocsi-reviewer label Nov 2, 2026

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

  1. "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.ts at merge-base bf7f6d2 → 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.
  2. "A row whose content holds a sk--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.
  3. "Same guarantee for the issue field, 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).
  4. "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.stringify with unchanged key order; green.
  5. "The header line and the returned count are unchanged." — test/export-redaction.test.ts:91-101 asserts _export, version, count: 2, exportedAt, res.count === 2; EXPORT_HEADER/EXPORT_VERSION untouched in diff; green.
  6. "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_recall still returns the raw legacy secret).
  7. "bun run typecheck, bun run lint and bun run test all 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.
  8. "git diff --name-only against the base lists src/portable/export.ts, the one new test file, and test/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 via scope, and must now assert the credential is replaced by [redacted]." — One line changed (166): toContain(legacySecret) → toContain("[redacted] stays addressable") (row content is legacy row containing <secret> stays addressable, so this asserts replacement in place); line 165 toContain(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.

@abogartz
abogartz merged commit ed81994 into main Nov 2, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ocsi-triager ocsi-triager Bot added test-integrity Test/eval integrity: mutation sweep, invariant pinning, assertion strength and removed test-integrity Test/eval integrity: mutation sweep, invariant pinning, assertion strength labels Nov 2, 2026
@abogartz
abogartz deleted the fix-issue-74-20261102T200500 branch November 19, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released review:requested Human-admitted for autonomous review by ocsi-reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secrets already in the store are never scrubbed, and memory_export writes them verbatim

1 participant