Skip to content

Commit 144d04f

Browse files
committed
JS: Add test exposing source location of attribute after line break
1 parent 7c6704a commit 144d04f

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

javascript/ql/test/library-tests/frameworks/Angular2/inline.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Input, Component } from '@angular/core';
55
template: `
66
<sink-component [sink7]="taint"></sink-component>
77
8-
\n<sink-component [sink7]="taint"></sink-component>
8+
\n<sink-component [sink9]="taint" [testAttr]="taint"></sink-component>
99
`
1010
})
1111
export class InlineComponent {

javascript/ql/test/library-tests/frameworks/Angular2/sink.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class SinkComponent {
1414
sink6: string;
1515
sink7: string;
1616
sink8: string;
17-
17+
sink9: string;
1818

1919
constructor(private sanitizer: DomSanitizer) {}
2020

@@ -27,5 +27,6 @@ export class SinkComponent {
2727
this.sanitizer.bypassSecurityTrustHtml(this.sink6);
2828
this.sanitizer.bypassSecurityTrustHtml(this.sink7);
2929
this.sanitizer.bypassSecurityTrustHtml(this.sink8);
30+
this.sanitizer.bypassSecurityTrustHtml(this.sink9);
3031
}
3132
}

javascript/ql/test/library-tests/frameworks/Angular2/test.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pipeClassRef
2323
| TestPipe.ts:4:8:9:1 | class T ... ;\\n }\\n} | source.component.html:6:19:6:26 | testPipe |
2424
taintFlow
2525
| inline.component.ts:15:22:15:29 | source() | sink.component.ts:28:48:28:57 | this.sink7 |
26+
| inline.component.ts:15:22:15:29 | source() | sink.component.ts:30:48:30:57 | this.sink9 |
2627
| source.component.ts:14:22:14:29 | source() | TestPipe.ts:6:31:6:35 | value |
2728
| source.component.ts:14:22:14:29 | source() | sink.component.ts:22:48:22:57 | this.sink1 |
2829
| source.component.ts:14:22:14:29 | source() | sink.component.ts:25:48:25:57 | this.sink4 |
@@ -31,3 +32,5 @@ taintFlow
3132
| source.component.ts:14:22:14:29 | source() | sink.component.ts:29:48:29:57 | this.sink8 |
3233
| source.component.ts:14:22:14:29 | source() | source.component.ts:20:48:20:48 | x |
3334
| source.component.ts:15:33:15:40 | source() | sink.component.ts:22:48:22:57 | this.sink1 |
35+
testAttrSourceLocation
36+
| inline.component.ts:8:43:8:61 | [testAttr]=taint | inline.component.ts:8:55:8:59 | <toplevel> |

javascript/ql/test/library-tests/frameworks/Angular2/test.ql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ class TaintConfig extends TaintTracking::Configuration {
2727
query predicate taintFlow(DataFlow::Node source, DataFlow::Node sink) {
2828
any(TaintConfig c).hasFlow(source, sink)
2929
}
30+
31+
query predicate testAttrSourceLocation(HTML::Attribute attrib, Angular2::TemplateTopLevel top) {
32+
attrib.getName() = "[testAttr]" and
33+
top = attrib.getCodeInAttribute()
34+
}

0 commit comments

Comments
 (0)