From 44095a02ebcdd4d3d84b11b92d986d7a05d88058 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 11 Apr 2023 12:04:33 -0400 Subject: [PATCH] The colon equal sign regex should contain both colon and equal. Neither is optional. Specific for assignment and declaration in golang (#675) --- detect_secrets/plugins/keyword.py | 2 +- tests/plugins/keyword_test.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/detect_secrets/plugins/keyword.py b/detect_secrets/plugins/keyword.py index d5ee43014..e6c1366d7 100644 --- a/detect_secrets/plugins/keyword.py +++ b/detect_secrets/plugins/keyword.py @@ -98,7 +98,7 @@ FOLLOWED_BY_COLON_EQUAL_SIGNS_REGEX = re.compile( # e.g. my_password := "bar" or my_password := bar - r'{denylist}({closing})?{whitespace}:=?{whitespace}({quote}?)({secret})(\3)'.format( + r'{denylist}({closing})?{whitespace}:={whitespace}({quote}?)({secret})(\3)'.format( denylist=DENYLIST_REGEX, closing=CLOSING, quote=QUOTE, diff --git a/tests/plugins/keyword_test.py b/tests/plugins/keyword_test.py index ec5cf4ce2..003d8dd38 100644 --- a/tests/plugins/keyword_test.py +++ b/tests/plugins/keyword_test.py @@ -83,6 +83,8 @@ ('password := "somefakekey"', None), # 'fake' in the secret ('some_key = "real_secret"', None), # We cannot make 'key' a Keyword, too noisy) ('private_key "hopenobodyfindsthisone\';', None), # Double-quote does not match single-quote) + ('password: real_key', None), + ('password: "real_key"', None), (LONG_LINE, None), # Long line test ]