Skip to content

Commit 0ea21ec

Browse files
authored
Merge pull request #161 from advanced-security/lcartey/remove-binding-path-cartesian-product
Remove cartesian product in `MkConstBindingPathComponentList`
2 parents e715c35 + 58d6734 commit 0ea21ec

File tree

6 files changed

+28
-25
lines changed

6 files changed

+28
-25
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -839,18 +839,18 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
839839
then
840840
exists(BindingPathComponentList tail |
841841
mkBindingPathComponentList(getNextSkippingWhitespace(nextToken), tail, last) and
842-
list = MkConstBindingPathComponentList(name, tail, first)
842+
list = MkConstBindingPathComponentList(name, tail)
843843
)
844844
else (
845-
list = MkConstBindingPathComponentList(name, MkEmptyBindingPathComponentList(), first) and
845+
list = MkConstBindingPathComponentList(name, MkEmptyBindingPathComponentList()) and
846846
last = name
847847
)
848848
)
849849
}
850850

851851
private newtype TBindingPathComponentList =
852852
MkEmptyBindingPathComponentList() or
853-
MkConstBindingPathComponentList(NameToken headToken, BindingPathComponentList tail, Token source) {
853+
MkConstBindingPathComponentList(NameToken headToken, BindingPathComponentList tail) {
854854
exists(Token nextToken | nextToken = getNextSkippingWhitespace(headToken) |
855855
if nextToken instanceof ForwardSlashToken or nextToken instanceof DotToken
856856
then mkBindingPathComponentList(getNextSkippingWhitespace(nextToken), tail, _)
@@ -863,18 +863,16 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
863863
this = MkEmptyBindingPathComponentList() and result = ""
864864
or
865865
exists(NameToken head, BindingPathComponentList tail |
866-
this = MkConstBindingPathComponentList(head, tail, _) and
866+
this = MkConstBindingPathComponentList(head, tail) and
867867
if tail instanceof MkEmptyBindingPathComponentList
868868
then result = head.toString()
869869
else result = head.toString() + "/" + tail.toString()
870870
)
871871
}
872872

873-
NameToken getHead() { this = MkConstBindingPathComponentList(result, _, _) }
873+
NameToken getHead() { this = MkConstBindingPathComponentList(result, _) }
874874

875-
BindingPathComponentList getTail() { this = MkConstBindingPathComponentList(_, result, _) }
876-
877-
Token getSource() { this = MkConstBindingPathComponentList(_, _, result) }
875+
BindingPathComponentList getTail() { this = MkConstBindingPathComponentList(_, result) }
878876
}
879877

880878
predicate mkAbsoluteBindingPath(Token first, BindingPath path, Token last) {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import javascript
66
import advanced_security.javascript.frameworks.ui5.BindingStringParser as MakeBindingStringParser
7+
import advanced_security.javascript.frameworks.ui5.UI5View
78

89
private class ContextBindingAttribute extends XmlAttribute {
910
ContextBindingAttribute() { this.getName() = "binding" }
@@ -15,8 +16,12 @@ private class ContextBindingAttribute extends XmlAttribute {
1516
// TODO: add support for binding strings in strings such as `description: "Some {/description}"`
1617
private newtype TBindingString =
1718
TBindingStringFromLiteral(StringLiteral stringLiteral) { stringLiteral.getValue().matches("{%}") } or
18-
TBindingStringFromXmlAttribute(XmlAttribute attribute) { attribute.getValue().matches("{%}") } or
19+
TBindingStringFromXmlAttribute(XmlAttribute attribute) {
20+
attribute.getLocation().getFile() instanceof UI5View and
21+
attribute.getValue().matches("{%}")
22+
} or
1923
TBindingStringFromJsonProperty(JsonObject object, string propertyName) {
24+
object.getFile() instanceof UI5View and
2025
object.getPropStringValue(propertyName).matches("{%}")
2126
} or
2227
TBindingStringFromBindElementMethodCall(BindElementMethodCallNode bindElement) {
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
| test.html:5:11:5:31 | XML property binding: data-value to {/input} |
2-
| test.html:8:11:8:33 | XML property binding: data-content to {/input} |
31
| test.js:10:20:10:33 | Early JavaScript property binding: value to "{/root/name}" |
42
| test.js:21:28:21:34 | JavaScript context binding: oInput to "/root" |
53
| test.js:23:38:23:43 | Late JavaScript property binding: value to "name" |
64
| test.js:27:19:33:12 | Early JavaScript property binding: value to {\\n ... } |
75
| test.js:38:48:44:9 | Late JavaScript property binding: value to {\\n ... } |
86
| test.js:48:19:48:42 | Early JavaScript property binding: text to "{/#foo ... label}" |
9-
| test.json:5:9:22:9 | JSON property binding: items to {/Base} |
10-
| test.json:11:17:16:17 | JSON property binding: value to {input} |
11-
| test.json:17:17:20:17 | JSON property binding: content to {path : /input, formatter : ".valueFormatter"} |
12-
| test.xml:2:5:2:28 | XML property binding: value to {foo} |
13-
| test.xml:3:5:3:29 | XML property binding: value to {/foo} |
14-
| test.xml:4:5:4:34 | XML property binding: value to {model>foo} |
15-
| test.xml:5:5:5:35 | XML property binding: value to {model>/foo} |
16-
| test.xml:6:5:8:29 | XML context binding: binding to {/root} |
17-
| test.xml:6:5:8:29 | XML property binding: value to {foo} |
18-
| test.xml:9:5:9:70 | XML property binding: value to {path : foo, type : "sap.ui.model.type.String"} |
19-
| test.xml:10:5:10:71 | XML property binding: value to {path : /foo, type : "sap.ui.model.type.String"} |
20-
| test.xml:11:5:11:77 | XML property binding: value to {path : model>/foo, type : "sap.ui.model.type.String"} |
21-
| test.xml:12:5:12:76 | XML property binding: value to {path : model>foo, type : "sap.ui.model.type.String"} |
22-
| test.xml:14:5:22:45 | XML property binding: value to {parts : [{path : foo}, {path : bar/baz}, {path : quux}], formatter : "some.formatter"} |
7+
| test.view.html:5:11:5:31 | XML property binding: data-value to {/input} |
8+
| test.view.html:8:11:8:33 | XML property binding: data-content to {/input} |
9+
| test.view.json:5:9:22:9 | JSON property binding: items to {/Base} |
10+
| test.view.json:11:17:16:17 | JSON property binding: value to {input} |
11+
| test.view.json:17:17:20:17 | JSON property binding: content to {path : /input, formatter : ".valueFormatter"} |
12+
| test.view.xml:2:5:2:28 | XML property binding: value to {foo} |
13+
| test.view.xml:3:5:3:29 | XML property binding: value to {/foo} |
14+
| test.view.xml:4:5:4:34 | XML property binding: value to {model>foo} |
15+
| test.view.xml:5:5:5:35 | XML property binding: value to {model>/foo} |
16+
| test.view.xml:6:5:8:29 | XML context binding: binding to {/root} |
17+
| test.view.xml:6:5:8:29 | XML property binding: value to {foo} |
18+
| test.view.xml:9:5:9:70 | XML property binding: value to {path : foo, type : "sap.ui.model.type.String"} |
19+
| test.view.xml:10:5:10:71 | XML property binding: value to {path : /foo, type : "sap.ui.model.type.String"} |
20+
| test.view.xml:11:5:11:77 | XML property binding: value to {path : model>/foo, type : "sap.ui.model.type.String"} |
21+
| test.view.xml:12:5:12:76 | XML property binding: value to {path : model>foo, type : "sap.ui.model.type.String"} |
22+
| test.view.xml:14:5:22:45 | XML property binding: value to {parts : [{path : foo}, {path : bar/baz}, {path : quux}], formatter : "some.formatter"} |

0 commit comments

Comments
 (0)