File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed
python/ql/lib/semmle/python Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -570,8 +570,7 @@ module API {
570
570
* API graph node for the prefix `foo`), in accordance with the usual semantics of Python.
571
571
*/
572
572
573
- private import semmle.python.internal.Awaited
574
-
573
+ // private import semmle.python.internal.Awaited
575
574
cached
576
575
newtype TApiNode =
577
576
/** The root of the API graph. */
@@ -762,11 +761,8 @@ module API {
762
761
)
763
762
or
764
763
// 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 ( )
770
766
)
771
767
or
772
768
exists ( DataFlow:: Node def , PY:: CallableExpr fn |
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ private import python
10
10
import DataFlowPublic
11
11
private import DataFlowPrivate
12
12
private import semmle.python.internal.CachedStages
13
+ private import semmle.python.internal.Awaited
13
14
14
15
/**
15
16
* A data flow node that is a source of local flow. This includes things like
@@ -95,6 +96,11 @@ class LocalSourceNode extends Node {
95
96
*/
96
97
CallCfgNode getACall ( ) { Cached:: call ( this , result ) }
97
98
99
+ /**
100
+ * Gets an awaited value from this node.
101
+ */
102
+ Node getAnAwaited ( ) { Cached:: await ( this , result ) }
103
+
98
104
/**
99
105
* Gets a call to the method `methodName` on this node.
100
106
*
@@ -225,4 +231,15 @@ private module Cached {
225
231
n = call .getFunction ( )
226
232
)
227
233
}
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
+ }
228
245
}
You can’t perform that action at this time.
0 commit comments