|
1 | 1 | 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) { |
10 | 4 | "use strict"; |
11 | 5 | return Controller.extend("codeql-sap-js.controller.app", { |
12 | 6 | onInit: function () { |
13 | 7 | let inputReference = this.getView().byId("unit-test-target1"); |
14 | 8 | let htmlControl = this.getView().byId("htmlControl"); |
15 | 9 |
|
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 ========== */ |
17 | 11 | /* 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 |
19 | 13 |
|
20 | 14 | /* 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 |
22 | 16 | }, |
23 | 17 |
|
24 | 18 | doSomething1: function () { |
25 | 19 | let inputReference = this.getView().byId("unit-test-target1"); |
26 | 20 |
|
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 ========== */ |
28 | 22 | /* 2-1. Value passed to the argument of the constructor call */ |
29 | 23 | 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 |
31 | 25 | }); |
32 | 26 | htmlControl1.placeAt("HTMLPlaceholder"); |
33 | 27 |
|
34 | 28 | /* 2-2. Value directly set to `HTML.content` */ |
35 | 29 | 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 |
37 | 31 | htmlControl2.placeAt("HTMLPlaceholder"); |
38 | 32 |
|
39 | 33 | /* 2-3. Value set by `HTML.setContent(content)` */ |
40 | 34 | 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 |
42 | 36 | htmlControl3.placeAt("HTMLPlaceholder"); |
43 | 37 | }, |
44 | 38 |
|
45 | 39 | doSomething2: function () { |
46 | 40 | let inputReference = this.getView().byId("unit-test-target1"); |
47 | 41 |
|
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 ========== */ |
50 | 43 | 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 |
52 | 45 | }); |
53 | 46 |
|
54 | | - /* 2-2. Value directly set to `HTML.content` */ |
55 | 47 | 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 |
57 | 49 |
|
58 | | - /* 2-3. Value set by `HTML.setContent(content)` */ |
59 | 50 | 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 | + }, |
62 | 53 | }); |
63 | 54 | } |
64 | 55 | ); |
0 commit comments