Repository navigation
fix(python/sast): Fix module variable reassignment contamination and var: placeholder leaking - #515
Merged
Conversation
…var: placeholder leaking (#BUG-03) Change FunctionScope.Variables from map[string]*VariableBinding to map[string][]*VariableBinding to support per-assignment tracking. This fixes two issues: - Issue A: Reassigned module variables (e.g., val="" then val=5) now return the correct type for each assignment line instead of always returning the last assignment's type. - Issue B: Functions returning a named variable (return result) no longer leak var:result placeholders to MCP output. A new ResolveReturnVariableReferences() pipeline step resolves these to concrete types, with a safety filter in GetModuleVariableType(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Code Pathfinder Security ScanNo security issues detected.
Powered by Code Pathfinder |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #515 +/- ##
==========================================
- Coverage 82.54% 82.54% -0.01%
==========================================
Files 122 122
Lines 14059 14097 +38
==========================================
+ Hits 11605 11636 +31
- Misses 2012 2016 +4
- Partials 442 445 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
FunctionScope.Variablesfrommap[string]*VariableBindingtomap[string][]*VariableBindingfor per-assignment tracking, fixing reassignment contamination where reassigned module variables (val = ""; val = 5) always returned the last assignment's typeGetVariableAtLine(varName, line)method to retrieve the binding at a specific source line, and updateGetModuleVariableType()to accept aline uint32parameter for line-aware lookupsResolveReturnVariableReferences()pipeline step that resolvesvar:varNameplaceholders in return types by looking up the variable's concrete type in the function's scope — fixesreturn resultpatterns leakingvar:resultto MCP outputvar:prefix filter inGetModuleVariableType()as a safety net alongside the existingcall:filterBefore
After
Test plan
TestGetModuleVariableType_Reassignment,TestGetModuleVariableType_VarPlaceholder,TestResolveReturnVariableReferences,TestResolveReturnVariableReferences_UnresolvedVariablestypeVariablestypeModuleVariableProviderinterface updated withline uint32parameter; mock updatedgradle buildGopassesgo test ./...)🤖 Generated with Claude Code