Skip to content

Commit d57bb93

Browse files
committed
Add resource root parsing
1 parent 13839a4 commit d57bb93

File tree

1 file changed

+44
-1
lines changed
  • javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5

1 file changed

+44
-1
lines changed

javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/UI5.qll

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
private import javascript
1+
private import javascript
22
private import DataFlow
3+
private import advanced_security.javascript.frameworks.ui5.JsonParser
34
private import semmle.javascript.security.dataflow.DomBasedXssCustomizations
45
private import advanced_security.javascript.frameworks.ui5.UI5View
56

@@ -11,6 +12,48 @@ module UI5 {
1112
exists(Project p | p.isInThisProject(f1) and p.isInThisProject(f2))
1213
}
1314

15+
bindingset[this]
16+
private class JsonStringReader extends string {
17+
bindingset[result]
18+
string read() { result = this }
19+
}
20+
21+
private newtype TResourceRoot =
22+
MkResourceRoot(string name, string path, string source) {
23+
exists(
24+
JsonParser<getAResourceRootConfig/0>::JsonObject config,
25+
JsonParser<getAResourceRootConfig/0>::JsonMember configEntry
26+
|
27+
source = config.getSource() and
28+
config.getAMember() = configEntry
29+
|
30+
name = configEntry.getKey() and
31+
path = configEntry.getValue().toString()
32+
)
33+
}
34+
35+
class ResourceRoot extends TResourceRoot, MkResourceRoot {
36+
string getName() { this = MkResourceRoot(result, _, _) }
37+
38+
string getPath() { this = MkResourceRoot(_, result, _) }
39+
40+
string getSource() { this = MkResourceRoot(_, _, result) }
41+
42+
string toString() { result = this.getName() + ": " + this.getPath() }
43+
}
44+
45+
private string getAResourceRootConfig() {
46+
result = any(SapUiCoreScript script).getAttributeByName("data-sap-ui-resourceroots").getValue()
47+
}
48+
49+
class SapUiCoreScript extends HTML::ScriptElement {
50+
SapUiCoreScript() { this.getSourcePath().matches("%/sap-ui-core.js") }
51+
52+
ResourceRoot getAResourceRoot() {
53+
result.getSource() = this.getAttributeByName("data-sap-ui-resourceroots").getValue()
54+
}
55+
}
56+
1457
class Project extends Folder {
1558
/**
1659
* An UI5 project root folder.

0 commit comments

Comments
 (0)