move Regex into a ParseRegExp file, and rename the class to RegExp

This commit is contained in:
erik-krogh
2023-03-17 18:20:12 +01:00
parent 556bb41999
commit 59cc90e547
10 changed files with 1102 additions and 1094 deletions

View File

@@ -13,7 +13,7 @@
import python
import semmle.python.regex
from Regex r, int offset
from RegExp r, int offset
where
r.escapingChar(offset) and
r.getChar(offset + 1) = "b" and

View File

@@ -13,7 +13,7 @@
import python
import semmle.python.regex
predicate duplicate_char_in_class(Regex r, string char) {
predicate duplicate_char_in_class(RegExp r, string char) {
exists(int i, int j, int x, int y, int start, int end |
i != x and
j != y and
@@ -36,7 +36,7 @@ predicate duplicate_char_in_class(Regex r, string char) {
)
}
from Regex r, string char
from RegExp r, string char
where duplicate_char_in_class(r, char)
select r,
"This regular expression includes duplicate character '" + char + "' in a set of characters."

View File

@@ -13,6 +13,6 @@
import python
import semmle.python.regex
from Regex r, string missing, string part
from RegExp r, string missing, string part
where r.getText().regexpMatch(".*\\(P<\\w+>.*") and missing = "?" and part = "named group"
select r, "Regular expression is missing '" + missing + "' in " + part + "."

View File

@@ -13,14 +13,14 @@
import python
import semmle.python.regex
predicate unmatchable_caret(Regex r, int start) {
predicate unmatchable_caret(RegExp r, int start) {
not r.getAMode() = "MULTILINE" and
not r.getAMode() = "VERBOSE" and
r.specialCharacter(start, start + 1, "^") and
not r.firstItem(start, start + 1)
}
from Regex r, int offset
from RegExp r, int offset
where unmatchable_caret(r, offset)
select r,
"This regular expression includes an unmatchable caret at offset " + offset.toString() + "."

View File

@@ -13,14 +13,14 @@
import python
import semmle.python.regex
predicate unmatchable_dollar(Regex r, int start) {
predicate unmatchable_dollar(RegExp r, int start) {
not r.getAMode() = "MULTILINE" and
not r.getAMode() = "VERBOSE" and
r.specialCharacter(start, start + 1, "$") and
not r.lastItem(start, start + 1)
}
from Regex r, int offset
from RegExp r, int offset
where unmatchable_dollar(r, offset)
select r,
"This regular expression includes an unmatchable dollar at offset " + offset.toString() + "."