Skip to content

Commit f3de75a

Browse files
author
Esben Sparre Andreasen
committed
JS: update a js/code-injection test
1 parent e41080f commit f3de75a

File tree

3 files changed

+111
-4
lines changed

3 files changed

+111
-4
lines changed

javascript/ql/test/query-tests/Security/CWE-094/CodeInjection/CodeInjection.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ nodes
2727
| angularjs.js:50:22:50:36 | location.search |
2828
| angularjs.js:53:32:53:39 | location |
2929
| angularjs.js:53:32:53:46 | location.search |
30-
| eslint-escope-build.js:20:22:20:22 | c |
31-
| eslint-escope-build.js:21:16:21:16 | c |
3230
| express.js:7:24:7:69 | "return ... + "];" |
3331
| express.js:7:44:7:62 | req.param("wobble") |
3432
| express.js:9:34:9:79 | "return ... + "];" |
@@ -73,7 +71,6 @@ edges
7371
| angularjs.js:47:16:47:23 | location | angularjs.js:47:16:47:30 | location.search |
7472
| angularjs.js:50:22:50:29 | location | angularjs.js:50:22:50:36 | location.search |
7573
| angularjs.js:53:32:53:39 | location | angularjs.js:53:32:53:46 | location.search |
76-
| eslint-escope-build.js:20:22:20:22 | c | eslint-escope-build.js:21:16:21:16 | c |
7774
| express.js:7:24:7:62 | "return ... obble") | express.js:7:24:7:69 | "return ... + "];" |
7875
| express.js:7:44:7:62 | req.param("wobble") | express.js:7:24:7:62 | "return ... obble") |
7976
| express.js:7:44:7:62 | req.param("wobble") | express.js:7:24:7:69 | "return ... + "];" |
@@ -113,7 +110,6 @@ edges
113110
| angularjs.js:47:16:47:30 | location.search | angularjs.js:47:16:47:23 | location | angularjs.js:47:16:47:30 | location.search | $@ flows to here and is interpreted as code. | angularjs.js:47:16:47:23 | location | User-provided value |
114111
| angularjs.js:50:22:50:36 | location.search | angularjs.js:50:22:50:29 | location | angularjs.js:50:22:50:36 | location.search | $@ flows to here and is interpreted as code. | angularjs.js:50:22:50:29 | location | User-provided value |
115112
| angularjs.js:53:32:53:46 | location.search | angularjs.js:53:32:53:39 | location | angularjs.js:53:32:53:46 | location.search | $@ flows to here and is interpreted as code. | angularjs.js:53:32:53:39 | location | User-provided value |
116-
| eslint-escope-build.js:21:16:21:16 | c | eslint-escope-build.js:20:22:20:22 | c | eslint-escope-build.js:21:16:21:16 | c | $@ flows to here and is interpreted as code. | eslint-escope-build.js:20:22:20:22 | c | User-provided value |
117113
| express.js:7:24:7:69 | "return ... + "];" | express.js:7:44:7:62 | req.param("wobble") | express.js:7:24:7:69 | "return ... + "];" | $@ flows to here and is interpreted as code. | express.js:7:44:7:62 | req.param("wobble") | User-provided value |
118114
| express.js:9:34:9:79 | "return ... + "];" | express.js:9:54:9:72 | req.param("wobble") | express.js:9:34:9:79 | "return ... + "];" | $@ flows to here and is interpreted as code. | express.js:9:54:9:72 | req.param("wobble") | User-provided value |
119115
| express.js:12:8:12:53 | "return ... + "];" | express.js:12:28:12:46 | req.param("wobble") | express.js:12:8:12:53 | "return ... + "];" | $@ flows to here and is interpreted as code. | express.js:12:28:12:46 | req.param("wobble") | User-provided value |
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
nodes
2+
| angularjs.js:10:22:10:29 | location |
3+
| angularjs.js:10:22:10:36 | location.search |
4+
| angularjs.js:13:23:13:30 | location |
5+
| angularjs.js:13:23:13:37 | location.search |
6+
| angularjs.js:16:28:16:35 | location |
7+
| angularjs.js:16:28:16:42 | location.search |
8+
| angularjs.js:19:22:19:29 | location |
9+
| angularjs.js:19:22:19:36 | location.search |
10+
| angularjs.js:22:27:22:34 | location |
11+
| angularjs.js:22:27:22:41 | location.search |
12+
| angularjs.js:25:23:25:30 | location |
13+
| angularjs.js:25:23:25:37 | location.search |
14+
| angularjs.js:28:33:28:40 | location |
15+
| angularjs.js:28:33:28:47 | location.search |
16+
| angularjs.js:31:28:31:35 | location |
17+
| angularjs.js:31:28:31:42 | location.search |
18+
| angularjs.js:34:18:34:25 | location |
19+
| angularjs.js:34:18:34:32 | location.search |
20+
| angularjs.js:40:18:40:25 | location |
21+
| angularjs.js:40:18:40:32 | location.search |
22+
| angularjs.js:44:17:44:24 | location |
23+
| angularjs.js:44:17:44:31 | location.search |
24+
| angularjs.js:47:16:47:23 | location |
25+
| angularjs.js:47:16:47:30 | location.search |
26+
| angularjs.js:50:22:50:29 | location |
27+
| angularjs.js:50:22:50:36 | location.search |
28+
| angularjs.js:53:32:53:39 | location |
29+
| angularjs.js:53:32:53:46 | location.search |
30+
| eslint-escope-build.js:20:22:20:22 | c |
31+
| eslint-escope-build.js:21:16:21:16 | c |
32+
| express.js:7:24:7:69 | "return ... + "];" |
33+
| express.js:7:44:7:62 | req.param("wobble") |
34+
| express.js:9:34:9:79 | "return ... + "];" |
35+
| express.js:9:54:9:72 | req.param("wobble") |
36+
| express.js:12:8:12:53 | "return ... + "];" |
37+
| express.js:12:28:12:46 | req.param("wobble") |
38+
| react-native.js:7:7:7:33 | tainted |
39+
| react-native.js:7:17:7:33 | req.param("code") |
40+
| react-native.js:8:32:8:38 | tainted |
41+
| react-native.js:10:23:10:29 | tainted |
42+
| tst.js:2:6:2:22 | document.location |
43+
| tst.js:2:6:2:27 | documen ... on.href |
44+
| tst.js:2:6:2:83 | documen ... t=")+8) |
45+
| tst.js:5:12:5:28 | document.location |
46+
| tst.js:5:12:5:33 | documen ... on.hash |
47+
| tst.js:14:10:14:26 | document.location |
48+
| tst.js:14:10:14:33 | documen ... .search |
49+
| tst.js:14:10:14:74 | documen ... , "$1") |
50+
| tst.js:17:21:17:37 | document.location |
51+
| tst.js:17:21:17:42 | documen ... on.hash |
52+
| tst.js:20:30:20:46 | document.location |
53+
| tst.js:20:30:20:51 | documen ... on.hash |
54+
| tst.js:23:6:23:46 | atob(do ... ing(1)) |
55+
| tst.js:23:11:23:27 | document.location |
56+
| tst.js:23:11:23:32 | documen ... on.hash |
57+
| tst.js:23:11:23:45 | documen ... ring(1) |
58+
| tst.js:26:26:26:33 | location |
59+
| tst.js:26:26:26:40 | location.search |
60+
| tst.js:26:26:26:53 | locatio ... ring(1) |
61+
edges
62+
| angularjs.js:10:22:10:29 | location | angularjs.js:10:22:10:36 | location.search |
63+
| angularjs.js:13:23:13:30 | location | angularjs.js:13:23:13:37 | location.search |
64+
| angularjs.js:16:28:16:35 | location | angularjs.js:16:28:16:42 | location.search |
65+
| angularjs.js:19:22:19:29 | location | angularjs.js:19:22:19:36 | location.search |
66+
| angularjs.js:22:27:22:34 | location | angularjs.js:22:27:22:41 | location.search |
67+
| angularjs.js:25:23:25:30 | location | angularjs.js:25:23:25:37 | location.search |
68+
| angularjs.js:28:33:28:40 | location | angularjs.js:28:33:28:47 | location.search |
69+
| angularjs.js:31:28:31:35 | location | angularjs.js:31:28:31:42 | location.search |
70+
| angularjs.js:34:18:34:25 | location | angularjs.js:34:18:34:32 | location.search |
71+
| angularjs.js:40:18:40:25 | location | angularjs.js:40:18:40:32 | location.search |
72+
| angularjs.js:44:17:44:24 | location | angularjs.js:44:17:44:31 | location.search |
73+
| angularjs.js:47:16:47:23 | location | angularjs.js:47:16:47:30 | location.search |
74+
| angularjs.js:50:22:50:29 | location | angularjs.js:50:22:50:36 | location.search |
75+
| angularjs.js:53:32:53:39 | location | angularjs.js:53:32:53:46 | location.search |
76+
| eslint-escope-build.js:20:22:20:22 | c | eslint-escope-build.js:21:16:21:16 | c |
77+
| express.js:7:24:7:62 | "return ... obble") | express.js:7:24:7:69 | "return ... + "];" |
78+
| express.js:7:44:7:62 | req.param("wobble") | express.js:7:24:7:62 | "return ... obble") |
79+
| express.js:7:44:7:62 | req.param("wobble") | express.js:7:24:7:69 | "return ... + "];" |
80+
| express.js:9:34:9:72 | "return ... obble") | express.js:9:34:9:79 | "return ... + "];" |
81+
| express.js:9:54:9:72 | req.param("wobble") | express.js:9:34:9:72 | "return ... obble") |
82+
| express.js:9:54:9:72 | req.param("wobble") | express.js:9:34:9:79 | "return ... + "];" |
83+
| express.js:12:8:12:46 | "return ... obble") | express.js:12:8:12:53 | "return ... + "];" |
84+
| express.js:12:28:12:46 | req.param("wobble") | express.js:12:8:12:46 | "return ... obble") |
85+
| express.js:12:28:12:46 | req.param("wobble") | express.js:12:8:12:53 | "return ... + "];" |
86+
| react-native.js:7:7:7:33 | tainted | react-native.js:8:32:8:38 | tainted |
87+
| react-native.js:7:7:7:33 | tainted | react-native.js:10:23:10:29 | tainted |
88+
| react-native.js:7:17:7:33 | req.param("code") | react-native.js:7:7:7:33 | tainted |
89+
| tst.js:2:6:2:22 | document.location | tst.js:2:6:2:27 | documen ... on.href |
90+
| tst.js:2:6:2:27 | documen ... on.href | tst.js:2:6:2:83 | documen ... t=")+8) |
91+
| tst.js:5:12:5:28 | document.location | tst.js:5:12:5:33 | documen ... on.hash |
92+
| tst.js:14:10:14:26 | document.location | tst.js:14:10:14:33 | documen ... .search |
93+
| tst.js:14:10:14:33 | documen ... .search | tst.js:14:10:14:74 | documen ... , "$1") |
94+
| tst.js:17:21:17:37 | document.location | tst.js:17:21:17:42 | documen ... on.hash |
95+
| tst.js:20:30:20:46 | document.location | tst.js:20:30:20:51 | documen ... on.hash |
96+
| tst.js:23:11:23:27 | document.location | tst.js:23:11:23:32 | documen ... on.hash |
97+
| tst.js:23:11:23:32 | documen ... on.hash | tst.js:23:11:23:45 | documen ... ring(1) |
98+
| tst.js:23:11:23:45 | documen ... ring(1) | tst.js:23:6:23:46 | atob(do ... ing(1)) |
99+
| tst.js:26:26:26:33 | location | tst.js:26:26:26:40 | location.search |
100+
| tst.js:26:26:26:40 | location.search | tst.js:26:26:26:53 | locatio ... ring(1) |
101+
#select
102+
| eslint-escope-build.js:21:16:21:16 | c | eslint-escope-build.js:20:22:20:22 | c | eslint-escope-build.js:21:16:21:16 | c | $@ flows to here and is interpreted as code. | eslint-escope-build.js:20:22:20:22 | c | User-provided value |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import javascript
2+
import semmle.javascript.heuristics.AdditionalSources
3+
import semmle.javascript.security.dataflow.CodeInjection::CodeInjection
4+
import DataFlow::PathGraph
5+
6+
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
7+
where cfg.hasFlowPath(source, sink) and source.getNode() instanceof HeuristicSource
8+
select sink.getNode(), source, sink, "$@ flows to here and is interpreted as code.",
9+
source.getNode(), "User-provided value"

0 commit comments

Comments
 (0)