mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
filter out potential misparses from java/suspicious-regexp-range
This commit is contained in:
@@ -13,6 +13,13 @@
|
||||
|
||||
import semmle.code.java.security.SuspiciousRegexpRangeQuery
|
||||
|
||||
RegExpCharacterClass potentialMisparsedCharClass() {
|
||||
// nested char classes are currently misparsed
|
||||
result.getAChild().(RegExpNormalChar).getValue() = "["
|
||||
}
|
||||
|
||||
from RegExpCharacterRange range, string reason
|
||||
where problem(range, reason)
|
||||
where
|
||||
problem(range, reason) and
|
||||
not range.getParent() = potentialMisparsedCharClass()
|
||||
select range, "Suspicious character range that " + reason + "."
|
||||
|
||||
@@ -29,5 +29,9 @@ class SuspiciousRegexpRange {
|
||||
Pattern overlapsWithClass1 = Pattern.compile("[0-9\\d]*"); // NOT OK
|
||||
|
||||
Pattern overlapsWithClass2 = Pattern.compile("[\\w,.-?:*+]*"); // NOT OK
|
||||
|
||||
Pattern nested = Pattern.compile("[[A-Za-z_][A-Za-z0-9._-]]*"); // OK, the dash it at the end
|
||||
|
||||
Pattern octal = Pattern.compile("[\000-\037\040-\045]*"); // OK
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user