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: request.args, request.form, request.GET, request.POST, request.headers and the like, directly or through a local variable of the same function.
From the rule's source, regex_backtracking.rs.
import refrom flask import request def view(): name = request.args.get("name") return re.match(r"^(\w+\s?)*$", name)tx0 reports: request input from `request.args.get( def local(text): return re.match(r"^(\w+\s?)*$", text) Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:regex-backtracking-on-input" = "error"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/python:regex-backtracking-on-input] reason="..."tx0 explain tx0/python:regex-backtracking-on-input shows the same in the terminal. Found a false positive? Report it.