File tree Expand file tree Collapse file tree
python/ql/lib/semmle/python Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -570,8 +570,7 @@ module API {
570570 * API graph node for the prefix `foo`), in accordance with the usual semantics of Python.
571571 */
572572
573- private import semmle.python.internal.Awaited
574-
573+ // private import semmle.python.internal.Awaited
575574 cached
576575 newtype TApiNode =
577576 /** The root of the API graph. */
@@ -762,11 +761,8 @@ module API {
762761 )
763762 or
764763 // awaiting
765- exists ( DataFlow:: Node awaitedValue |
766- lbl = Label:: await ( ) and
767- ref = awaited ( awaitedValue ) and
768- pred .flowsTo ( awaitedValue )
769- )
764+ lbl = Label:: await ( ) and
765+ ref = pred .getAnAwaited ( )
770766 )
771767 or
772768 exists ( DataFlow:: Node def , PY:: CallableExpr fn |
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ private import python
1010import DataFlowPublic
1111private import DataFlowPrivate
1212private import semmle.python.internal.CachedStages
13+ private import semmle.python.internal.Awaited
1314
1415/**
1516 * A data flow node that is a source of local flow. This includes things like
@@ -95,6 +96,11 @@ class LocalSourceNode extends Node {
9596 */
9697 CallCfgNode getACall ( ) { Cached:: call ( this , result ) }
9798
99+ /**
100+ * Gets an awaited value from this node.
101+ */
102+ Node getAnAwaited ( ) { Cached:: await ( this , result ) }
103+
98104 /**
99105 * Gets a call to the method `methodName` on this node.
100106 *
@@ -225,4 +231,15 @@ private module Cached {
225231 n = call .getFunction ( )
226232 )
227233 }
234+
235+ /**
236+ * Holds if `node` flows to the awaited value of `awaited`.
237+ */
238+ cached
239+ predicate await ( LocalSourceNode node , Node awaited ) {
240+ exists ( Node awaitedValue |
241+ node .flowsTo ( awaitedValue ) and
242+ awaited = awaited ( awaitedValue )
243+ )
244+ }
228245}
You can’t perform that action at this time.
0 commit comments