Files
codeql/python/ql/src/Expressions/Regex/MissingPartSpecialGroup.ql
Joe Farebrother fa5b2ef794 Tag remaining high precision quality queries
Excluded queries that are python 2 specific; as well as the cyclic import queries
2025-06-19 14:08:07 +01:00

20 lines
628 B
Plaintext

/**
* @name Missing part of special group in regular expression
* @description Incomplete special groups are parsed as normal groups and are unlikely to match the intended strings.
* @kind problem
* @tags quality
* reliability
* correctness
* @problem.severity warning
* @sub-severity high
* @precision high
* @id py/regex/incomplete-special-group
*/
import python
import semmle.python.regex
from RegExp r, string missing, string part
where r.getText().regexpMatch(".*\\(P<\\w+>.*") and missing = "?" and part = "named group"
select r, "Regular expression is missing '" + missing + "' in " + part + "."