From d412c7d0f165c622ac76fd28105f18bac636e506 Mon Sep 17 00:00:00 2001 From: Robin Bowes Date: Mon, 5 Jun 2023 18:33:15 +0100 Subject: [PATCH] Do not require leading quotes for high-entropy strings --- detect_secrets/plugins/high_entropy_strings.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/detect_secrets/plugins/high_entropy_strings.py b/detect_secrets/plugins/high_entropy_strings.py index 5a352cb19..a2ca65ded 100644 --- a/detect_secrets/plugins/high_entropy_strings.py +++ b/detect_secrets/plugins/high_entropy_strings.py @@ -26,9 +26,8 @@ def __init__(self, charset: str, limit: float) -> None: self.charset = charset self.entropy_limit = limit - # We require quoted strings to reduce noise. # NOTE: We need this to be a capturing group, so back-reference can work. - self.regex = re.compile(r'([\'"])([{}]+)(\1)'.format(re.escape(charset))) + self.regex = re.compile(r'([\'"]?)([{}]+)(\1)'.format(re.escape(charset))) def analyze_string(self, string: str) -> Generator[str, None, None]: for result in self.regex.findall(string):