-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18458 from asgerf/js/angular2-xss-through-dom
JS: Add Angular2 DOM sources
- Loading branch information
Showing
8 changed files
with
124 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
javascript/ql/src/change-notes/2025-01-09-angular2-xss-through-dom.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: majorAnalysis | ||
--- | ||
* The `js/xss-through-dom` query now recognises sources of DOM input originating from Angular templates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/angular.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Component } from "@angular/core"; | ||
import { NgForm } from "@angular/forms"; | ||
|
||
@Component({ | ||
template: ` | ||
<input type="text" (input)="setInput1($event)"></input> | ||
<input type="text" (input)="setInput2($event.target)"></input> | ||
<input type="text" [(ngModel)]="field"></input> | ||
` | ||
}) | ||
export class Foo { | ||
field: string = ""; | ||
safeField: string = ""; | ||
|
||
setInput1(event) { | ||
document.write(event.target.value); // NOT OK | ||
} | ||
|
||
setInput2(target) { | ||
document.write(target.value); // NOT OK | ||
} | ||
|
||
setOtherInput(e) { | ||
document.write(e.target.value); // OK | ||
document.write(e.value); // OK | ||
} | ||
|
||
blah(form: NgForm) { | ||
document.write(form.value.foo); // NOT OK | ||
} | ||
|
||
useField() { | ||
document.write(this.field); // NOT OK | ||
document.write(this.safeField); // OK | ||
} | ||
} |