Skip to content

Commit 33133d6

Browse files
yoffCopilot
andcommitted
Python: gate captured jumps on SSA writes
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 439edf6 commit 33133d6

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

python/ql/lib/semmle/python/dataflow/new/internal/TypeTrackingImpl.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,12 @@ module TypeTrackingInput implements Shared::TypeTrackingInput<Location> {
324324
// nodeFrom is `expr`
325325
// nodeTo is entry node for `f`
326326
exists(
327-
SsaImpl::ScopeEntryDefinition e, SsaImpl::SsaSourceVariable var, Cfg::DefinitionNode def
327+
SsaImpl::ScopeEntryDefinition e, SsaImpl::SsaSourceVariable var,
328+
SsaImpl::EssaNodeDefinition write, Cfg::DefinitionNode def
328329
|
329330
e.getSourceVariable() = var and
330-
def.getNode() = var.getVariable().getAStore()
331+
write.getSourceVariable() = var and
332+
write.getDefiningNode() = def
331333
|
332334
nodeTo.(DataFlowPublic::ScopeEntryDefinitionNode).getDefinition() = e and
333335
nodeFrom.asCfgNode() = def and

python/ql/test/library-tests/dataflow/typetracking/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ def captured_reassignment_tradeoff():
8686
value = tracked # $ tracked
8787

8888
def read_value():
89-
return value # $ tracked
89+
return value # $ MISSING: tracked
9090

91-
before_reassignment = read_value() # $ tracked
91+
before_reassignment = read_value() # $ MISSING: tracked
9292
value = "safe"
93-
safe_sibling = read_value() # $ SPURIOUS: tracked
93+
safe_sibling = read_value()
9494

95-
before_reassignment # $ tracked
96-
safe_sibling # $ SPURIOUS: tracked
95+
before_reassignment # $ MISSING: tracked
96+
safe_sibling
9797

9898

9999
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)