Skip to content

Commit b3ba75a

Browse files
committed
Python: Fix tests by managing local sources
`API::Node::getAwaited` is restriced to local sources
1 parent 56dab25 commit b3ba75a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,19 @@ module EssaFlow {
175175
contextManager.strictlyDominates(var)
176176
)
177177
or
178+
// Async with var definition
179+
// `async with f(42) as x:`
180+
// nodeFrom is `x`, cfg node
181+
// nodeTo is `x`, essa var
182+
//
183+
// This makes the cfg node the local source of the awaited value.
184+
exists(With with, ControlFlowNode var |
185+
nodeFrom.(CfgNode).getNode() = var and
186+
nodeTo.(EssaNode).getVar().getDefinition().(WithDefinition).getDefiningNode() = var and
187+
with.getOptionalVars() = var.getNode() and
188+
with.isAsync()
189+
)
190+
or
178191
// Parameter definition
179192
// `def foo(x):`
180193
// nodeFrom is `x`, cfgNode

0 commit comments

Comments
 (0)