Skip to content

Commit 7af1955

Browse files
committed
add test case for location.split("?")[0] for DomBasedXss
1 parent 4dcf944 commit 7af1955

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ nodes
357357
| tst.js:366:21:366:26 | target |
358358
| tst.js:369:18:369:23 | target |
359359
| tst.js:369:18:369:23 | target |
360+
| tst.js:377:7:377:39 | target |
361+
| tst.js:377:16:377:32 | document.location |
362+
| tst.js:377:16:377:32 | document.location |
363+
| tst.js:377:16:377:39 | documen ... .search |
364+
| tst.js:380:18:380:23 | target |
365+
| tst.js:380:18:380:23 | target |
360366
| typeahead.js:20:13:20:45 | target |
361367
| typeahead.js:20:22:20:38 | document.location |
362368
| typeahead.js:20:22:20:38 | document.location |
@@ -689,6 +695,11 @@ edges
689695
| tst.js:361:19:361:35 | document.location | tst.js:361:19:361:42 | documen ... .search |
690696
| tst.js:361:19:361:35 | document.location | tst.js:361:19:361:42 | documen ... .search |
691697
| tst.js:361:19:361:42 | documen ... .search | tst.js:361:10:361:42 | target |
698+
| tst.js:377:7:377:39 | target | tst.js:380:18:380:23 | target |
699+
| tst.js:377:7:377:39 | target | tst.js:380:18:380:23 | target |
700+
| tst.js:377:16:377:32 | document.location | tst.js:377:16:377:39 | documen ... .search |
701+
| tst.js:377:16:377:32 | document.location | tst.js:377:16:377:39 | documen ... .search |
702+
| tst.js:377:16:377:39 | documen ... .search | tst.js:377:7:377:39 | target |
692703
| typeahead.js:20:13:20:45 | target | typeahead.js:21:12:21:17 | target |
693704
| typeahead.js:20:22:20:38 | document.location | typeahead.js:20:22:20:45 | documen ... .search |
694705
| typeahead.js:20:22:20:38 | document.location | typeahead.js:20:22:20:45 | documen ... .search |
@@ -794,6 +805,7 @@ edges
794805
| tst.js:362:16:362:21 | target | tst.js:361:19:361:35 | document.location | tst.js:362:16:362:21 | target | Cross-site scripting vulnerability due to $@. | tst.js:361:19:361:35 | document.location | user-provided value |
795806
| tst.js:366:21:366:26 | target | tst.js:361:19:361:35 | document.location | tst.js:366:21:366:26 | target | Cross-site scripting vulnerability due to $@. | tst.js:361:19:361:35 | document.location | user-provided value |
796807
| tst.js:369:18:369:23 | target | tst.js:361:19:361:35 | document.location | tst.js:369:18:369:23 | target | Cross-site scripting vulnerability due to $@. | tst.js:361:19:361:35 | document.location | user-provided value |
808+
| tst.js:380:18:380:23 | target | tst.js:377:16:377:32 | document.location | tst.js:380:18:380:23 | target | Cross-site scripting vulnerability due to $@. | tst.js:377:16:377:32 | document.location | user-provided value |
797809
| typeahead.js:25:18:25:20 | val | typeahead.js:20:22:20:38 | document.location | typeahead.js:25:18:25:20 | val | Cross-site scripting vulnerability due to $@. | typeahead.js:20:22:20:38 | document.location | user-provided value |
798810
| 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 |
799811
| winjs.js:3:43:3:49 | tainted | winjs.js:2:17:2:33 | document.location | winjs.js:3:43:3:49 | tainted | Cross-site scripting vulnerability due to $@. | winjs.js:2:17:2:33 | document.location | user-provided value |

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,13 @@ function thisNodes() {
372372
$.fn[pluginName] = myPlugin;
373373

374374
}
375+
376+
function test() {
377+
var target = document.location.search
378+
379+
// NOT OK
380+
$('myId').html(target)
381+
382+
// OK
383+
$('myid').html(document.location.href.split("?")[0]);
384+
}

0 commit comments

Comments
 (0)