File tree Expand file tree Collapse file tree 9 files changed +30
-15
lines changed
query-tests/Expressions/Regex Expand file tree Collapse file tree 9 files changed +30
-15
lines changed Original file line number Diff line number Diff line change @@ -497,8 +497,12 @@ abstract class RegexString extends Expr {
497
497
this .getChar ( endin ) = "}" and
498
498
end > start and
499
499
exists ( string multiples | multiples = this .getText ( ) .substring ( start + 1 , endin ) |
500
+ multiples .regexpMatch ( "0+" ) and maybe_empty = true
501
+ or
500
502
multiples .regexpMatch ( "0*,[0-9]*" ) and maybe_empty = true
501
503
or
504
+ multiples .regexpMatch ( "0*[1-9][0-9]*" ) and maybe_empty = false
505
+ or
502
506
multiples .regexpMatch ( "0*[1-9][0-9]*,[0-9]*" ) and maybe_empty = false
503
507
) and
504
508
not exists ( int mid |
@@ -643,9 +647,13 @@ abstract class RegexString extends Expr {
643
647
start = 0 and end = this .getText ( ) .length ( )
644
648
or
645
649
exists ( int y | this .lastPart ( start , y ) |
646
- this .emptyMatchAtEndGroup ( end , y ) or
647
- this .qualifiedItem ( end , y , true ) or
650
+ this .emptyMatchAtEndGroup ( end , y )
651
+ or
652
+ this .qualifiedItem ( end , y , true )
653
+ or
648
654
this .specialCharacter ( end , y , "$" )
655
+ or
656
+ y = end + 2 and this .escapingChar ( end ) and this .getChar ( end + 1 ) = "Z"
649
657
)
650
658
or
651
659
exists ( int x |
Original file line number Diff line number Diff line change 110
110
| ax{3,} | 5 | 6 |
111
111
| ax{3} | 0 | 1 |
112
112
| ax{3} | 1 | 2 |
113
- | ax{3} | 2 | 3 |
114
113
| ax{3} | 3 | 4 |
115
114
| ax{3} | 4 | 5 |
116
115
| ax{,3} | 0 | 1 |
Original file line number Diff line number Diff line change 84
84
| ax{3,} | last | 1 | 6 |
85
85
| ax{3,} | last | 5 | 6 |
86
86
| ax{3} | first | 0 | 1 |
87
+ | ax{3} | last | 1 | 2 |
88
+ | ax{3} | last | 1 | 5 |
87
89
| ax{3} | last | 4 | 5 |
88
90
| ax{,3} | first | 0 | 1 |
89
91
| ax{,3} | last | 0 | 1 |
Original file line number Diff line number Diff line change 11
11
| ^[A-Z_]+$(?<!not-this) | 1 | 8 | false |
12
12
| ax{01,3} | 1 | 8 | false |
13
13
| ax{3,} | 1 | 6 | false |
14
+ | ax{3} | 1 | 5 | false |
14
15
| ax{,3} | 1 | 6 | true |
Original file line number Diff line number Diff line change 207
207
| ax{3,} | sequence | 0 | 6 |
208
208
| ax{3} | char | 0 | 1 |
209
209
| ax{3} | char | 1 | 2 |
210
- | ax{3} | char | 2 | 3 |
211
210
| ax{3} | char | 3 | 4 |
212
211
| ax{3} | char | 4 | 5 |
212
+ | ax{3} | qualified | 1 | 5 |
213
213
| ax{3} | sequence | 0 | 5 |
214
214
| ax{,3} | char | 0 | 1 |
215
215
| ax{,3} | char | 1 | 2 |
Original file line number Diff line number Diff line change 1
- | test.py:41 :12:41 :18 | Str | This regular expression includes duplicate character 'A' in a set of characters. |
2
- | test.py:42 :12:42 :19 | Str | This regular expression includes duplicate character '0' in a set of characters. |
3
- | test.py:43 :12:43 :21 | Str | This regular expression includes duplicate character '-' in a set of characters. |
1
+ | test.py:46 :12:46 :18 | Str | This regular expression includes duplicate character 'A' in a set of characters. |
2
+ | test.py:47 :12:47 :19 | Str | This regular expression includes duplicate character '0' in a set of characters. |
3
+ | test.py:48 :12:48 :21 | Str | This regular expression includes duplicate character '-' in a set of characters. |
Original file line number Diff line number Diff line change 1
1
| test.py:4:12:4:19 | Str | This regular expression includes an unmatchable caret at offset 1. |
2
2
| test.py:5:12:5:23 | Str | This regular expression includes an unmatchable caret at offset 5. |
3
3
| test.py:6:12:6:21 | Str | This regular expression includes an unmatchable caret at offset 2. |
4
- | test.py:74 :12:74 :27 | Str | This regular expression includes an unmatchable caret at offset 8. |
4
+ | test.py:79 :12:79 :27 | Str | This regular expression includes an unmatchable caret at offset 8. |
Original file line number Diff line number Diff line change 1
1
| test.py:29:12:29:19 | Str | This regular expression includes an unmatchable dollar at offset 3. |
2
2
| test.py:30:12:30:23 | Str | This regular expression includes an unmatchable dollar at offset 3. |
3
3
| test.py:31:12:31:20 | Str | This regular expression includes an unmatchable dollar at offset 2. |
4
- | test.py:75 :12:75 :26 | Str | This regular expression includes an unmatchable dollar at offset 3. |
4
+ | test.py:80 :12:80 :26 | Str | This regular expression includes an unmatchable dollar at offset 3. |
Original file line number Diff line number Diff line change 30
30
re .compile (b"abc$ (?s)" )
31
31
re .compile (b"\[$] " )
32
32
33
- #Likely false positives for unmatchable dollar
34
- re .compile (b"[$] " )
35
- re .compile (b"\$ " )
36
- re .compile (b"abc$(?m)" )
37
- re .compile (b"abc$()" )
38
-
33
+ #Not unmatchable dollar
34
+ re .match (b"[$] " , b"$ " )
35
+ re .match (b"\$ " , b"$ " )
36
+ re .match (b"abc$(?m)" , b"abc" )
37
+ re .match (b"abc$()" , b"abc" )
38
+ re .match (b"((a$)|b)*" , b"bba" )
39
+ re .match (b"((a$)|b){4}" , b"bbba" ) # Inspired by FP report here: https://github.com/github/codeql/issues/2403
40
+ re .match (b"((a$).*)" , b"a" )
41
+ re .match ("(\Aab$|\Aba$)$\Z" , "ab" )
42
+ re .match (b"((a$\Z)|b){4}" , b"bbba" )
43
+ re .match (b"(a){00}b" , b"b" )
39
44
40
45
#Duplicate character in set
41
46
re .compile (b"[AA]" )
You can’t perform that action at this time.
0 commit comments