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 13
13
14
14
import semmle.code.java.security.SuspiciousRegexpRangeQuery
15
15
16
+ RegExpCharacterClass potentialMisparsedCharClass ( ) {
17
+ // nested char classes are currently misparsed
18
+ result .getAChild ( ) .( RegExpNormalChar ) .getValue ( ) = "["
19
+ }
20
+
16
21
from RegExpCharacterRange range , string reason
17
- where problem ( range , reason )
22
+ where
23
+ problem ( range , reason ) and
24
+ not range .getParent ( ) = potentialMisparsedCharClass ( )
18
25
select range , "Suspicious character range that " + reason + "."
Original file line number Diff line number Diff line change @@ -29,5 +29,9 @@ void test() {
29
29
Pattern overlapsWithClass1 = Pattern .compile ("[0-9\\ d]*" ); // NOT OK
30
30
31
31
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
32
36
}
33
37
}
You can’t perform that action at this time.
0 commit comments