Skip to content

Commit f2ef54b

Browse files
committed
Sync files
1 parent 4d6e995 commit f2ef54b

File tree

6 files changed

+126
-30
lines changed

6 files changed

+126
-30
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/AccessPathSyntax.qll

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*
55
* This file is used by the shared data flow library and by the JavaScript libraries
66
* (which does not use the shared data flow libraries).
7+
*
8+
* An access path consists of a `.`-separated list of components, which each consist
9+
* of an identifier optionally followed by a `[]`-enclosed argument.
10+
*
11+
* The argument can be be enclosed in single quotes. In this case, any character is allowed in-between
12+
* the single quotes, and two consecutive single quotes will be interpreted as an individual single quote.
713
*/
814

915
/**
@@ -116,7 +122,7 @@ private string getRawToken(AccessPath path, int n) {
116122
// Avoid splitting by '.' since tokens may contain dots, e.g. `Field[foo.Bar.x]`.
117123
// Instead use regexpFind to match valid tokens, and supplement with a final length
118124
// check (in `AccessPath.hasSyntaxError`) to ensure all characters were included in a token.
119-
result = path.regexpFind("\\w+(?:\\[[^\\]]*\\])?(?=\\.|$)", n, _)
125+
result = path.regexpFind("\\w+(?:\\[(?:[^'\\]]*|'(?:[^']|'')*')\\])?(?=\\.|$)", n, _)
120126
}
121127

122128
/**
@@ -152,7 +158,7 @@ class AccessPathToken extends string {
152158
AccessPathToken() { this = getRawToken(_, _) }
153159

154160
private string getPart(int part) {
155-
result = this.regexpCapture("([^\\[]+)(?:\\[([^\\]]*)\\])?", part)
161+
result = this.regexpCapture("([^\\[]+)(?:\\[(?:([^'\\]]*)|'((?:[^']|'')*)')\\])?", part)
156162
}
157163

158164
/** Gets the name of the token, such as `Member` from `Member[x]` */
@@ -162,10 +168,20 @@ class AccessPathToken extends string {
162168
* Gets the argument list, such as `1,2` from `Member[1,2]`,
163169
* or has no result if there are no arguments.
164170
*/
165-
string getArgumentList() { result = this.getPart(2) }
171+
string getArgumentList() {
172+
result = this.getPart(2) or result = this.getPart(3).regexpReplaceAll("''", "'")
173+
}
166174

167-
/** Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`. */
168-
string getArgument(int n) { result = this.getArgumentList().splitAt(",", n).trim() }
175+
/**
176+
* Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`, or
177+
* `foo,bar` from `Member['foo,bar']`.
178+
*/
179+
pragma[nomagic]
180+
string getArgument(int n) {
181+
result = this.getPart(2).splitAt(",", n).trim()
182+
or
183+
result = this.getPart(3).replaceAll("''", "'") and n = 0
184+
}
169185

170186
/** Gets the `n`th argument to this `name` token, such as `x` or `y` from `Member[x,y]`. */
171187
pragma[nomagic]

go/ql/lib/semmle/go/dataflow/internal/AccessPathSyntax.qll

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*
55
* This file is used by the shared data flow library and by the JavaScript libraries
66
* (which does not use the shared data flow libraries).
7+
*
8+
* An access path consists of a `.`-separated list of components, which each consist
9+
* of an identifier optionally followed by a `[]`-enclosed argument.
10+
*
11+
* The argument can be be enclosed in single quotes. In this case, any character is allowed in-between
12+
* the single quotes, and two consecutive single quotes will be interpreted as an individual single quote.
713
*/
814

915
/**
@@ -116,7 +122,7 @@ private string getRawToken(AccessPath path, int n) {
116122
// Avoid splitting by '.' since tokens may contain dots, e.g. `Field[foo.Bar.x]`.
117123
// Instead use regexpFind to match valid tokens, and supplement with a final length
118124
// check (in `AccessPath.hasSyntaxError`) to ensure all characters were included in a token.
119-
result = path.regexpFind("\\w+(?:\\[[^\\]]*\\])?(?=\\.|$)", n, _)
125+
result = path.regexpFind("\\w+(?:\\[(?:[^'\\]]*|'(?:[^']|'')*')\\])?(?=\\.|$)", n, _)
120126
}
121127

122128
/**
@@ -152,7 +158,7 @@ class AccessPathToken extends string {
152158
AccessPathToken() { this = getRawToken(_, _) }
153159

154160
private string getPart(int part) {
155-
result = this.regexpCapture("([^\\[]+)(?:\\[([^\\]]*)\\])?", part)
161+
result = this.regexpCapture("([^\\[]+)(?:\\[(?:([^'\\]]*)|'((?:[^']|'')*)')\\])?", part)
156162
}
157163

158164
/** Gets the name of the token, such as `Member` from `Member[x]` */
@@ -162,10 +168,20 @@ class AccessPathToken extends string {
162168
* Gets the argument list, such as `1,2` from `Member[1,2]`,
163169
* or has no result if there are no arguments.
164170
*/
165-
string getArgumentList() { result = this.getPart(2) }
171+
string getArgumentList() {
172+
result = this.getPart(2) or result = this.getPart(3).regexpReplaceAll("''", "'")
173+
}
166174

167-
/** Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`. */
168-
string getArgument(int n) { result = this.getArgumentList().splitAt(",", n).trim() }
175+
/**
176+
* Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`, or
177+
* `foo,bar` from `Member['foo,bar']`.
178+
*/
179+
pragma[nomagic]
180+
string getArgument(int n) {
181+
result = this.getPart(2).splitAt(",", n).trim()
182+
or
183+
result = this.getPart(3).replaceAll("''", "'") and n = 0
184+
}
169185

170186
/** Gets the `n`th argument to this `name` token, such as `x` or `y` from `Member[x,y]`. */
171187
pragma[nomagic]

java/ql/lib/semmle/code/java/dataflow/internal/AccessPathSyntax.qll

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*
55
* This file is used by the shared data flow library and by the JavaScript libraries
66
* (which does not use the shared data flow libraries).
7+
*
8+
* An access path consists of a `.`-separated list of components, which each consist
9+
* of an identifier optionally followed by a `[]`-enclosed argument.
10+
*
11+
* The argument can be be enclosed in single quotes. In this case, any character is allowed in-between
12+
* the single quotes, and two consecutive single quotes will be interpreted as an individual single quote.
713
*/
814

915
/**
@@ -116,7 +122,7 @@ private string getRawToken(AccessPath path, int n) {
116122
// Avoid splitting by '.' since tokens may contain dots, e.g. `Field[foo.Bar.x]`.
117123
// Instead use regexpFind to match valid tokens, and supplement with a final length
118124
// check (in `AccessPath.hasSyntaxError`) to ensure all characters were included in a token.
119-
result = path.regexpFind("\\w+(?:\\[[^\\]]*\\])?(?=\\.|$)", n, _)
125+
result = path.regexpFind("\\w+(?:\\[(?:[^'\\]]*|'(?:[^']|'')*')\\])?(?=\\.|$)", n, _)
120126
}
121127

122128
/**
@@ -152,7 +158,7 @@ class AccessPathToken extends string {
152158
AccessPathToken() { this = getRawToken(_, _) }
153159

154160
private string getPart(int part) {
155-
result = this.regexpCapture("([^\\[]+)(?:\\[([^\\]]*)\\])?", part)
161+
result = this.regexpCapture("([^\\[]+)(?:\\[(?:([^'\\]]*)|'((?:[^']|'')*)')\\])?", part)
156162
}
157163

158164
/** Gets the name of the token, such as `Member` from `Member[x]` */
@@ -162,10 +168,20 @@ class AccessPathToken extends string {
162168
* Gets the argument list, such as `1,2` from `Member[1,2]`,
163169
* or has no result if there are no arguments.
164170
*/
165-
string getArgumentList() { result = this.getPart(2) }
171+
string getArgumentList() {
172+
result = this.getPart(2) or result = this.getPart(3).regexpReplaceAll("''", "'")
173+
}
166174

167-
/** Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`. */
168-
string getArgument(int n) { result = this.getArgumentList().splitAt(",", n).trim() }
175+
/**
176+
* Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`, or
177+
* `foo,bar` from `Member['foo,bar']`.
178+
*/
179+
pragma[nomagic]
180+
string getArgument(int n) {
181+
result = this.getPart(2).splitAt(",", n).trim()
182+
or
183+
result = this.getPart(3).replaceAll("''", "'") and n = 0
184+
}
169185

170186
/** Gets the `n`th argument to this `name` token, such as `x` or `y` from `Member[x,y]`. */
171187
pragma[nomagic]

javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*
55
* This file is used by the shared data flow library and by the JavaScript libraries
66
* (which does not use the shared data flow libraries).
7+
*
8+
* An access path consists of a `.`-separated list of components, which each consist
9+
* of an identifier optionally followed by a `[]`-enclosed argument.
10+
*
11+
* The argument can be be enclosed in single quotes. In this case, any character is allowed in-between
12+
* the single quotes, and two consecutive single quotes will be interpreted as an individual single quote.
713
*/
814

915
/**
@@ -116,7 +122,7 @@ private string getRawToken(AccessPath path, int n) {
116122
// Avoid splitting by '.' since tokens may contain dots, e.g. `Field[foo.Bar.x]`.
117123
// Instead use regexpFind to match valid tokens, and supplement with a final length
118124
// check (in `AccessPath.hasSyntaxError`) to ensure all characters were included in a token.
119-
result = path.regexpFind("\\w+(?:\\[[^\\]]*\\])?(?=\\.|$)", n, _)
125+
result = path.regexpFind("\\w+(?:\\[(?:[^'\\]]*|'(?:[^']|'')*')\\])?(?=\\.|$)", n, _)
120126
}
121127

122128
/**
@@ -152,7 +158,7 @@ class AccessPathToken extends string {
152158
AccessPathToken() { this = getRawToken(_, _) }
153159

154160
private string getPart(int part) {
155-
result = this.regexpCapture("([^\\[]+)(?:\\[([^\\]]*)\\])?", part)
161+
result = this.regexpCapture("([^\\[]+)(?:\\[(?:([^'\\]]*)|'((?:[^']|'')*)')\\])?", part)
156162
}
157163

158164
/** Gets the name of the token, such as `Member` from `Member[x]` */
@@ -162,10 +168,20 @@ class AccessPathToken extends string {
162168
* Gets the argument list, such as `1,2` from `Member[1,2]`,
163169
* or has no result if there are no arguments.
164170
*/
165-
string getArgumentList() { result = this.getPart(2) }
171+
string getArgumentList() {
172+
result = this.getPart(2) or result = this.getPart(3).regexpReplaceAll("''", "'")
173+
}
166174

167-
/** Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`. */
168-
string getArgument(int n) { result = this.getArgumentList().splitAt(",", n).trim() }
175+
/**
176+
* Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`, or
177+
* `foo,bar` from `Member['foo,bar']`.
178+
*/
179+
pragma[nomagic]
180+
string getArgument(int n) {
181+
result = this.getPart(2).splitAt(",", n).trim()
182+
or
183+
result = this.getPart(3).replaceAll("''", "'") and n = 0
184+
}
169185

170186
/** Gets the `n`th argument to this `name` token, such as `x` or `y` from `Member[x,y]`. */
171187
pragma[nomagic]

python/ql/lib/semmle/python/dataflow/new/internal/AccessPathSyntax.qll

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*
55
* This file is used by the shared data flow library and by the JavaScript libraries
66
* (which does not use the shared data flow libraries).
7+
*
8+
* An access path consists of a `.`-separated list of components, which each consist
9+
* of an identifier optionally followed by a `[]`-enclosed argument.
10+
*
11+
* The argument can be be enclosed in single quotes. In this case, any character is allowed in-between
12+
* the single quotes, and two consecutive single quotes will be interpreted as an individual single quote.
713
*/
814

915
/**
@@ -116,7 +122,7 @@ private string getRawToken(AccessPath path, int n) {
116122
// Avoid splitting by '.' since tokens may contain dots, e.g. `Field[foo.Bar.x]`.
117123
// Instead use regexpFind to match valid tokens, and supplement with a final length
118124
// check (in `AccessPath.hasSyntaxError`) to ensure all characters were included in a token.
119-
result = path.regexpFind("\\w+(?:\\[[^\\]]*\\])?(?=\\.|$)", n, _)
125+
result = path.regexpFind("\\w+(?:\\[(?:[^'\\]]*|'(?:[^']|'')*')\\])?(?=\\.|$)", n, _)
120126
}
121127

122128
/**
@@ -152,7 +158,7 @@ class AccessPathToken extends string {
152158
AccessPathToken() { this = getRawToken(_, _) }
153159

154160
private string getPart(int part) {
155-
result = this.regexpCapture("([^\\[]+)(?:\\[([^\\]]*)\\])?", part)
161+
result = this.regexpCapture("([^\\[]+)(?:\\[(?:([^'\\]]*)|'((?:[^']|'')*)')\\])?", part)
156162
}
157163

158164
/** Gets the name of the token, such as `Member` from `Member[x]` */
@@ -162,10 +168,20 @@ class AccessPathToken extends string {
162168
* Gets the argument list, such as `1,2` from `Member[1,2]`,
163169
* or has no result if there are no arguments.
164170
*/
165-
string getArgumentList() { result = this.getPart(2) }
171+
string getArgumentList() {
172+
result = this.getPart(2) or result = this.getPart(3).regexpReplaceAll("''", "'")
173+
}
166174

167-
/** Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`. */
168-
string getArgument(int n) { result = this.getArgumentList().splitAt(",", n).trim() }
175+
/**
176+
* Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`, or
177+
* `foo,bar` from `Member['foo,bar']`.
178+
*/
179+
pragma[nomagic]
180+
string getArgument(int n) {
181+
result = this.getPart(2).splitAt(",", n).trim()
182+
or
183+
result = this.getPart(3).replaceAll("''", "'") and n = 0
184+
}
169185

170186
/** Gets the `n`th argument to this `name` token, such as `x` or `y` from `Member[x,y]`. */
171187
pragma[nomagic]

swift/ql/lib/codeql/swift/dataflow/internal/AccessPathSyntax.qll

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*
55
* This file is used by the shared data flow library and by the JavaScript libraries
66
* (which does not use the shared data flow libraries).
7+
*
8+
* An access path consists of a `.`-separated list of components, which each consist
9+
* of an identifier optionally followed by a `[]`-enclosed argument.
10+
*
11+
* The argument can be be enclosed in single quotes. In this case, any character is allowed in-between
12+
* the single quotes, and two consecutive single quotes will be interpreted as an individual single quote.
713
*/
814

915
/**
@@ -116,7 +122,7 @@ private string getRawToken(AccessPath path, int n) {
116122
// Avoid splitting by '.' since tokens may contain dots, e.g. `Field[foo.Bar.x]`.
117123
// Instead use regexpFind to match valid tokens, and supplement with a final length
118124
// check (in `AccessPath.hasSyntaxError`) to ensure all characters were included in a token.
119-
result = path.regexpFind("\\w+(?:\\[[^\\]]*\\])?(?=\\.|$)", n, _)
125+
result = path.regexpFind("\\w+(?:\\[(?:[^'\\]]*|'(?:[^']|'')*')\\])?(?=\\.|$)", n, _)
120126
}
121127

122128
/**
@@ -152,7 +158,7 @@ class AccessPathToken extends string {
152158
AccessPathToken() { this = getRawToken(_, _) }
153159

154160
private string getPart(int part) {
155-
result = this.regexpCapture("([^\\[]+)(?:\\[([^\\]]*)\\])?", part)
161+
result = this.regexpCapture("([^\\[]+)(?:\\[(?:([^'\\]]*)|'((?:[^']|'')*)')\\])?", part)
156162
}
157163

158164
/** Gets the name of the token, such as `Member` from `Member[x]` */
@@ -162,10 +168,20 @@ class AccessPathToken extends string {
162168
* Gets the argument list, such as `1,2` from `Member[1,2]`,
163169
* or has no result if there are no arguments.
164170
*/
165-
string getArgumentList() { result = this.getPart(2) }
171+
string getArgumentList() {
172+
result = this.getPart(2) or result = this.getPart(3).regexpReplaceAll("''", "'")
173+
}
166174

167-
/** Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`. */
168-
string getArgument(int n) { result = this.getArgumentList().splitAt(",", n).trim() }
175+
/**
176+
* Gets the `n`th argument to this token, such as `x` or `y` from `Member[x,y]`, or
177+
* `foo,bar` from `Member['foo,bar']`.
178+
*/
179+
pragma[nomagic]
180+
string getArgument(int n) {
181+
result = this.getPart(2).splitAt(",", n).trim()
182+
or
183+
result = this.getPart(3).replaceAll("''", "'") and n = 0
184+
}
169185

170186
/** Gets the `n`th argument to this `name` token, such as `x` or `y` from `Member[x,y]`. */
171187
pragma[nomagic]

0 commit comments

Comments
 (0)