Skip to content

Commit 4fd8b1a

Browse files
committed
Ruby/Python re-introduce normalCharacterSequence
1 parent 9d9abaf commit 4fd8b1a

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

python/ql/lib/semmle/python/RegexTreeView.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ newtype TRegExpParent =
4040
TRegExpSpecialChar(Regex re, int start, int end) { re.specialCharacter(start, end, _) } or
4141
/** A normal character */
4242
TRegExpNormalChar(Regex re, int start, int end) {
43-
re.simpleCharacterSequence(start, end)
43+
re.normalCharacterSequence(start, end)
4444
or
4545
re.escapedCharacter(start, end) and
4646
not re.specialCharacter(start, end, _)

python/ql/lib/semmle/python/regex.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ abstract class RegexString extends Expr {
427427
}
428428

429429
predicate normalCharacter(int start, int end) {
430-
this.character(start, end) and
430+
this.simpleCharacter(start, end) and
431431
not this.specialCharacter(start, end, _)
432432
}
433433

@@ -447,16 +447,16 @@ abstract class RegexString extends Expr {
447447
}
448448

449449
/**
450-
* A sequence of 'simple' characters.
450+
* A sequence of 'normal' characters.
451451
*/
452-
predicate simpleCharacterSequence(int start, int end) {
453-
// a simple character inside a character set is interpreted on its own
454-
this.simpleCharacter(start, end) and
452+
predicate normalCharacterSequence(int start, int end) {
453+
// a normal character inside a character set is interpreted on its own
454+
this.normalCharacter(start, end) and
455455
this.inCharSet(start)
456456
or
457-
// a maximal run of simple characters is considered as one constant
457+
// a maximal run of normal characters is considered as one constant
458458
exists(int s, int e |
459-
e = max(int i | simpleCharacterRun(s, i)) and
459+
e = max(int i | normalCharacterRun(s, i)) and
460460
not this.inCharSet(s)
461461
|
462462
// 'abc' can be considered one constant, but
@@ -474,17 +474,17 @@ abstract class RegexString extends Expr {
474474
)
475475
}
476476

477-
private predicate simpleCharacterRun(int start, int end) {
477+
private predicate normalCharacterRun(int start, int end) {
478478
(
479-
simpleCharacterRun(start, end - 1)
479+
normalCharacterRun(start, end - 1)
480480
or
481481
start = end - 1 and not normalCharacter(start - 1, start)
482482
) and
483-
this.simpleCharacter(end - 1, end)
483+
this.normalCharacter(end - 1, end)
484484
}
485485

486486
private predicate characterItem(int start, int end) {
487-
this.simpleCharacterSequence(start, end) or
487+
this.normalCharacterSequence(start, end) or
488488
this.escapedCharacter(start, end) or
489489
this.specialCharacter(start, end, _)
490490
}

ruby/ql/lib/codeql/ruby/security/performance/ParseRegExp.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,16 @@ class RegExp extends AST::RegExpLiteral {
402402
}
403403

404404
/**
405-
* A sequence of 'simple' characters.
405+
* A sequence of 'normal' characters.
406406
*/
407-
predicate simpleCharacterSequence(int start, int end) {
408-
// a simple character inside a character set is interpreted on its own
409-
this.simpleCharacter(start, end) and
407+
predicate normalCharacterSequence(int start, int end) {
408+
// a normal character inside a character set is interpreted on its own
409+
this.normalCharacter(start, end) and
410410
this.inCharSet(start)
411411
or
412-
// a maximal run of simple characters is considered as one constant
412+
// a maximal run of normal characters is considered as one constant
413413
exists(int s, int e |
414-
e = max(int i | simpleCharacterRun(s, i)) and
414+
e = max(int i | normalCharacterRun(s, i)) and
415415
not this.inCharSet(s)
416416
|
417417
// 'abc' can be considered one constant, but
@@ -429,17 +429,17 @@ class RegExp extends AST::RegExpLiteral {
429429
)
430430
}
431431

432-
private predicate simpleCharacterRun(int start, int end) {
432+
private predicate normalCharacterRun(int start, int end) {
433433
(
434-
simpleCharacterRun(start, end - 1)
434+
normalCharacterRun(start, end - 1)
435435
or
436436
start = end - 1 and not normalCharacter(start - 1, start)
437437
) and
438-
this.simpleCharacter(end - 1, end)
438+
this.normalCharacter(end - 1, end)
439439
}
440440

441441
private predicate characterItem(int start, int end) {
442-
this.simpleCharacterSequence(start, end) or
442+
this.normalCharacterSequence(start, end) or
443443
this.escapedCharacter(start, end) or
444444
this.specialCharacter(start, end, _)
445445
}

ruby/ql/lib/codeql/ruby/security/performance/RegExpTreeView.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ newtype TRegExpParent =
229229
TRegExpGroup(RegExp re, int start, int end) { re.group(start, end) } or
230230
TRegExpSpecialChar(RegExp re, int start, int end) { re.specialCharacter(start, end, _) } or
231231
TRegExpNormalChar(RegExp re, int start, int end) {
232-
re.simpleCharacterSequence(start, end)
232+
re.normalCharacterSequence(start, end)
233233
or
234234
re.escapedCharacter(start, end) and
235235
not re.specialCharacter(start, end, _)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy