Skip to content

Commit 3cbd6d3

Browse files
committed
JS: Test case for nested statements
1 parent f3a4acf commit 3cbd6d3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

javascript/ql/test/library-tests/TaintTracking/BasicTaintTracking.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
| exceptions.js:88:6:88:13 | source() | exceptions.js:33:10:33:21 | e.toString() |
3535
| exceptions.js:88:6:88:13 | source() | exceptions.js:34:10:34:18 | e.message |
3636
| exceptions.js:88:6:88:13 | source() | exceptions.js:35:10:35:19 | e.fileName |
37+
| exceptions.js:93:11:93:18 | source() | exceptions.js:95:10:95:10 | e |
38+
| exceptions.js:100:13:100:20 | source() | exceptions.js:102:12:102:12 | e |
39+
| exceptions.js:115:21:115:28 | source() | exceptions.js:121:10:121:10 | e |
3740
| indexOf.js:4:11:4:18 | source() | indexOf.js:9:10:9:10 | x |
3841
| partialCalls.js:4:17:4:24 | source() | partialCalls.js:17:14:17:14 | x |
3942
| partialCalls.js:4:17:4:24 | source() | partialCalls.js:20:14:20:14 | y |

javascript/ql/test/library-tests/TaintTracking/exceptions.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,38 @@ async function throwAsync(x) {
8888
test(source(), "hello");
8989
test("hey", "hello"); // no single-call inlining
9090

91+
function testNesting(x) {
92+
try {
93+
throw source();
94+
} catch (e) {
95+
sink(e); // NOT OK
96+
}
97+
98+
try {
99+
try {
100+
throw source();
101+
} catch (e) {
102+
sink(e); // NOT OK
103+
}
104+
} catch (e) {
105+
sink(e); // OK - not caught by this catch
106+
}
107+
108+
try {
109+
if (x) {
110+
for (;x;) {
111+
while(x) {
112+
switch (x) {
113+
case 1:
114+
default:
115+
throw source();
116+
}
117+
}
118+
}
119+
}
120+
} catch (e) {
121+
sink(e); // NOT OK
122+
}
123+
}
124+
91125
// semmle-extractor-options: --experimental

0 commit comments

Comments
 (0)