Skip to content

Commit c7f16cd

Browse files
committed
JS: Add test
1 parent 0d598c4 commit c7f16cd

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/Xss.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,10 @@ nodes
11191119
| tst.js:494:18:494:30 | location.hash |
11201120
| tst.js:494:18:494:40 | locatio ... bstr(1) |
11211121
| tst.js:494:18:494:40 | locatio ... bstr(1) |
1122+
| tst.js:501:33:501:63 | decodeU ... n.hash) |
1123+
| tst.js:501:33:501:63 | decodeU ... n.hash) |
1124+
| tst.js:501:43:501:62 | window.location.hash |
1125+
| tst.js:501:43:501:62 | window.location.hash |
11221126
| typeahead.js:20:13:20:45 | target |
11231127
| typeahead.js:20:22:20:45 | documen ... .search |
11241128
| typeahead.js:20:22:20:45 | documen ... .search |
@@ -2271,6 +2275,10 @@ edges
22712275
| tst.js:494:18:494:30 | location.hash | tst.js:494:18:494:40 | locatio ... bstr(1) |
22722276
| tst.js:494:18:494:30 | location.hash | tst.js:494:18:494:40 | locatio ... bstr(1) |
22732277
| tst.js:494:18:494:30 | location.hash | tst.js:494:18:494:40 | locatio ... bstr(1) |
2278+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
2279+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
2280+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
2281+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
22742282
| typeahead.js:20:13:20:45 | target | typeahead.js:21:12:21:17 | target |
22752283
| typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:20:13:20:45 | target |
22762284
| typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:20:13:20:45 | target |
@@ -2559,6 +2567,7 @@ edges
25592567
| tst.js:486:22:486:24 | url | tst.js:471:13:471:36 | documen ... .search | tst.js:486:22:486:24 | url | Cross-site scripting vulnerability due to $@. | tst.js:471:13:471:36 | documen ... .search | user-provided value |
25602568
| tst.js:491:23:491:45 | locatio ... bstr(1) | tst.js:491:23:491:35 | location.hash | tst.js:491:23:491:45 | locatio ... bstr(1) | Cross-site scripting vulnerability due to $@. | tst.js:491:23:491:35 | location.hash | user-provided value |
25612569
| tst.js:494:18:494:40 | locatio ... bstr(1) | tst.js:494:18:494:30 | location.hash | tst.js:494:18:494:40 | locatio ... bstr(1) | Cross-site scripting vulnerability due to $@. | tst.js:494:18:494:30 | location.hash | user-provided value |
2570+
| tst.js:501:33:501:63 | decodeU ... n.hash) | tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) | Cross-site scripting vulnerability due to $@. | tst.js:501:43:501:62 | window.location.hash | user-provided value |
25622571
| typeahead.js:25:18:25:20 | val | typeahead.js:20:22:20:45 | documen ... .search | typeahead.js:25:18:25:20 | val | Cross-site scripting vulnerability due to $@. | typeahead.js:20:22:20:45 | documen ... .search | user-provided value |
25632572
| v-html.vue:2:8:2:23 | v-html=tainted | v-html.vue:6:42:6:58 | document.location | v-html.vue:2:8:2:23 | v-html=tainted | Cross-site scripting vulnerability due to $@. | v-html.vue:6:42:6:58 | document.location | user-provided value |
25642573
| various-concat-obfuscations.js:4:4:4:31 | "<div>" ... </div>" | various-concat-obfuscations.js:2:16:2:39 | documen ... .search | various-concat-obfuscations.js:4:4:4:31 | "<div>" ... </div>" | Cross-site scripting vulnerability due to $@. | various-concat-obfuscations.js:2:16:2:39 | documen ... .search | user-provided value |

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/XssWithAdditionalSources.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,10 @@ nodes
11311131
| tst.js:494:18:494:30 | location.hash |
11321132
| tst.js:494:18:494:40 | locatio ... bstr(1) |
11331133
| tst.js:494:18:494:40 | locatio ... bstr(1) |
1134+
| tst.js:501:33:501:63 | decodeU ... n.hash) |
1135+
| tst.js:501:33:501:63 | decodeU ... n.hash) |
1136+
| tst.js:501:43:501:62 | window.location.hash |
1137+
| tst.js:501:43:501:62 | window.location.hash |
11341138
| typeahead.js:9:28:9:30 | loc |
11351139
| typeahead.js:9:28:9:30 | loc |
11361140
| typeahead.js:9:28:9:30 | loc |
@@ -2333,6 +2337,10 @@ edges
23332337
| tst.js:494:18:494:30 | location.hash | tst.js:494:18:494:40 | locatio ... bstr(1) |
23342338
| tst.js:494:18:494:30 | location.hash | tst.js:494:18:494:40 | locatio ... bstr(1) |
23352339
| tst.js:494:18:494:30 | location.hash | tst.js:494:18:494:40 | locatio ... bstr(1) |
2340+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
2341+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
2342+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
2343+
| tst.js:501:43:501:62 | window.location.hash | tst.js:501:33:501:63 | decodeU ... n.hash) |
23362344
| typeahead.js:9:28:9:30 | loc | typeahead.js:10:16:10:18 | loc |
23372345
| typeahead.js:9:28:9:30 | loc | typeahead.js:10:16:10:18 | loc |
23382346
| typeahead.js:9:28:9:30 | loc | typeahead.js:10:16:10:18 | loc |

javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/tst.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,13 @@ function urlStuff() {
493493
const myHistory = require('history').createBrowserHistory();
494494
myHistory.push(location.hash.substr(1)); // NOT OK
495495
}
496+
497+
function Foo() {
498+
this.foo = document;
499+
var obj = {
500+
bar: function() {
501+
this.foo.body.innerHTML = decodeURI(window.location.hash); // NOT OK
502+
}
503+
};
504+
Object.assign(this, obj);
505+
}

0 commit comments

Comments
 (0)