Skip to content

Commit 659d40e

Browse files
committed
add test to make sure sanitizer is not too broad
1 parent c56063f commit 659d40e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

javascript/ql/test/query-tests/Security/CWE-601/ClientSideUrlRedirect/ClientSideUrlRedirect.expected

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ nodes
5555
| tst10.js:14:33:14:49 | document.location |
5656
| tst10.js:14:33:14:49 | document.location |
5757
| tst10.js:14:33:14:56 | documen ... .search |
58+
| tst12.js:3:9:3:50 | urlParts |
59+
| tst12.js:3:20:3:34 | window.location |
60+
| tst12.js:3:20:3:34 | window.location |
61+
| tst12.js:3:20:3:34 | window.location |
62+
| tst12.js:3:20:3:39 | window.location.hash |
63+
| tst12.js:3:20:3:50 | window. ... it('?') |
64+
| tst12.js:4:9:4:45 | loc |
65+
| tst12.js:4:15:4:22 | urlParts |
66+
| tst12.js:4:15:4:25 | urlParts[0] |
67+
| tst12.js:4:15:4:45 | urlPart ... s.value |
68+
| tst12.js:5:23:5:25 | loc |
69+
| tst12.js:5:23:5:25 | loc |
5870
| tst.js:2:19:2:69 | /.*redi ... n.href) |
5971
| tst.js:2:19:2:72 | /.*redi ... ref)[1] |
6072
| tst.js:2:19:2:72 | /.*redi ... ref)[1] |
@@ -120,6 +132,18 @@ edges
120132
| tst10.js:14:33:14:49 | document.location | tst10.js:14:33:14:56 | documen ... .search |
121133
| tst10.js:14:33:14:56 | documen ... .search | tst10.js:14:17:14:56 | 'https: ... .search |
122134
| tst10.js:14:33:14:56 | documen ... .search | tst10.js:14:17:14:56 | 'https: ... .search |
135+
| tst12.js:3:9:3:50 | urlParts | tst12.js:4:15:4:22 | urlParts |
136+
| tst12.js:3:20:3:34 | window.location | tst12.js:3:20:3:39 | window.location.hash |
137+
| tst12.js:3:20:3:34 | window.location | tst12.js:3:20:3:39 | window.location.hash |
138+
| tst12.js:3:20:3:34 | window.location | tst12.js:3:20:3:39 | window.location.hash |
139+
| tst12.js:3:20:3:39 | window.location.hash | tst12.js:3:20:3:50 | window. ... it('?') |
140+
| tst12.js:3:20:3:50 | window. ... it('?') | tst12.js:3:9:3:50 | urlParts |
141+
| tst12.js:4:9:4:45 | loc | tst12.js:5:23:5:25 | loc |
142+
| tst12.js:4:9:4:45 | loc | tst12.js:5:23:5:25 | loc |
143+
| tst12.js:4:15:4:22 | urlParts | tst12.js:4:15:4:25 | urlParts[0] |
144+
| tst12.js:4:15:4:25 | urlParts[0] | tst12.js:4:15:4:45 | urlPart ... s.value |
145+
| tst12.js:4:15:4:45 | urlPart ... s.value | tst12.js:4:9:4:45 | loc |
146+
| tst12.js:5:23:5:25 | loc | tst12.js:3:20:3:34 | window.location |
123147
| tst.js:2:19:2:69 | /.*redi ... n.href) | tst.js:2:19:2:72 | /.*redi ... ref)[1] |
124148
| tst.js:2:19:2:69 | /.*redi ... n.href) | tst.js:2:19:2:72 | /.*redi ... ref)[1] |
125149
| tst.js:2:47:2:63 | document.location | tst.js:2:47:2:68 | documen ... on.href |
@@ -142,5 +166,6 @@ edges
142166
| tst10.js:8:17:8:47 | '//' + ... .search | tst10.js:8:24:8:40 | document.location | tst10.js:8:17:8:47 | '//' + ... .search | Untrusted URL redirection due to $@. | tst10.js:8:24:8:40 | document.location | user-provided value |
143167
| tst10.js:11:17:11:50 | '//foo' ... .search | tst10.js:11:27:11:43 | document.location | tst10.js:11:17:11:50 | '//foo' ... .search | Untrusted URL redirection due to $@. | tst10.js:11:27:11:43 | document.location | user-provided value |
144168
| tst10.js:14:17:14:56 | 'https: ... .search | tst10.js:14:33:14:49 | document.location | tst10.js:14:17:14:56 | 'https: ... .search | Untrusted URL redirection due to $@. | tst10.js:14:33:14:49 | document.location | user-provided value |
169+
| tst12.js:5:23:5:25 | loc | tst12.js:3:20:3:34 | window.location | tst12.js:5:23:5:25 | loc | Untrusted URL redirection due to $@. | tst12.js:3:20:3:34 | window.location | user-provided value |
145170
| tst.js:2:19:2:72 | /.*redi ... ref)[1] | tst.js:2:47:2:63 | document.location | tst.js:2:19:2:72 | /.*redi ... ref)[1] | Untrusted URL redirection due to $@. | tst.js:2:47:2:63 | document.location | user-provided value |
146171
| tst.js:6:20:6:59 | indirec ... ref)[1] | tst.js:6:34:6:50 | document.location | tst.js:6:20:6:59 | indirec ... ref)[1] | Untrusted URL redirection due to $@. | tst.js:6:34:6:50 | document.location | user-provided value |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// NOT OK
2+
function foo() {
3+
var urlParts = window.location.hash.split('?');
4+
var loc = urlParts[0] + "?" + boxes.value;
5+
window.location = loc
6+
}

0 commit comments

Comments
 (0)