Skip to content

Commit dbcdcbf

Browse files
committed
Port over UI5UnsafeLogAccess
1 parent 32aba1c commit dbcdcbf

File tree

3 files changed

+54
-43
lines changed

3 files changed

+54
-43
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import javascript
2+
import advanced_security.javascript.frameworks.ui5.dataflow.DataFlow
3+
import semmle.javascript.security.dataflow.LogInjectionQuery
4+
5+
module UI5UnsafeLogAccess implements DataFlow::ConfigSig {
6+
predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource }
7+
8+
predicate isBarrier(DataFlow::Node node) { LogInjectionConfig::isBarrier(node) }
9+
10+
predicate isSink(DataFlow::Node node) {
11+
node = ModelOutput::getASinkNode("ui5-log-injection").asSink()
12+
}
13+
}
14+
15+
private newtype TLogEntriesNode =
16+
TDataFlowNode(DataFlow::Node node) {
17+
node = ModelOutput::getATypeNode("SapLogEntries").getInducingNode()
18+
} or
19+
TUI5ControlNode(UI5Control control) { control.getImportPath() = "sap/ui/vk/Notifications" }
20+
21+
class LogEntriesNode extends TLogEntriesNode {
22+
DataFlow::Node asDataFlowNode() { this = TDataFlowNode(result) }
23+
24+
UI5Control asUI5ControlNode() { this = TUI5ControlNode(result) }
25+
26+
File getFile() {
27+
result = this.asDataFlowNode().getFile()
28+
or
29+
result = this.asUI5ControlNode().getView()
30+
}
31+
32+
string toString() {
33+
result = this.asDataFlowNode().toString()
34+
or
35+
result = this.asUI5ControlNode().toString()
36+
}
37+
38+
predicate hasLocationInfo(
39+
string filepath, int startline, int startcolumn, int endline, int endcolumn
40+
) {
41+
this.asDataFlowNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
42+
or
43+
this.asUI5ControlNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
44+
}
45+
}

javascript/frameworks/ui5/src/UI5LogInjection/UI5UnsafeLogAccess.ql

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,21 @@
1212

1313
import javascript
1414
import advanced_security.javascript.frameworks.ui5.dataflow.DataFlow
15-
import advanced_security.javascript.frameworks.ui5.dataflow.DataFlow::UI5PathGraph
16-
import semmle.javascript.security.dataflow.LogInjectionQuery as LogInjection
15+
import advanced_security.javascript.frameworks.ui5.UI5UnsafeLogAccessQuery
1716

18-
class UI5LogInjectionConfiguration extends LogInjection::LogInjectionConfiguration {
19-
override predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource }
17+
module UI5UnsafeLogAccessFlow = TaintTracking::Global<UI5UnsafeLogAccess>;
2018

21-
override predicate isSink(DataFlow::Node node) {
22-
node = ModelOutput::getASinkNode("ui5-log-injection").asSink()
23-
}
24-
}
19+
module UI5UnsafeLogAccessFlowUI5PathGraph =
20+
UI5PathGraph<UI5UnsafeLogAccessFlow::PathNode, UI5UnsafeLogAccessFlow::PathGraph>;
2521

26-
private newtype TLogEntriesNode =
27-
TDataFlowNode(DataFlow::Node node) {
28-
node = ModelOutput::getATypeNode("SapLogEntries").getInducingNode()
29-
} or
30-
TUI5ControlNode(UI5Control control) { control.getImportPath() = "sap/ui/vk/Notifications" }
31-
32-
class LogEntriesNode extends TLogEntriesNode {
33-
DataFlow::Node asDataFlowNode() { this = TDataFlowNode(result) }
34-
35-
UI5Control asUI5ControlNode() { this = TUI5ControlNode(result) }
36-
37-
File getFile() {
38-
result = this.asDataFlowNode().getFile()
39-
or
40-
result = this.asUI5ControlNode().getView()
41-
}
42-
43-
string toString() {
44-
result = this.asDataFlowNode().toString()
45-
or
46-
result = this.asUI5ControlNode().toString()
47-
}
48-
49-
predicate hasLocationInfo(
50-
string filepath, int startline, int startcolumn, int endline, int endcolumn
51-
) {
52-
this.asDataFlowNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
53-
or
54-
this.asUI5ControlNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
55-
}
56-
}
22+
import UI5UnsafeLogAccessFlowUI5PathGraph
5723

5824
from
59-
UI5LogInjectionConfiguration cfg, UI5PathNode source, UI5PathNode sink, UI5PathNode primarySource,
60-
LogEntriesNode logEntries
25+
UI5UnsafeLogAccessFlowUI5PathGraph::UI5PathNode source,
26+
UI5UnsafeLogAccessFlowUI5PathGraph::UI5PathNode sink,
27+
UI5UnsafeLogAccessFlowUI5PathGraph::UI5PathNode primarySource, LogEntriesNode logEntries
6128
where
62-
cfg.hasFlowPath(source.getPathNode(), sink.getPathNode()) and
29+
UI5UnsafeLogAccessFlow::flowPath(source.getPathNode(), sink.getPathNode()) and
6330
primarySource = source.getAPrimarySource() and
6431
inSameWebApp(source.getFile(), logEntries.getFile())
6532
select logEntries, primarySource, sink, "Accessed log entries depend on $@.", primarySource,

javascript/frameworks/ui5/test/queries/UI5LogInjection/log-entry-flows-to-sinks/UI5UnsafeLogAccess.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
WARNING: type 'LogInjectionConfiguration' has been deprecated and may be removed in future (UI5UnsafeLogAccess.ql:18,44-83)
21
nodes
32
| webapp/controller/app.controller.js:11:11:11:21 | input: null |
43
| webapp/controller/app.controller.js:17:13:17:48 | input |

0 commit comments

Comments
 (0)