forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnmatchableDollar.ql
More file actions
23 lines (21 loc) · 801 Bytes
/
UnmatchableDollar.ql
File metadata and controls
23 lines (21 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* @name Unmatchable dollar in regular expression
* @description If a dollar assertion '$' appears in a regular expression before another term that
* cannot match the empty string, then this assertion can never match, so the entire
* regular expression cannot match any string.
* @kind problem
* @problem.severity error
* @id js/regex/unmatchable-dollar
* @tags reliability
* correctness
* regular-expressions
* external/cwe/cwe-561
* @precision very-high
*/
import javascript
from RegExpDollar dollar, RegExpTerm t
where t = dollar.getSuccessor+() and
not t.isNullable() and
// conservative handling of multi-line regular expressions
not dollar.getLiteral().isMultiline()
select dollar, "This assertion can never match."