From af04c48744321a9dea5436969a096e45d26f0470 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Wed, 2 Feb 2022 18:31:39 -0500 Subject: [PATCH] Fix Catastophic Backtracking for Indirect Reference (#509) * Update regex to avoid catastrophic backtracking * Keep regex the same. Only run heuristic for lines that are less than 1k char since that better suits the intention of the heuristic --- detect_secrets/filters/heuristic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/detect_secrets/filters/heuristic.py b/detect_secrets/filters/heuristic.py index ea70c315b..48ab1cc45 100644 --- a/detect_secrets/filters/heuristic.py +++ b/detect_secrets/filters/heuristic.py @@ -165,6 +165,8 @@ def is_indirect_reference(line: str) -> bool: secret = request.headers['apikey'] """ + if len(line) > 1000: + return False return bool(_get_indirect_reference_regex().search(line))