Why it matters
A pattern with nested quantifiers can hold the event loop for seconds per request.
How to fix it
Escape the value before compiling it, or match with a plain string method such as includes.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
const express = require("express");
const app = express();
app.get("/search", (req, res) => {
const matcher = new RegExp(req.query.q, "i");
res.json(app.locals.titles.filter((title) => matcher.test(title)));
});const express = require("express");
const app = express();
app.get("/search", (req, res) => {
const needle = String(req.query.q).toLowerCase();
res.json(app.locals.titles.filter((title) => title.toLowerCase().includes(needle)));
});What TrustIvan reads
Runs on repository scans of JavaScript source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- NoSQL injection from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-nosql-injection - Child process exec interpolation (JavaScript)
JavaScriptSeverity: Medium
trustivan-javascript-child-process-exec-interpolation - Open redirect from request input (JavaScript)
JavaScriptSeverity: Medium
trustivan-javascript-taint-open-redirect - React dangerous HTML (JavaScript)
JavaScriptSeverity: Medium
trustivan-javascript-react-dangerous-html - Code injection from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-code-injection - TLS verification disabled (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-tls-verification-disabled
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation