-
Notifications
You must be signed in to change notification settings - Fork 4
Model DF edge for sanitized HTML setContent->getContent #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
75557a1
Fix `setSanitizeContent` and `setSanitizeValue` name capitalization
mbaluda 98a9458
- Adds a test case for sanitizers
mbaluda 0176dd4
Merge branch 'main' into mbaluda/get-sanitized-content
mbaluda a71ec82
Models the flow between the `getContent` and `setContent` methods in …
mbaluda 7ef7a35
Update javascript/frameworks/ui5/lib/advanced_security/javascript/fra…
mbaluda 316aae3
Update expected file
mbaluda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
22 changes: 22 additions & 0 deletions
22
javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/UI5Xss.expected
This file contains hidden or 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,22 @@ | ||
| nodes | ||
| | webapp/controller/app.controller.js:10:17:10:27 | input: null | | ||
| | webapp/controller/app.controller.js:16:35:16:62 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:19:36:19:63 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | | ||
| | webapp/view/app.view.xml:8:5:8:79 | content={/output} | | ||
| edges | ||
| | webapp/controller/app.controller.js:10:17:10:27 | input: null | webapp/controller/app.controller.js:16:35:16:62 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:10:17:10:27 | input: null | webapp/controller/app.controller.js:19:36:19:63 | oModel. ... input') | | ||
| | webapp/controller/app.controller.js:10:17:10:27 | input: null | webapp/view/app.view.xml:5:5:7:28 | value={/input} | | ||
| | webapp/controller/app.controller.js:11:17:11:28 | output: null | webapp/view/app.view.xml:8:5:8:79 | content={/output} | | ||
| | webapp/controller/app.controller.js:13:26:13:45 | new JSONModel(oData) | webapp/view/app.view.xml:8:5:8:79 | content={/output} | | ||
| | webapp/controller/app.controller.js:19:36:19:63 | oModel. ... input') | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:10:17:10:27 | input: null | | ||
| | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:13:26:13:45 | new JSONModel(oData) | | ||
| | webapp/view/app.view.xml:8:5:8:79 | content={/output} | webapp/controller/app.controller.js:11:17:11:28 | output: null | | ||
| #select | ||
| | webapp/controller/app.controller.js:16:35:16:62 | oModel. ... input') | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:16:35:16:62 | oModel. ... input') | XSS vulnerability due to $@. | webapp/view/app.view.xml:5:5:7:28 | value={/input} | user-provided value | | ||
| | webapp/controller/app.controller.js:19:36:19:63 | oModel. ... input') | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:19:36:19:63 | oModel. ... input') | XSS vulnerability due to $@. | webapp/view/app.view.xml:5:5:7:28 | value={/input} | user-provided value | | ||
| | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | XSS vulnerability due to $@. | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | user-provided value | | ||
| | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | webapp/view/app.view.xml:5:5:7:28 | value={/input} | webapp/controller/app.controller.js:20:35:20:58 | unsanit ... ntent() | XSS vulnerability due to $@. | webapp/view/app.view.xml:5:5:7:28 | value={/input} | user-provided value | |
1 change: 1 addition & 0 deletions
1
javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/UI5Xss.qlref
This file contains hidden or 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 @@ | ||
| UI5Xss/UI5Xss.ql |
12 changes: 12 additions & 0 deletions
12
javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/package.json
This file contains hidden or 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,5 @@ | ||
| { | ||
| "name": "sap-ui5-xss", | ||
| "version": "1.0.0", | ||
| "main": "index.js" | ||
| } |
7 changes: 7 additions & 0 deletions
7
javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/ui5.yaml
This file contains hidden or 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,7 @@ | ||
| specVersion: '3.0' | ||
| metadata: | ||
| name: sap-ui5-xss | ||
| type: application | ||
| framework: | ||
| name: SAPUI5 | ||
| version: "1.115.0" |
32 changes: 32 additions & 0 deletions
32
...ks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/webapp/controller/app.controller.js
This file contains hidden or 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,32 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/mvc/Controller", | ||
| "sap/ui/model/json/JSONModel", | ||
| "sap/ui/core/HTML" | ||
| ], function (Controller, JSONModel, HTML) { | ||
| "use strict"; | ||
| return Controller.extend("codeql-sap-js.controller.app", { | ||
| onInit: function () { | ||
| var oData = { | ||
| input: null, | ||
| output: null, | ||
| }; | ||
| var oModel = new JSONModel(oData); | ||
| this.getView().setModel(oModel); | ||
|
|
||
| jQuery.sap.globalEval(oModel.getProperty('/input')); // UNSAFE: evaluating user input | ||
|
|
||
|
|
||
| var unsanitized = new HTML(); | ||
| unsanitized.setContent(oModel.getProperty('/input')); // UNSAFE: evaluating user input | ||
|
|
||
| jQuery.sap.globalEval(unsanitized.getContent()); // UNSAFE: setContent->getContent flow step | ||
|
|
||
|
|
||
| var sanitized = new HTML(); | ||
| sanitized.setSanitizeContent(true); | ||
| sanitized.setContent(oModel.getProperty('/input')); // SAFE: content is sanitized before eval | ||
| jQuery.sap.globalEval(sanitized.getContent()); // SAFE: content is sanitized before eval | ||
|
|
||
| let htmlSanitized = this.getView().byId("htmlSanitized"); | ||
| jQuery.sap.globalEval(htmlSanitized.getContent()); // SAFE: content is sanitized declaratively in the view | ||
| } | ||
| }); | ||
| } | ||
| ); | ||
21 changes: 21 additions & 0 deletions
21
javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/webapp/index.html
This file contains hidden or 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,21 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
|
|
||
| <meta charset="utf-8"> | ||
| <title>SAPUI5 XSS</title> | ||
| <script src="https://sdk.openui5.org/resources/sap-ui-core.js" | ||
| data-sap-ui-libs="sap.m" | ||
| data-sap-ui-onInit="module:codeql-sap-js/index" | ||
| data-sap-ui-resourceroots='{ | ||
| "codeql-sap-js": "./" | ||
| }'> | ||
| </script> | ||
| </head> | ||
|
|
||
| <body class="sapUiBody" id="content"> | ||
|
|
||
| </body> | ||
|
|
||
| </html> |
11 changes: 11 additions & 0 deletions
11
javascript/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/webapp/index.js
This file contains hidden or 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,11 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/mvc/XMLView" | ||
| ], function (XMLView) { | ||
| "use strict"; | ||
| XMLView.create({ | ||
| viewName: "codeql-sap-js.view.app" | ||
| }).then(function (oView) { | ||
| oView.placeAt("content"); | ||
| }); | ||
|
|
||
| }); |
5 changes: 5 additions & 0 deletions
5
...script/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/webapp/manifest.json
This file contains hidden or 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,5 @@ | ||
| { | ||
| "sap.app": { | ||
| "id": "sap-ui5-xss" | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...pt/frameworks/ui5/test/queries/UI5Xss/xss-html-control-sanitized/webapp/view/app.view.xml
This file contains hidden or 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,9 @@ | ||
| <mvc:View controllerName="codeql-sap-js.controller.app" | ||
| xmlns="sap.m" | ||
| xmlns:core="sap.ui.core" | ||
| xmlns:mvc="sap.ui.core.mvc"> | ||
| <Input placeholder="Enter Payload (will be sanitized)" | ||
| description="Try: <img src=x onerror=alert("XSS")>" | ||
| value="{/input}" /> <!--User input source sap.m.Input.value --> | ||
| <core:HTML id="htmlSanitized" content="{/output}" sanitizeContent="true"/> <!--sanitized XSS sink sap.ui.core.HTML.content --> | ||
| </mvc:View> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.