Skip to content

Commit 47c519f

Browse files
committed
JS: Add test for flow through dynamic imports
1 parent 7cfe3da commit 47c519f

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ legacyDataFlowDifference
1414
| constructor-calls.js:4:18:4:25 | source() | constructor-calls.js:44:8:44:19 | f_safe.taint | only flow with NEW data flow library |
1515
| constructor-calls.js:20:15:20:22 | source() | constructor-calls.js:39:8:39:14 | e.param | only flow with NEW data flow library |
1616
| exceptions.js:53:14:53:21 | source() | exceptions.js:54:10:54:10 | e | only flow with NEW data flow library |
17+
| export-taint.js:3:22:3:29 | source() | import-taint.js:7:10:7:25 | mod.object.taint | only flow with OLD data flow library |
18+
| export-taint.js:3:22:3:29 | source() | import-taint.js:14:14:14:29 | mod.object.taint | only flow with OLD data flow library |
1719
| getters-and-setters.js:53:21:53:28 | source() | getters-and-setters.js:53:10:53:30 | getX(ne ... rce())) | only flow with NEW data flow library |
1820
| nested-props.js:14:15:14:22 | source() | nested-props.js:15:10:15:16 | obj.x.y | only flow with NEW data flow library |
1921
| nested-props.js:27:18:27:25 | source() | nested-props.js:28:10:28:14 | obj.x | only flow with NEW data flow library |
@@ -165,6 +167,8 @@ flow
165167
| exceptions.js:144:9:144:16 | source() | exceptions.js:132:8:132:27 | returnThrownSource() |
166168
| exceptions.js:150:13:150:20 | source() | exceptions.js:153:10:153:10 | e |
167169
| exceptions.js:158:13:158:20 | source() | exceptions.js:161:10:161:10 | e |
170+
| export-taint.js:2:12:2:19 | source() | import-taint.js:6:10:6:18 | mod.taint |
171+
| export-taint.js:2:12:2:19 | source() | import-taint.js:13:14:13:22 | mod.taint |
168172
| factory-function.js:21:13:21:20 | source() | factory-function.js:7:10:7:12 | obj |
169173
| factory-function.js:22:13:22:20 | source() | factory-function.js:7:10:7:12 | obj |
170174
| factory-function.js:26:7:26:14 | source() | factory-function.js:16:14:16:16 | obj |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ legacyDataFlowDifference
1515
| constructor-calls.js:4:18:4:25 | source() | constructor-calls.js:44:8:44:19 | f_safe.taint | only flow with NEW data flow library |
1616
| constructor-calls.js:20:15:20:22 | source() | constructor-calls.js:39:8:39:14 | e.param | only flow with NEW data flow library |
1717
| exceptions.js:53:14:53:21 | source() | exceptions.js:54:10:54:10 | e | only flow with NEW data flow library |
18+
| export-taint.js:3:22:3:29 | source() | import-taint.js:7:10:7:25 | mod.object.taint | only flow with OLD data flow library |
19+
| export-taint.js:3:22:3:29 | source() | import-taint.js:14:14:14:29 | mod.object.taint | only flow with OLD data flow library |
1820
| getters-and-setters.js:53:21:53:28 | source() | getters-and-setters.js:53:10:53:30 | getX(ne ... rce())) | only flow with NEW data flow library |
1921
| nested-props.js:14:15:14:22 | source() | nested-props.js:15:10:15:16 | obj.x.y | only flow with NEW data flow library |
2022
| nested-props.js:27:18:27:25 | source() | nested-props.js:28:10:28:14 | obj.x | only flow with NEW data flow library |
@@ -115,6 +117,8 @@ flow
115117
| exceptions.js:144:9:144:16 | source() | exceptions.js:132:8:132:27 | returnThrownSource() |
116118
| exceptions.js:150:13:150:20 | source() | exceptions.js:153:10:153:10 | e |
117119
| exceptions.js:158:13:158:20 | source() | exceptions.js:161:10:161:10 | e |
120+
| export-taint.js:2:12:2:19 | source() | import-taint.js:6:10:6:18 | mod.taint |
121+
| export-taint.js:2:12:2:19 | source() | import-taint.js:13:14:13:22 | mod.taint |
118122
| factory-function.js:21:13:21:20 | source() | factory-function.js:7:10:7:12 | obj |
119123
| factory-function.js:22:13:22:20 | source() | factory-function.js:7:10:7:12 | obj |
120124
| factory-function.js:26:7:26:14 | source() | factory-function.js:16:14:16:16 | obj |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
taint: source(),
3+
object: { taint: source() }
4+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import 'dummy';
2+
3+
async function test1() {
4+
let mod = await import("./export-taint");
5+
sink(mod); // OK
6+
sink(mod.taint); // NOT OK
7+
sink(mod.object.taint); // NOT OK [INCONSISTENCY] - blocked by access path limit
8+
}
9+
10+
function test2() {
11+
import("./export-taint").then(mod => {
12+
sink(mod); // OK
13+
sink(mod.taint); // NOT OK
14+
sink(mod.object.taint); // NOT OK [INCONSISTENCY] - blocked by access path limit
15+
});
16+
}

0 commit comments

Comments
 (0)