fix(logging): redact environment values from logged CLI commands#175
Open
ryuhaneul wants to merge 3 commits into
Open
fix(logging): redact environment values from logged CLI commands#175ryuhaneul wants to merge 3 commits into
ryuhaneul wants to merge 3 commits into
Conversation
ryuhaneul
force-pushed
the
fix/redact-secrets-in-cmd-logs
branch
from
July 13, 2026 01:32
9ee7d7e to
a544a43
Compare
ryuhaneul
marked this pull request as draft
July 13, 2026 02:56
ryuhaneul
marked this pull request as ready for review
July 15, 2026 07:14
ryuhaneul
force-pushed
the
fix/redact-secrets-in-cmd-logs
branch
from
July 15, 2026 08:15
a91422d to
afbb507
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every CLI invocation logs the full command line, including the
-e KEY=VALUEenvironment flags passed to the sandbox container. Since~/.ductor/.envis injected into every CLI subprocess, every secret in it is written to the log in plaintext:cli/claude_provider.py—CLI stream cmd/CLI cmd(INFO)cli/codex_provider.py—Codex cmd(INFO)cli/gemini_provider.py—Gemini cmd(INFO)cli/antigravity_provider.py—Antigravity send(DEBUG)infra/docker.py—docker run cmd(DEBUG)The existing "safe_cmd" logic only truncates values that follow a
--flag;-e API_KEY=...is untouched, and most tokens are short enough to survive truncation anyway. Raisinglog_levelto INFO or DEBUG for debugging therefore dumps API keys, tokens and passwords intoagent.log(and its rotations).What changed
A shared helper,
cli/_log_redact.py:KEY=VALUEargument whose key looks like an environment variable (uppercase / digits / underscore):-e GITHUB_TOKEN=ghp_…→-e GITHUB_TOKEN=***.-e KEY=VALUE,-eKEY=VALUE,--env=KEY=VALUE, and bare inline assignments.DUCTOR_*(chat/topic/transport/agent/home/ports),TZ,PYTHONPATH,HOME,LANG,CONTAINER, Playwright browser path, and*_URL/*_HOST/*_PORTsettings.Applied at every command-logging site (Claude, Codex, Gemini, Antigravity, Docker). Existing truncation and prompt-substitution behavior is preserved; masking is applied first, so a masked value is never truncated into something misleading.
Example
Before:
After:
Testing
New tests cover: secret values absent from the rendered log line, key names preserved, allowlisted values preserved, command structure preserved, the inline/
-e/--env=forms, and per-providercaplogassertions that no secret reaches the log record. Full suite: no new failures vs. base;ruff,ruff format,mypyand the i18n check pass.Only fake tokens are used in the tests.