feat: add mask_stdout to redact secrets from sandboxed process output#6
feat: add mask_stdout to redact secrets from sandboxed process output#6machado144 wants to merge 4 commits intomainfrom
Conversation
Intercepts stdout/stderr from sandboxed processes at the Go layer and redacts secrets before they reach the terminal — a defense-in-depth layer on top of existing kernel-level sandbox protections. - MaskingWriter: line-buffered io.Writer with regex-based redaction - 5 built-in presets: openai, anthropic, aws_key, github, bearer - Custom patterns with show_prefix (partial reveal) and case_insensitive options - All presets + a generic key=value pattern enabled by default in aigate init - Banner shows active presets/patterns at sandbox startup - Zero behavioral change when mask_stdout is absent from config
… with releaseforge
StructLint — All checks passed71 rules validated against
|
There was a problem hiding this comment.
Core Changes
- Implemented
mask_stdoutfunctionality to redact sensitive information from sandboxed process output (stdout/stderr). - Introduced a
MaskingWriterservice that uses configurable presets and custom regex patterns for redaction. - Integrated output masking into the sandbox execution flow and updated configuration management to support
mask_stdout. - Enhanced CI/CD with PR title validation, AI code review, struct linting, and improved release automation using
releaseforge.
Concerns
None. The changes are additive, well-tested, and enhance the security posture of the application without introducing regressions or critical issues.
Verdict
Approve: The changes are well-implemented, thoroughly tested, and significantly improve the security and maintainability of the project. All internal breaking changes to interfaces have been correctly propagated and handled.
Code review performed by GEMINI - gemini-2.5-flash.
There was a problem hiding this comment.
Core Changes
- Implemented
mask_stdoutfeature to redact secrets from sandboxed process output using configurable presets and custom regex patterns. - Updated
PlatformandExecutorinterfaces to support customio.Writerfor stdout/stderr, allowing theMaskingWriterto intercept and redact output. - Enhanced CI/CD workflows with PR title validation, AI code review, struct linting, and updated release automation to use
releaseforgefor version bumping and release notes.
Concerns
None. The changes are well-implemented, and the new output masking feature adds a valuable defense-in-depth layer without introducing regressions or critical issues.
Verdict
Approve: The changes introduce a significant security enhancement and improve development workflows. All modifications appear correct and robust.
Code review performed by GEMINI - gemini-2.5-flash.
There was a problem hiding this comment.
Core Changes
- Implemented
mask_stdoutfunctionality to redact sensitive information from sandboxed process output using configurable presets and custom regex patterns. - Updated CI/CD workflows (
pr.yml,release.yml,test.yml) to include new linting tools (structlint,golangci-lint) and enforce conventional commit message formats for PR titles and commit messages. - Modified the
PlatformandExecutorinterfaces to support passingio.Writerforstdoutandstderr, allowing theMaskingWriterto intercept and redact output.
Verdict
Approve: The changes introduce a valuable security feature (output masking) and improve code quality through enhanced linting and commit standards. All breaking interface changes are handled internally, and the new functionality is well-tested. The release.yml input change is a functional update with clear intent.
Code review performed by GEMINI - gemini-2.5-flash.
Summary
mask_stdoutconfig block that intercepts stdout/stderr from sandboxed processes and redacts secrets before they reach the terminalaigate initWhat's included
New:
services/masker.goMaskingWriter— line-bufferedio.Writerthat applies regex rules before forwarding to the real writer\n)Flush()handles the last line if it has no trailing newlineBuilt-in presets
openaisk-.../sk-proj-...sk-***anthropicsk-ant-...sk-ant-***aws_keyAKIA...AKIA***githubghp_,gho_,ghu_,ghs_,ghr_ghp_***bearerBearer <token>Bearer ***Custom pattern options
Default config (
aigate init) now ships with all 5 presets + one example pattern for generickey=valueassignments (api_key=,secret:,password=, etc.)Safety
mask_stdoutis absent from config,buildOutputWritersreturnsos.Stdout/os.Stderr— identical to previous behaviourRunPassthroughnow delegates toRunPassthroughWith(os.Stdout, os.Stderr, ...)— same resultRunSandboxed,Executor) are mechanical — all implementations and test mocks updatedgo vet+ race detector both passTest plan
go test ./... -count=1 -racepassesaigate initgenerates config withmask_stdoutpresets + example patternaigate run -- envwith an OpenAI key in env does not print the raw key[aigate] mask_stdout: ...line appears in startup banner when configured