mirror of
https://github.com/github/codeql.git
synced 2026-02-21 09:23:40 +01:00
26 lines
821 B
Plaintext
26 lines
821 B
Plaintext
/**
|
|
* @name Unmatchable caret in regular expression
|
|
* @description If a caret assertion '^' appears in a regular expression after 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-caret
|
|
* @tags reliability
|
|
* correctness
|
|
* regular-expressions
|
|
* external/cwe/cwe-561
|
|
* @precision very-high
|
|
*/
|
|
|
|
import javascript
|
|
|
|
from RegExpCaret caret, RegExpTerm t
|
|
where
|
|
caret.isPartOfRegExpLiteral() and
|
|
t = caret.getPredecessor+() and
|
|
not t.isNullable() and
|
|
// conservative handling of multi-line regular expressions
|
|
not caret.getLiteral().isMultiline()
|
|
select caret, "This assertion can never match."
|