Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc952bd

Browse files
committed
JS: Reorganize test a bit
1 parent 1ab36dc commit cc952bd

6 files changed

Lines changed: 65 additions & 65 deletions

File tree

javascript/ql/test/library-tests/frameworks/Angular2/foo.component.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Component } from "@angular/core";
2+
import { DomSanitizer } from '@angular/platform-browser';
3+
4+
@Component({
5+
selector: "sink-component",
6+
template: "not important"
7+
})
8+
export class SinkComponent {
9+
sink1: string;
10+
sink2: string;
11+
sink3: string;
12+
sink4: string;
13+
sink5: string;
14+
15+
constructor(private sanitizer: DomSanitizer) {}
16+
17+
foo() {
18+
this.sanitizer.bypassSecurityTrustHtml(this.sink1);
19+
this.sanitizer.bypassSecurityTrustHtml(this.sink2);
20+
this.sanitizer.bypassSecurityTrustHtml(this.sink3);
21+
this.sanitizer.bypassSecurityTrustHtml(this.sink4);
22+
this.sanitizer.bypassSecurityTrustHtml(this.sink5);
23+
}
24+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<sink-component
2+
[sink1]="taint"
3+
[sink2]="taint | unknownPipe"
4+
[sink3]="taint | unknownPipe:'safe'"
5+
[sink4]="taint | testPipe:'safe'"
6+
[sink5]="42 | testPipe:taint"
7+
></sink-component>
8+
9+
<div *ngFor="let element of taintedArray">
10+
<sink-component [sink1]="element"></sink-component>
11+
</div>
12+
13+
<div *ngFor="let element of safeArray">
14+
<sink-component [sink2]="element"></sink-component>
15+
</div>

javascript/ql/test/library-tests/frameworks/Angular2/foo.component.ts renamed to javascript/ql/test/library-tests/frameworks/Angular2/source.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Component } from "@angular/core";
22

33
@Component({
4-
selector: "foo-component",
5-
templateUrl: "./foo.component.html"
4+
selector: "source-component",
5+
templateUrl: "./source.component.html"
66
})
7-
export class Foo {
8-
foo: string;
7+
export class Source {
8+
taint: string;
99
taintedArray: string[];
1010
safeArray: string[];
1111

1212
constructor() {
13-
this.foo = source();
13+
this.taint = source();
1414
this.taintedArray = [...source()];
1515
this.safeArray = ['a', 'b'];
1616
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
pipeRef
2-
| foo.component.html:3:20:3:30 | unknownPipe |
3-
| foo.component.html:4:20:4:30 | unknownPipe |
4-
| foo.component.html:5:20:5:27 | testPipe |
5-
| foo.component.html:6:19:6:26 | testPipe |
2+
| source.component.html:3:22:3:32 | unknownPipe |
3+
| source.component.html:4:22:4:32 | unknownPipe |
4+
| source.component.html:5:22:5:29 | testPipe |
5+
| source.component.html:6:19:6:26 | testPipe |
66
pipeCall
7-
| foo.component.html:3:14:3:30 | foo \| unknownPipe |
8-
| foo.component.html:4:14:4:37 | foo \| u ... :'safe' |
9-
| foo.component.html:5:14:5:34 | foo \| t ... :'safe' |
10-
| foo.component.html:6:14:6:30 | 42 \| testPipe:foo |
7+
| source.component.html:3:14:3:32 | taint \| unknownPipe |
8+
| source.component.html:4:14:4:39 | taint \| ... :'safe' |
9+
| source.component.html:5:14:5:36 | taint \| ... :'safe' |
10+
| source.component.html:6:14:6:32 | 42 \| testPipe:taint |
1111
pipeCallArg
12-
| 0 | foo.component.html:3:14:3:16 | foo | foo.component.html:3:14:3:30 | foo \| unknownPipe |
13-
| 0 | foo.component.html:4:14:4:16 | foo | foo.component.html:4:14:4:37 | foo \| u ... :'safe' |
14-
| 0 | foo.component.html:5:14:5:16 | foo | foo.component.html:5:14:5:34 | foo \| t ... :'safe' |
15-
| 0 | foo.component.html:6:14:6:15 | 42 | foo.component.html:6:14:6:30 | 42 \| testPipe:foo |
16-
| 1 | foo.component.html:4:32:4:37 | 'safe' | foo.component.html:4:14:4:37 | foo \| u ... :'safe' |
17-
| 1 | foo.component.html:5:29:5:34 | 'safe' | foo.component.html:5:14:5:34 | foo \| t ... :'safe' |
18-
| 1 | foo.component.html:6:28:6:30 | foo | foo.component.html:6:14:6:30 | 42 \| testPipe:foo |
12+
| 0 | source.component.html:3:14:3:18 | taint | source.component.html:3:14:3:32 | taint \| unknownPipe |
13+
| 0 | source.component.html:4:14:4:18 | taint | source.component.html:4:14:4:39 | taint \| ... :'safe' |
14+
| 0 | source.component.html:5:14:5:18 | taint | source.component.html:5:14:5:36 | taint \| ... :'safe' |
15+
| 0 | source.component.html:6:14:6:15 | 42 | source.component.html:6:14:6:32 | 42 \| testPipe:taint |
16+
| 1 | source.component.html:4:34:4:39 | 'safe' | source.component.html:4:14:4:39 | taint \| ... :'safe' |
17+
| 1 | source.component.html:5:31:5:36 | 'safe' | source.component.html:5:14:5:36 | taint \| ... :'safe' |
18+
| 1 | source.component.html:6:28:6:32 | taint | source.component.html:6:14:6:32 | 42 \| testPipe:taint |
1919
pipeClass
2020
| TestPipe.ts:4:8:9:1 | class T ... ;\\n }\\n} |
2121
pipeClassRef
22-
| TestPipe.ts:4:8:9:1 | class T ... ;\\n }\\n} | foo.component.html:5:20:5:27 | testPipe |
23-
| TestPipe.ts:4:8:9:1 | class T ... ;\\n }\\n} | foo.component.html:6:19:6:26 | testPipe |
22+
| TestPipe.ts:4:8:9:1 | class T ... ;\\n }\\n} | source.component.html:5:22:5:29 | testPipe |
23+
| TestPipe.ts:4:8:9:1 | class T ... ;\\n }\\n} | source.component.html:6:19:6:26 | testPipe |
2424
taintFlow
25-
| foo.component.ts:13:20:13:27 | source() | other.component.ts:18:48:18:57 | this.prop1 |
26-
| foo.component.ts:13:20:13:27 | source() | other.component.ts:21:48:21:57 | this.prop4 |
27-
| foo.component.ts:13:20:13:27 | source() | other.component.ts:22:48:22:57 | this.prop5 |
28-
| foo.component.ts:14:33:14:40 | source() | other.component.ts:18:48:18:57 | this.prop1 |
25+
| source.component.ts:13:22:13:29 | source() | sink.component.ts:18:48:18:57 | this.sink1 |
26+
| source.component.ts:13:22:13:29 | source() | sink.component.ts:21:48:21:57 | this.sink4 |
27+
| source.component.ts:13:22:13:29 | source() | sink.component.ts:22:48:22:57 | this.sink5 |
28+
| source.component.ts:14:33:14:40 | source() | sink.component.ts:18:48:18:57 | this.sink1 |

0 commit comments

Comments
 (0)