Skip to content

Remove cartesian product in MkConstBindingPathComponentList #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -839,18 +839,18 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
then
exists(BindingPathComponentList tail |
mkBindingPathComponentList(getNextSkippingWhitespace(nextToken), tail, last) and
list = MkConstBindingPathComponentList(name, tail, first)
list = MkConstBindingPathComponentList(name, tail)
)
else (
list = MkConstBindingPathComponentList(name, MkEmptyBindingPathComponentList(), first) and
list = MkConstBindingPathComponentList(name, MkEmptyBindingPathComponentList()) and
last = name
)
)
}

private newtype TBindingPathComponentList =
MkEmptyBindingPathComponentList() or
MkConstBindingPathComponentList(NameToken headToken, BindingPathComponentList tail, Token source) {
MkConstBindingPathComponentList(NameToken headToken, BindingPathComponentList tail) {
exists(Token nextToken | nextToken = getNextSkippingWhitespace(headToken) |
if nextToken instanceof ForwardSlashToken or nextToken instanceof DotToken
then mkBindingPathComponentList(getNextSkippingWhitespace(nextToken), tail, _)
Expand All @@ -863,18 +863,16 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
this = MkEmptyBindingPathComponentList() and result = ""
or
exists(NameToken head, BindingPathComponentList tail |
this = MkConstBindingPathComponentList(head, tail, _) and
this = MkConstBindingPathComponentList(head, tail) and
if tail instanceof MkEmptyBindingPathComponentList
then result = head.toString()
else result = head.toString() + "/" + tail.toString()
)
}

NameToken getHead() { this = MkConstBindingPathComponentList(result, _, _) }
NameToken getHead() { this = MkConstBindingPathComponentList(result, _) }

BindingPathComponentList getTail() { this = MkConstBindingPathComponentList(_, result, _) }

Token getSource() { this = MkConstBindingPathComponentList(_, _, result) }
BindingPathComponentList getTail() { this = MkConstBindingPathComponentList(_, result) }
}

predicate mkAbsoluteBindingPath(Token first, BindingPath path, Token last) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import javascript
import advanced_security.javascript.frameworks.ui5.BindingStringParser as MakeBindingStringParser
import advanced_security.javascript.frameworks.ui5.UI5View

private class ContextBindingAttribute extends XmlAttribute {
ContextBindingAttribute() { this.getName() = "binding" }
Expand All @@ -15,8 +16,12 @@ private class ContextBindingAttribute extends XmlAttribute {
// TODO: add support for binding strings in strings such as `description: "Some {/description}"`
private newtype TBindingString =
TBindingStringFromLiteral(StringLiteral stringLiteral) { stringLiteral.getValue().matches("{%}") } or
TBindingStringFromXmlAttribute(XmlAttribute attribute) { attribute.getValue().matches("{%}") } or
TBindingStringFromXmlAttribute(XmlAttribute attribute) {
attribute.getLocation().getFile() instanceof XmlView and
attribute.getValue().matches("{%}")
} or
TBindingStringFromJsonProperty(JsonObject object, string propertyName) {
object.getFile() instanceof UI5View and
object.getPropStringValue(propertyName).matches("{%}")
} or
TBindingStringFromBindElementMethodCall(BindElementMethodCallNode bindElement) {
Expand Down
Loading