fix(analyzer): detect full environment reads via AST - #332
Draft
mohgupta-ship-it wants to merge 1 commit into
Draft
fix(analyzer): detect full environment reads via AST#332mohgupta-ship-it wants to merge 1 commit into
mohgupta-ship-it wants to merge 1 commit into
Conversation
Signed-off-by: Mohit Gupta <mohgupta@nvidia.com>
mohgupta-ship-it
force-pushed
the
codex/fix-issue-329-env-ast
branch
from
August 2, 2026 09:27
73baca8 to
641614e
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.
Summary
Replaces the spelling-sensitive Python E2 full-environment checks with AST-based detection.
copy(),dict(os.environ), dict unpacking,.items(), direct iteration, andcopy.copy()variants.os/environimport aliases and remains insensitive to formatting such asos . environ . copy ().os.environto a child process as environment harvesting.Root cause
E2 matched literal text such as
os.environ.copy(); semantically equivalent syntax and import aliases bypassed the rule. This AST-based implementation covers the full reproduction set from the issue without broad argument-matching false positives.Validation
uv run --no-sync python -m pytest tests/nodes/analyzers/test_static_patterns.py tests/unit/test_patterns.py -quv run --with hatchling --no-sync python -m pytest -qq --disable-warnings -m "not integration and not provider" tests/uv run --no-sync make lintuv run --no-sync make format-checkThis is a broader AST-based alternative to the regex-only coverage in #331.
Fixes #329
Created by Codex on behalf of Mohit.