File tree Expand file tree Collapse file tree
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments