File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
test/query-tests/security/CWE-020 Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1313
1414import semmle.code.java.security.SuspiciousRegexpRangeQuery
1515
16+ RegExpCharacterClass potentialMisparsedCharClass ( ) {
17+ // nested char classes are currently misparsed
18+ result .getAChild ( ) .( RegExpNormalChar ) .getValue ( ) = "["
19+ }
20+
1621from RegExpCharacterRange range , string reason
17- where problem ( range , reason )
22+ where
23+ problem ( range , reason ) and
24+ not range .getParent ( ) = potentialMisparsedCharClass ( )
1825select range , "Suspicious character range that " + reason + "."
Original file line number Diff line number Diff line change @@ -29,5 +29,9 @@ void test() {
2929 Pattern overlapsWithClass1 = Pattern .compile ("[0-9\\ d]*" ); // NOT OK
3030
3131 Pattern overlapsWithClass2 = Pattern .compile ("[\\ w,.-?:*+]*" ); // NOT OK
32+
33+ Pattern nested = Pattern .compile ("[[A-Za-z_][A-Za-z0-9._-]]*" ); // OK, the dash it at the end
34+
35+ Pattern octal = Pattern .compile ("[\000 -\037 \040 -\045 ]*" ); // OK
3236 }
3337}
You can’t perform that action at this time.
0 commit comments