Skip to content

Commit 3240d45

Browse files
committed
Document code with docstrings and alert messages
1 parent 614220a commit 3240d45

File tree

4 files changed

+20
-34
lines changed

4 files changed

+20
-34
lines changed

javascript/frameworks/ui5/test/models/dangerous_write_to_html_content/dynamicWriteToHtmlContent.ql

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| webapp/controller/app.controller.js:18:9:18:27 | htmlControl.content | Content write to an HTML element |
2-
| webapp/controller/app.controller.js:21:32:21:56 | inputRe ... Value() | Content write to an HTML element |
3-
| webapp/controller/app.controller.js:30:20:30:60 | `<div>$ ... </div>` | Content write to an HTML element |
4-
| webapp/controller/app.controller.js:36:32:36:56 | inputRe ... Value() | Content write to an HTML element |
5-
| webapp/controller/app.controller.js:41:33:41:57 | inputRe ... Value() | Content write to an HTML element |
1+
| webapp/controller/app.controller.js:18:9:18:27 | htmlControl.content | Dynamic write to content of an HTML control without the use of a binding path. |
2+
| webapp/controller/app.controller.js:21:32:21:56 | inputRe ... Value() | Dynamic write to content of an HTML control without the use of a binding path. |
3+
| webapp/controller/app.controller.js:30:20:30:60 | `<div>$ ... </div>` | Dynamic write to content of an HTML control without the use of a binding path. |
4+
| webapp/controller/app.controller.js:36:32:36:56 | inputRe ... Value() | Dynamic write to content of an HTML control without the use of a binding path. |
5+
| webapp/controller/app.controller.js:41:33:41:57 | inputRe ... Value() | Dynamic write to content of an HTML control without the use of a binding path. |

javascript/frameworks/ui5/test/models/dynamic_write_to_html_content/dynamicWriteToHtmlContent.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import javascript
22
import advanced_security.javascript.frameworks.ui5.UI5XssQuery
33

44
from DynamicallySetElementValueOfHTML htmlContent
5-
select htmlContent, "Content write to an HTML element "
5+
select htmlContent, "Dynamic write to content of an HTML control without the use of a binding path."
Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,55 @@
11
sap.ui.define(
2-
[
3-
"sap/ui/core/mvc/Controller",
4-
"sap/m/Input",
5-
"sap/m/Button",
6-
"sap/m/VBox",
7-
"sap/ui/core/HTML",
8-
],
9-
function (Controller, Input, Button, VBox, HTML) {
2+
["sap/ui/core/mvc/Controller", "sap/ui/core/HTML"],
3+
function (Controller, HTML) {
104
"use strict";
115
return Controller.extend("codeql-sap-js.controller.app", {
126
onInit: function () {
137
let inputReference = this.getView().byId("unit-test-target1");
148
let htmlControl = this.getView().byId("htmlControl");
159

16-
/* ========== 1. Input value piped into static HTML, via a reference ========== */
10+
/* ========== 1. UNSAFE: Input value piped into a reference to a static HTML, via a reference ========== */
1711
/* 1-1. Value directly set to `HTML.content` */
18-
htmlControl.content = inputReference.getValue();
12+
htmlControl.content = inputReference.getValue(); // UNSAFE: property `content` set with an input value of a reference to a static value
1913

2014
/* 1-2. Value set by `HTML.setContent(content)` */
21-
htmlControl.setContent(inputReference.getValue());
15+
htmlControl.setContent(inputReference.getValue()); // UNSAFE: property `content` set with an input value of a reference to a static value
2216
},
2317

2418
doSomething1: function () {
2519
let inputReference = this.getView().byId("unit-test-target1");
2620

27-
/* ========== 2. Input value piped into dynamic HTML, instantiated and placed on-demand ========== */
21+
/* ========== 2. UNSAFE: Input value piped into dynamic HTML, instantiated and placed on-demand ========== */
2822
/* 2-1. Value passed to the argument of the constructor call */
2923
let htmlControl1 = new HTML({
30-
content: `<div>${inputReference.getValue()}</div>`,
24+
content: `<div>${inputReference.getValue()}</div>`, // UNSAFE: property `content` set with an input value, control later placed at DOM
3125
});
3226
htmlControl1.placeAt("HTMLPlaceholder");
3327

3428
/* 2-2. Value directly set to `HTML.content` */
3529
let htmlControl2 = new HTML();
36-
htmlControl2.content = inputReference.getValue();
30+
htmlControl2.content = inputReference.getValue(); // UNSAFE: property `content` set with an input value, control later placed at DOM
3731
htmlControl2.placeAt("HTMLPlaceholder");
3832

3933
/* 2-3. Value set by `HTML.setContent(content)` */
4034
let htmlControl3 = new HTML();
41-
htmlControl3.setContent(inputReference.getValue());
35+
htmlControl3.setContent(inputReference.getValue()); // UNSAFE: property `content` set with an input value, control later placed at DOM
4236
htmlControl3.placeAt("HTMLPlaceholder");
4337
},
4438

4539
doSomething2: function () {
4640
let inputReference = this.getView().byId("unit-test-target1");
4741

48-
/* ========== 2. Input value piped into dynamic HTML, instantiated and placed on-demand ========== */
49-
/* 2-1. Value passed to the argument of the constructor call */
42+
/* ========== 3. SAFE: Input value piped into dynamic HTML, instantiated but not placed anywhere in the DOM ========== */
5043
let htmlControl1 = new HTML({
51-
content: `<div>${inputReference.getValue()}</div>`,
44+
content: `<div>${inputReference.getValue()}</div>`, // SAFE: property `content` set with an input value but control not placed anywhere
5245
});
5346

54-
/* 2-2. Value directly set to `HTML.content` */
5547
let htmlControl2 = new HTML();
56-
htmlControl2.content = inputReference.getValue();
48+
htmlControl2.content = inputReference.getValue(); // SAFE: property `content` set with an input value but control not placed anywhere
5749

58-
/* 2-3. Value set by `HTML.setContent(content)` */
5950
let htmlControl3 = new HTML();
60-
htmlControl3.setContent(inputReference.getValue());
61-
}
51+
htmlControl3.setContent(inputReference.getValue()); // SAFE: property `content` set with an input value but control not placed anywhere
52+
},
6253
});
6354
}
6455
);

0 commit comments

Comments
 (0)