fix(redact): skip env-assignment redaction for os.getenv/os.environ lookups (#2852) - #2854
Closed
crazywriter1 wants to merge 2 commits into
Closed
fix(redact): skip env-assignment redaction for os.getenv/os.environ lookups (#2852)#2854crazywriter1 wants to merge 2 commits into
crazywriter1 wants to merge 2 commits into
Conversation
…ookups (NousResearch#2852) The _ENV_ASSIGN_RE pattern matched ha_token=os.getenv(...) and treated the whole RHS as a secret value, corrupting skill source code. Skip masking when the value starts with os.getenv or os.environ. Add regression tests for getenv, environ.get, bracket access, and multiline skill snippets. Fixes NousResearch#2852
1 task
Contributor
Author
|
Rebased onto main, conflict with the new code_file guard. That guard fixes #2852 only when callers pass code_file=True. The os.getenv/os.environ skip is still needed for the default path (e.g. MY_API_TOKEN=os.getenv(...) without code_file). Merged both in _redact_env. |
teknium1
added a commit
that referenced
this pull request
Jul 5, 2026
…v-skip fix(redact): don't mask programmatic env lookups in KEY=value redaction (salvage #2854)
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
'KEY=os.getenv(...)' / 'os.environ[...]' / 'process.env.X' values are variable-name references in code snippets, not leaked secrets. Masking them corrupted pasted code in prose/log contexts (issue NousResearch#2852): ha_token=os.getenv('HOMEASSISTANT_TOKEN') -> ha_token=os.get...EN'). Skip these values inside _redact_env, which covers all three passes that share the closure (_ENV_ASSIGN_RE, _CFG_DOTTED_RE, _CFG_ANCHORED_RE). Real secret values are still masked. Salvage of PR NousResearch#2852-fix NousResearch#2854 — the PR's own placement (an unconditional pass before the code_file gate) would have reintroduced the code-file false-positive class; the skip is applied inside the existing gated pass instead. Tests adapted from the PR. Co-authored-by: crazywriter1 <sampiyonyus@gmail.com>
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…redact-getenv-skip fix(redact): don't mask programmatic env lookups in KEY=value redaction (salvage NousResearch#2854)
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
'KEY=os.getenv(...)' / 'os.environ[...]' / 'process.env.X' values are variable-name references in code snippets, not leaked secrets. Masking them corrupted pasted code in prose/log contexts (issue NousResearch#2852): ha_token=os.getenv('HOMEASSISTANT_TOKEN') -> ha_token=os.get...EN'). Skip these values inside _redact_env, which covers all three passes that share the closure (_ENV_ASSIGN_RE, _CFG_DOTTED_RE, _CFG_ANCHORED_RE). Real secret values are still masked. Salvage of PR NousResearch#2852-fix NousResearch#2854 — the PR's own placement (an unconditional pass before the code_file gate) would have reintroduced the code-file false-positive class; the skip is applied inside the existing gated pass instead. Tests adapted from the PR. Co-authored-by: crazywriter1 <sampiyonyus@gmail.com>
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…redact-getenv-skip fix(redact): don't mask programmatic env lookups in KEY=value redaction (salvage NousResearch#2854)
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
'KEY=os.getenv(...)' / 'os.environ[...]' / 'process.env.X' values are variable-name references in code snippets, not leaked secrets. Masking them corrupted pasted code in prose/log contexts (issue NousResearch#2852): ha_token=os.getenv('HOMEASSISTANT_TOKEN') -> ha_token=os.get...EN'). Skip these values inside _redact_env, which covers all three passes that share the closure (_ENV_ASSIGN_RE, _CFG_DOTTED_RE, _CFG_ANCHORED_RE). Real secret values are still masked. Salvage of PR NousResearch#2852-fix NousResearch#2854 — the PR's own placement (an unconditional pass before the code_file gate) would have reintroduced the code-file false-positive class; the skip is applied inside the existing gated pass instead. Tests adapted from the PR. Co-authored-by: crazywriter1 <sampiyonyus@gmail.com>
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…redact-getenv-skip fix(redact): don't mask programmatic env lookups in KEY=value redaction (salvage NousResearch#2854)
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
'KEY=os.getenv(...)' / 'os.environ[...]' / 'process.env.X' values are variable-name references in code snippets, not leaked secrets. Masking them corrupted pasted code in prose/log contexts (issue NousResearch#2852): ha_token=os.getenv('HOMEASSISTANT_TOKEN') -> ha_token=os.get...EN'). Skip these values inside _redact_env, which covers all three passes that share the closure (_ENV_ASSIGN_RE, _CFG_DOTTED_RE, _CFG_ANCHORED_RE). Real secret values are still masked. Salvage of PR NousResearch#2852-fix NousResearch#2854 — the PR's own placement (an unconditional pass before the code_file gate) would have reintroduced the code-file false-positive class; the skip is applied inside the existing gated pass instead. Tests adapted from the PR. Co-authored-by: crazywriter1 <sampiyonyus@gmail.com>
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…redact-getenv-skip fix(redact): don't mask programmatic env lookups in KEY=value redaction (salvage NousResearch#2854)
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.
Summary
Fixes #2852 —
redact_sensitive_text()treated Python lines likeha_token=os.getenv('HOMEASSISTANT_TOKEN')as shell-style secret assignments. The RHS was passed through_mask_token(), corrupting source code (e.g.os.get...EN')).Fix
In
_redact_env, skip masking when the captured value starts withos.getenvoros.environ(programmatic env lookup, not a literal secret).Tests
TestEnvLookupPreservedintests/agent/test_redact.py(getenv, environ.get, bracket access, spaced=, multiline skill snippet, and a check that realKEY=jwt...assignments are still redacted).Test plan
pytest tests/agent/test_redact.py— 38 passed