A regular expression that takes super-linear time is matched against request input
What it finds
A pattern that takes exponential or polynomial time, as the two rules above find, matched against request input: req.query, req.body, req.params, req.headers, the location of the page and the like, directly or through a local variable of the same function.
From the rule's source, regex_backtracking.rs.
const NAME = /^(\w+\s?)*$/;tx0 reports: request input from req.query.namefunction handler(req, res) { const name = req.query.name; return NAME.test(name);}function local(text) { return /^(a|a)*$/.test(text);} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:regex-backtracking-on-input" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:regex-backtracking-on-input] reason="..."tx0 explain tx0/ts:regex-backtracking-on-input shows the same in the terminal. Found a false positive? Report it.