@@ -72,6 +72,9 @@ predicate benignContext(Expr e) {
72
72
or
73
73
// arguments to Promise.resolve (and promise library variants) are benign.
74
74
e = any ( PromiseCreationCall promise ) .getValue ( ) .asExpr ( )
75
+ or
76
+ // arguments to other (unknown) promise creations.
77
+ e = any ( DataFlow:: CallNode call | call .getCalleeName ( ) = "resolve" ) .getAnArgument ( ) .asExpr ( )
75
78
}
76
79
77
80
predicate oneshotClosure ( DataFlow:: CallNode call ) {
@@ -153,56 +156,6 @@ predicate hasNonVoidReturnType(Function f) {
153
156
exists ( TypeAnnotation type | type = f .getReturnTypeAnnotation ( ) | not type .isVoid ( ) )
154
157
}
155
158
156
- /**
157
- * Provides classes for working with various Deferred implementations.
158
- * It is a heuristic. The heuristic assume that a class is a promise defintion
159
- * if the class is called "Deferred" and the method `resolve` is called on an instance.
160
- *
161
- * Removes some false positives in the js/use-of-returnless-function query.
162
- */
163
- module Deferred {
164
- /**
165
- * An instance of a `Deferred` class.
166
- * For example the result from `new Deferred()` or `new $.Deferred()`.
167
- */
168
- class DeferredInstance extends DataFlow:: NewNode {
169
- // Describes both `new Deferred()`, `new $.Deferred` and other variants.
170
- DeferredInstance ( ) { this .getCalleeName ( ) = "Deferred" }
171
-
172
- private DataFlow:: SourceNode ref ( DataFlow:: TypeTracker t ) {
173
- t .start ( ) and
174
- result = this
175
- or
176
- exists ( DataFlow:: TypeTracker t2 | result = ref ( t2 ) .track ( t2 , t ) )
177
- }
178
-
179
- DataFlow:: SourceNode ref ( ) { result = ref ( DataFlow:: TypeTracker:: end ( ) ) }
180
- }
181
-
182
- /**
183
- * A promise object created by a Deferred constructor
184
- */
185
- private class DeferredPromiseDefinition extends PromiseDefinition , DeferredInstance {
186
- DeferredPromiseDefinition ( ) {
187
- // hardening of the "Deferred" heuristic: a method call to `resolve`.
188
- exists ( ref ( ) .getAMethodCall ( "resolve" ) )
189
- }
190
-
191
- override DataFlow:: FunctionNode getExecutor ( ) { result = getCallback ( 0 ) }
192
- }
193
-
194
- /**
195
- * A resolved promise created by a `new Deferred().resolve()` call.
196
- */
197
- class ResolvedDeferredPromiseDefinition extends PromiseCreationCall {
198
- ResolvedDeferredPromiseDefinition ( ) {
199
- this = any ( DeferredPromiseDefinition def ) .ref ( ) .getAMethodCall ( "resolve" )
200
- }
201
-
202
- override DataFlow:: Node getValue ( ) { result = getArgument ( 0 ) }
203
- }
204
- }
205
-
206
159
from DataFlow:: CallNode call , Function func , string name , string msg
207
160
where
208
161
(
0 commit comments