Skip to content

Commit 9c7b40c

Browse files
committed
Fix BindingStringParser test
1 parent f3fcd63 commit 9c7b40c

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import javascript as stdlib
22

33
signature class BindingStringReaderSig {
44
string getBindingString();
5-
stdlib::Location getLocation();
5+
6+
stdlib::DbLocation getLocation();
67

78
// Get a dataflow node associated with the binding string, if any.
89
// Note that not all location from which we can obtain a binding string
@@ -51,7 +52,8 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
5152
value = ":"
5253
} or
5354
MkNumberToken(int begin, int end, string value, BindingStringReader reader) {
54-
value = reader.getBindingString().regexpFind("-?[1-9]\\d*(\\.\\d+)?((e|E)?(\\+|-)?\\d+)?", _, begin) and
55+
value =
56+
reader.getBindingString().regexpFind("-?[1-9]\\d*(\\.\\d+)?((e|E)?(\\+|-)?\\d+)?", _, begin) and
5557
begin + value.length() - 1 = end
5658
} or
5759
MkStringToken(int begin, int end, string value, BindingStringReader reader) {
@@ -95,9 +97,9 @@ module BindingStringParser<BindingStringReaderSig BindingStringReader> {
9597
.getBindingString()
9698
.regexpFind("(?:#|#@)?(?:[a-zA-Z][a-zA-Z0-9_]*|[a-zA-Z0-9][a-zA-Z0-9_]:[a-zA-Z0-9_]+)(?:\\([^\\)]*\\))?",
9799
_, begin) and
98-
begin + value.length() - 1 = end
100+
begin + value.length() - 1 = end and
99101
// exclude keyword
100-
and not value in ["true", "false", "null"]
102+
not value in ["true", "false", "null"]
101103
} or
102104
MkGreaterThanToken(int begin, int end, string value, BindingStringReader reader) {
103105
begin = reader.getBindingString().indexOf(">") and

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private class BindingStringReader extends TBindingString {
6060
)
6161
}
6262

63-
Location getLocation() {
63+
DbLocation getLocation() {
6464
exists(StringLiteral stringLiteral |
6565
this = TBindingStringFromLiteral(stringLiteral) and
6666
result = stringLiteral.getLocation()
@@ -221,10 +221,10 @@ private predicate earlyPropertyBinding(
221221
or
222222
// Composite binding https://ui5.sap.com/#/topic/a2fe8e763014477e87990ff50657a0d0
223223
exists(
224-
DataFlow::ObjectLiteralNode objectLiteral,
225-
DataFlow::ObjectLiteralNode valueLiteral, DataFlow::PropWrite partWrite,
226-
DataFlow::ArrayLiteralNode partsArray, DataFlow::ObjectLiteralNode partsElement,
227-
DataFlow::PropWrite pathWrite, DataFlow::ValueNode pathValue
224+
DataFlow::ObjectLiteralNode objectLiteral, DataFlow::ObjectLiteralNode valueLiteral,
225+
DataFlow::PropWrite partWrite, DataFlow::ArrayLiteralNode partsArray,
226+
DataFlow::ObjectLiteralNode partsElement, DataFlow::PropWrite pathWrite,
227+
DataFlow::ValueNode pathValue
228228
|
229229
objectLiteral.getAPropertyWrite() = bindingTarget and
230230
bindingTarget.writes(_, "value", binding) and

javascript/frameworks/ui5/test/lib/BindingStringParser/BindingStringParser.ql

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@ import advanced_security.javascript.frameworks.ui5.Bindings
33
import advanced_security.javascript.frameworks.ui5.BindingStringParser as Make
44

55
class BindingStringReader extends StringLiteral {
6-
BindingStringReader() {
7-
this.getValue().matches("{%}")
8-
}
6+
BindingStringReader() { this.getValue().matches("{%}") }
97

10-
string getBindingString() {
11-
result = this.getValue()
12-
}
13-
14-
DataFlow::Node getANode() {
15-
result.asExpr() = this
16-
}
8+
string getBindingString() { result = this.getValue() }
9+
10+
DataFlow::Node getANode() { result.asExpr() = this }
1711
}
1812

1913
module BindingStringParser = Make::BindingStringParser<BindingStringReader>;
2014

2115
from BindingStringParser::Binding binding
2216
select binding
23-
24-

0 commit comments

Comments
 (0)