Skip to content

Commit 6114d71

Browse files
committed
Python: subscript on local source nodes
and adjust comment on awaited
1 parent 7f61040 commit 6114d71

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ class LocalSourceNode extends Node {
101101
*/
102102
Node getAnAwaited() { Cached::await(this, result) }
103103

104+
/**
105+
* Gets a subscript of this node.
106+
*/
107+
CfgNode getASubscript() { Cached::subscript(this, result) }
108+
104109
/**
105110
* Gets a call to the method `methodName` on this node.
106111
*
@@ -233,7 +238,7 @@ private module Cached {
233238
}
234239

235240
/**
236-
* Holds if `node` flows to the awaited value of `awaited`.
241+
* Holds if `node` flows to a value that, when awaited, results in `awaited`.
237242
*/
238243
cached
239244
predicate await(LocalSourceNode node, Node awaited) {
@@ -242,4 +247,15 @@ private module Cached {
242247
awaited = awaited(awaitedValue)
243248
)
244249
}
250+
251+
/**
252+
* Holds if `node` flows to a sequence of which `subscript` is a subscript.
253+
*/
254+
cached
255+
predicate subscript(LocalSourceNode node, CfgNode subscript) {
256+
exists(CfgNode seq, SubscriptNode subscriptNode | subscriptNode = subscript.getNode() |
257+
node.flowsTo(seq) and
258+
seq.getNode() = subscriptNode.getObject()
259+
)
260+
}
245261
}

0 commit comments

Comments
 (0)