Skip to content

Commit 2c65946

Browse files
committed
JS: Add setOtherInput example
1 parent e983e26 commit 2c65946

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
edges
2-
| angular.ts:12:5:12:23 | field: string = ""; | angular.ts:28:24:28:33 | this.field | provenance | |
3-
| angular.ts:24:24:24:33 | form.value | angular.ts:24:24:24:37 | form.value.foo | provenance | |
2+
| angular.ts:12:5:12:23 | field: string = ""; | angular.ts:33:24:33:33 | this.field | provenance | |
3+
| angular.ts:29:24:29:33 | form.value | angular.ts:29:24:29:37 | form.value.foo | provenance | |
44
| forms.js:8:23:8:28 | values | forms.js:9:31:9:36 | values | provenance | |
55
| forms.js:9:31:9:36 | values | forms.js:9:31:9:40 | values.foo | provenance | |
66
| forms.js:11:24:11:29 | values | forms.js:12:31:12:36 | values | provenance | |
@@ -47,9 +47,9 @@ nodes
4747
| angular.ts:12:5:12:23 | field: string = ""; | semmle.label | field: string = ""; |
4848
| angular.ts:16:24:16:41 | event.target.value | semmle.label | event.target.value |
4949
| angular.ts:20:24:20:35 | target.value | semmle.label | target.value |
50-
| angular.ts:24:24:24:33 | form.value | semmle.label | form.value |
51-
| angular.ts:24:24:24:37 | form.value.foo | semmle.label | form.value.foo |
52-
| angular.ts:28:24:28:33 | this.field | semmle.label | this.field |
50+
| angular.ts:29:24:29:33 | form.value | semmle.label | form.value |
51+
| angular.ts:29:24:29:37 | form.value.foo | semmle.label | form.value.foo |
52+
| angular.ts:33:24:33:33 | this.field | semmle.label | this.field |
5353
| forms.js:8:23:8:28 | values | semmle.label | values |
5454
| forms.js:9:31:9:36 | values | semmle.label | values |
5555
| forms.js:9:31:9:40 | values.foo | semmle.label | values.foo |
@@ -134,8 +134,8 @@ subpaths
134134
#select
135135
| angular.ts:16:24:16:41 | event.target.value | angular.ts:16:24:16:41 | event.target.value | angular.ts:16:24:16:41 | event.target.value | $@ is reinterpreted as HTML without escaping meta-characters. | angular.ts:16:24:16:41 | event.target.value | DOM text |
136136
| angular.ts:20:24:20:35 | target.value | angular.ts:20:24:20:35 | target.value | angular.ts:20:24:20:35 | target.value | $@ is reinterpreted as HTML without escaping meta-characters. | angular.ts:20:24:20:35 | target.value | DOM text |
137-
| angular.ts:24:24:24:37 | form.value.foo | angular.ts:24:24:24:33 | form.value | angular.ts:24:24:24:37 | form.value.foo | $@ is reinterpreted as HTML without escaping meta-characters. | angular.ts:24:24:24:33 | form.value | DOM text |
138-
| angular.ts:28:24:28:33 | this.field | angular.ts:12:5:12:23 | field: string = ""; | angular.ts:28:24:28:33 | this.field | $@ is reinterpreted as HTML without escaping meta-characters. | angular.ts:12:5:12:23 | field: string = ""; | DOM text |
137+
| angular.ts:29:24:29:37 | form.value.foo | angular.ts:29:24:29:33 | form.value | angular.ts:29:24:29:37 | form.value.foo | $@ is reinterpreted as HTML without escaping meta-characters. | angular.ts:29:24:29:33 | form.value | DOM text |
138+
| angular.ts:33:24:33:33 | this.field | angular.ts:12:5:12:23 | field: string = ""; | angular.ts:33:24:33:33 | this.field | $@ is reinterpreted as HTML without escaping meta-characters. | angular.ts:12:5:12:23 | field: string = ""; | DOM text |
139139
| forms.js:9:31:9:40 | values.foo | forms.js:8:23:8:28 | values | forms.js:9:31:9:40 | values.foo | $@ is reinterpreted as HTML without escaping meta-characters. | forms.js:8:23:8:28 | values | DOM text |
140140
| forms.js:12:31:12:40 | values.bar | forms.js:11:24:11:29 | values | forms.js:12:31:12:40 | values.bar | $@ is reinterpreted as HTML without escaping meta-characters. | forms.js:11:24:11:29 | values | DOM text |
141141
| forms.js:25:23:25:34 | values.email | forms.js:24:15:24:20 | values | forms.js:25:23:25:34 | values.email | $@ is reinterpreted as HTML without escaping meta-characters. | forms.js:24:15:24:20 | values | DOM text |

javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/angular.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export class Foo {
2020
document.write(target.value); // NOT OK
2121
}
2222

23+
setOtherInput(e) {
24+
document.write(e.target.value); // OK
25+
document.write(e.value); // OK
26+
}
27+
2328
blah(form: NgForm) {
2429
document.write(form.value.foo); // NOT OK
2530
}

0 commit comments

Comments
 (0)