Skip to content

Commit 5132e61

Browse files
committed
add tests
1 parent e98f794 commit 5132e61

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

javascript/ql/test/library-tests/Promises/AdditionalPromises.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| additional-promises.js:2:13:2:57 | new Pin ... ct) {}) |
2+
| flow2.js:4:2:4:31 | Promise ... lean"]) |
23
| flow.js:7:11:7:59 | new Pro ... ource)) |
34
| flow.js:10:11:10:58 | new Pro ... ource)) |
45
| flow.js:13:11:13:58 | new Pro ... ource)) |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(async function () {
2+
var source = "source";
3+
4+
Promise.all([source, "clean"]).then((arr) => {
5+
sink(arr); // OK - but flagged by taint-tracking.
6+
sink(arr[0]); // NOT OK
7+
sink(arr[1]); // OK - but flagged by taint-tracking.
8+
})
9+
10+
var [clean, tainted] = await Promise.all(["clean", source]);
11+
sink(clean); // OK - but flagged by taint-tracking
12+
sink(tainted); // NOT OK
13+
14+
var [clean2, tainted2] = await Promise.resolve(Promise.all(["clean", source]));
15+
sink(clean2); // OK - but flagged by taint-tracking
16+
sink(tainted2); // NOT OK
17+
});

javascript/ql/test/library-tests/Promises/tests.expected

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
test_ResolvedPromiseDefinition
2+
| flow2.js:4:2:4:31 | Promise ... lean"]) | flow2.js:4:15:4:20 | source |
3+
| flow2.js:4:2:4:31 | Promise ... lean"]) | flow2.js:4:23:4:29 | "clean" |
4+
| flow2.js:10:31:10:60 | Promise ... ource]) | flow2.js:10:44:10:50 | "clean" |
5+
| flow2.js:10:31:10:60 | Promise ... ource]) | flow2.js:10:53:10:58 | source |
6+
| flow2.js:14:33:14:79 | Promise ... urce])) | flow2.js:14:49:14:78 | Promise ... ource]) |
7+
| flow2.js:14:49:14:78 | Promise ... ource]) | flow2.js:14:62:14:68 | "clean" |
8+
| flow2.js:14:49:14:78 | Promise ... ource]) | flow2.js:14:71:14:76 | source |
29
| flow.js:4:11:4:33 | Promise ... source) | flow.js:4:27:4:32 | source |
310
| flow.js:20:2:20:24 | Promise ... source) | flow.js:20:18:20:23 | source |
411
| flow.js:22:2:22:24 | Promise ... source) | flow.js:22:18:22:23 | source |
@@ -188,6 +195,9 @@ test_PromiseDefinition_getACatchHandler
188195
| flow.js:119:2:119:48 | new Pro ... "BLA")) | flow.js:119:56:119:68 | x => resolved |
189196
| promises.js:10:18:17:4 | new Pro ... );\\n }) | promises.js:23:18:25:3 | (v) => ... v;\\n } |
190197
flow
198+
| flow2.js:2:15:2:22 | "source" | flow2.js:6:8:6:13 | arr[0] |
199+
| flow2.js:2:15:2:22 | "source" | flow2.js:12:7:12:13 | tainted |
200+
| flow2.js:2:15:2:22 | "source" | flow2.js:16:7:16:14 | tainted2 |
191201
| flow.js:2:15:2:22 | "source" | flow.js:5:7:5:14 | await p1 |
192202
| flow.js:2:15:2:22 | "source" | flow.js:8:7:8:14 | await p2 |
193203
| flow.js:2:15:2:22 | "source" | flow.js:17:8:17:8 | e |
@@ -220,8 +230,23 @@ flow
220230
| flow.js:2:15:2:22 | "source" | flow.js:129:69:129:69 | x |
221231
| flow.js:2:15:2:22 | "source" | flow.js:131:43:131:43 | x |
222232
exclusiveTaintFlow
233+
| flow2.js:2:15:2:22 | "source" | flow2.js:5:8:5:10 | arr |
234+
| flow2.js:2:15:2:22 | "source" | flow2.js:7:8:7:13 | arr[1] |
235+
| flow2.js:2:15:2:22 | "source" | flow2.js:11:7:11:11 | clean |
236+
| flow2.js:2:15:2:22 | "source" | flow2.js:15:7:15:12 | clean2 |
223237
| interflow.js:3:18:3:25 | "source" | interflow.js:18:10:18:14 | error |
224238
typetrack
239+
| flow2.js:4:2:4:31 | Promise ... lean"]) | flow2.js:4:14:4:30 | [source, "clean"] | copy $PromiseResolveField$ |
240+
| flow2.js:4:2:4:31 | Promise ... lean"]) | flow2.js:4:14:4:30 | [source, "clean"] | store $PromiseResolveField$ |
241+
| flow2.js:4:39:4:41 | arr | flow2.js:4:2:4:31 | Promise ... lean"]) | load $PromiseResolveField$ |
242+
| flow2.js:10:25:10:60 | await P ... ource]) | flow2.js:10:31:10:60 | Promise ... ource]) | load $PromiseResolveField$ |
243+
| flow2.js:10:31:10:60 | Promise ... ource]) | flow2.js:10:43:10:59 | ["clean", source] | copy $PromiseResolveField$ |
244+
| flow2.js:10:31:10:60 | Promise ... ource]) | flow2.js:10:43:10:59 | ["clean", source] | store $PromiseResolveField$ |
245+
| flow2.js:14:27:14:79 | await P ... urce])) | flow2.js:14:33:14:79 | Promise ... urce])) | load $PromiseResolveField$ |
246+
| flow2.js:14:33:14:79 | Promise ... urce])) | flow2.js:14:49:14:78 | Promise ... ource]) | copy $PromiseResolveField$ |
247+
| flow2.js:14:33:14:79 | Promise ... urce])) | flow2.js:14:49:14:78 | Promise ... ource]) | store $PromiseResolveField$ |
248+
| flow2.js:14:49:14:78 | Promise ... ource]) | flow2.js:14:61:14:77 | ["clean", source] | copy $PromiseResolveField$ |
249+
| flow2.js:14:49:14:78 | Promise ... ource]) | flow2.js:14:61:14:77 | ["clean", source] | store $PromiseResolveField$ |
225250
| flow.js:20:2:20:43 | Promise ... ink(x)) | flow.js:20:36:20:42 | sink(x) | copy $PromiseResolveField$ |
226251
| flow.js:20:2:20:43 | Promise ... ink(x)) | flow.js:20:36:20:42 | sink(x) | store $PromiseResolveField$ |
227252
| flow.js:20:31:20:31 | x | flow.js:20:2:20:24 | Promise ... source) | load $PromiseResolveField$ |

0 commit comments

Comments
 (0)