fix(export): redact secrets in-place instead of aborting#3383
fix(export): redact secrets in-place instead of aborting#3383la14-1 merged 2 commits intoOpenRouterTeam:mainfrom
Conversation
Before: any staged file matching the secret regex caused the export
to fail with `{"ok":false,"error":"Possible secrets detected..."}`,
forcing the user to SSH in and clean things up by hand.
After: matched strings are replaced with `***REDACTED-BY-SPAWN-EXPORT***`
via sed -i -E, the file is re-staged, and the export proceeds. The list
of redacted files is included in the success result and surfaced as a
warning on the host CLI:
✓ Exported to https://github.com/alice/my-vm
⚠ Redacted potential secrets in 1 file:
- project/test/brain-sync.test.ts
The regex is unchanged. The redact placeholder is intentionally loud so
a casual reader of the published repo can tell that something was
scrubbed and isn't just blank.
Bumps CLI 1.0.33 -> 1.0.34.
Previously the VM would silently redact any staged files matching the secret regex and push the repo — meaning a regex miss (OpenRouterTeam#3381 tracks broadening) would publish a real secret without the user ever seeing the file list. That's a fail-open posture on a tool that can push to public GitHub. New flow: - buildExportScript takes allowRedact: boolean. - First pass (allowRedact=false): VM stages, runs the secret scan, and on hits writes a needs_confirmation result (hits=[...]) and exits 0 before any commit or push. No hits → commit + push as before. - Host reads the result. If needs_confirmation: print the file list, explain that the regex has known gaps, and ask "Redact these N files and continue pushing?" (initialValue false). Decline → exit 0, no push. Approve → re-run the script with allowRedact=true, which now actually does the sed + re-stage + commit + push. Other changes: - ResultSchema gains the needs_confirmation variant. - cmdExport factors the runServer + downloadFile + parse cycle into runPassAndParseResult so the two-pass orchestration is readable. - Tests: 4 new cases cover the gate scripting (ALLOW_REDACT=0 writes needs_confirmation and exits 0, ALLOW_REDACT=1 redacts) and the end-to-end host flow (approve → two passes with ALLOW_REDACT 0→1; decline → one pass, exit 0; no-secrets happy path → one pass, no confirm). 38/38 export tests, 2176/0 fail overall. - CLI 1.0.34 → 1.0.35.
|
Pushed a gate in commit 855a89e to turn the silent redact-and-push into a two-pass flow: First pass ( Host: reads the result, prints the file list, notes the regex has known gaps (#3381), and asks:
No-hits path is unchanged: single pass, single push. Diff
Verification
Ready for another look / merge. |
la14-1
left a comment
There was a problem hiding this comment.
Gate wired up in 855a89e. First pass scans + pauses on hits; host prompts with the file list; only on approval does the redact+push run. Tests cover all four flows (approve / decline / no-secrets / script variants). All CI green. Approving.
Summary
Before: matching any of the API-key regexes in a staged file killed the export — the user got a JSON error and had to SSH in and clean up by hand.
After: matched strings are replaced with `REDACTED-BY-SPAWN-EXPORT` via `sed -i -E`, the file is re-staged, and the export proceeds. The redacted file list is included in the success result and surfaced on the host CLI:
```
✓ Exported to https://github.com/alice/my-vm
⚠ Redacted potential secrets in 1 file:
```
Reproduces the user-reported failure where a test fixture (
project/test/brain-sync.test.ts) tripped the scan and the whole export bailed.Notes
Test plan
🤖 Generated with Claude Code