Skip to content

Commit b64b837

Browse files
committed
JS: Add: test cases for find, findLast, findLastIndex with callbacks
1 parent 1b0f8aa commit b64b837

File tree

4 files changed

+385
-129
lines changed

4 files changed

+385
-129
lines changed

javascript/ql/test/library-tests/Arrays/DataFlow.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@
2626
| arrays.js:53:4:53:11 | "source" | arrays.js:54:10:54:18 | ary.pop() |
2727
| arrays.js:99:31:99:38 | "source" | arrays.js:100:8:100:17 | arr8.pop() |
2828
| arrays.js:103:55:103:62 | "source" | arrays.js:105:8:105:25 | arr8_variant.pop() |
29+
| arrays.js:114:19:114:26 | "source" | arrays.js:116:10:116:16 | element |
30+
| arrays.js:120:19:120:26 | "source" | arrays.js:122:10:122:16 | element |

javascript/ql/test/library-tests/Arrays/TaintFlow.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
| arrays.js:96:9:96:16 | "source" | arrays.js:96:8:96:36 | ["sourc ... => !!x) |
3131
| arrays.js:99:31:99:38 | "source" | arrays.js:100:8:100:17 | arr8.pop() |
3232
| arrays.js:103:55:103:62 | "source" | arrays.js:105:8:105:25 | arr8_variant.pop() |
33+
| arrays.js:114:19:114:26 | "source" | arrays.js:116:10:116:16 | element |
34+
| arrays.js:120:19:120:26 | "source" | arrays.js:122:10:122:16 | element |

javascript/ql/test/library-tests/Arrays/arrays.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,22 @@
109109
sink(arr8_spread.pop()); // NOT OK
110110

111111
sink(arr.findLast(someCallback)); // NOT OK
112+
113+
{ // Test for findLast function
114+
const list = ["source"];
115+
const element = list.findLast((item) => sink(item)); // NOT OK -- Not caught, currently missing dataflow tracking.
116+
sink(element); // NOT OK
117+
}
118+
119+
{ // Test for find function
120+
const list = ["source"];
121+
const element = list.find((item) => sink(item)); // NOT OK -- Not caught, currently missing dataflow tracking.
122+
sink(element); // NOT OK
123+
}
124+
125+
{ // Test for findLastIndex function
126+
const list = ["source"];
127+
const element = list.findLastIndex((item) => sink(item)); // NOT OK -- Not caught, currently missing dataflow tracking.
128+
sink(element); // OK
129+
}
112130
});

0 commit comments

Comments
 (0)