@@ -85,7 +85,7 @@ private class ES2015PromiseDefinition extends PromiseDefinition, DataFlow::NewNo
85
85
*/
86
86
abstract class PromiseCreationCall extends DataFlow:: CallNode {
87
87
/**
88
- * Gets the value this promise is resolved with.
88
+ * Gets a value this promise is resolved with.
89
89
*/
90
90
abstract DataFlow:: Node getValue ( ) ;
91
91
}
@@ -95,6 +95,16 @@ abstract class PromiseCreationCall extends DataFlow::CallNode {
95
95
*/
96
96
abstract class ResolvedPromiseDefinition extends PromiseCreationCall { }
97
97
98
+ /**
99
+ * A promise that is created using a `Promise.all(array)` call.
100
+ */
101
+ abstract class PromiseAllCreation extends PromiseCreationCall {
102
+ /**
103
+ * Gets a node for the array of values given to the `Promise.all(array)` call.
104
+ */
105
+ abstract DataFlow:: Node getArrayNode ( ) ;
106
+ }
107
+
98
108
/**
99
109
* A resolved promise created by the standard ECMAScript 2015 `Promise.resolve` function.
100
110
*/
@@ -121,6 +131,15 @@ class AggregateES2015PromiseDefinition extends PromiseCreationCall {
121
131
}
122
132
}
123
133
134
+ /**
135
+ * An aggregated promise created using `Promise.all()`.
136
+ */
137
+ class ES2015PromiseAllDefinition extends AggregateES2015PromiseDefinition , PromiseAllCreation {
138
+ ES2015PromiseAllDefinition ( ) { this .getCalleeName ( ) = "all" }
139
+
140
+ override DataFlow:: Node getArrayNode ( ) { result = getArgument ( 0 ) }
141
+ }
142
+
124
143
/**
125
144
* Common predicates shared between type-tracking and data-flow for promises.
126
145
*/
@@ -303,16 +322,28 @@ private module PromiseFlow {
303
322
CreationStep ( ) { this = promise }
304
323
305
324
override predicate store ( DataFlow:: Node pred , DataFlow:: SourceNode succ , string prop ) {
325
+ not promise instanceof PromiseAllCreation and
306
326
prop = valueProp ( ) and
307
327
pred = promise .getValue ( ) and
308
328
succ = this
329
+ or
330
+ promise instanceof PromiseAllCreation and
331
+ prop = valueProp ( ) and
332
+ pred = promise .( PromiseAllCreation ) .getArrayNode ( ) and
333
+ succ = this
309
334
}
310
335
311
336
override predicate loadStore ( DataFlow:: Node pred , DataFlow:: Node succ , string prop ) {
312
337
// Copy the value of a resolved promise to the value of this promise.
338
+ not promise instanceof PromiseAllCreation and
313
339
prop = valueProp ( ) and
314
340
pred = promise .getValue ( ) and
315
341
succ = this
342
+ or
343
+ promise instanceof PromiseAllCreation and
344
+ prop = valueProp ( ) and
345
+ pred = promise .( PromiseAllCreation ) .getArrayNode ( ) and
346
+ succ = this
316
347
}
317
348
}
318
349
@@ -533,6 +564,15 @@ module Bluebird {
533
564
result = getArgument ( 0 ) .getALocalSource ( ) .( DataFlow:: ArrayCreationNode ) .getAnElement ( )
534
565
}
535
566
}
567
+
568
+ /**
569
+ * A promise created using `Promise.all`:
570
+ */
571
+ class BluebirdPromiseAllDefinition extends AggregateBluebirdPromiseDefinition , PromiseAllCreation {
572
+ BluebirdPromiseAllDefinition ( ) { this .getCalleeName ( ) = "all" }
573
+
574
+ override DataFlow:: Node getArrayNode ( ) { result = getArgument ( 0 ) }
575
+ }
536
576
}
537
577
538
578
/**
0 commit comments