From a0c1d3061d83dcaf4f6f2f871cdbc8cc12badb98 Mon Sep 17 00:00:00 2001 From: yoni Date: Sun, 9 Aug 2020 00:50:58 +0300 Subject: [PATCH 1/3] fix regex for longer slack webhook urls and added another error response --- detect_secrets/plugins/slack.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/detect_secrets/plugins/slack.py b/detect_secrets/plugins/slack.py index 15e494813..1d1527c32 100644 --- a/detect_secrets/plugins/slack.py +++ b/detect_secrets/plugins/slack.py @@ -18,9 +18,7 @@ class SlackDetector(RegexBasedDetector): re.compile(r'xox(?:a|b|p|o|s|r)-(?:\d+-)+[a-z0-9]+', flags=re.IGNORECASE), # Slack Webhooks re.compile( - r""" - https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24} - """, + r'https://hooks.slack.com/services/T[a-zA-Z0-9_]+/B[a-zA-Z0-9_]+/[a-zA-Z0-9_]+', flags=re.IGNORECASE | re.VERBOSE, ), ) @@ -33,7 +31,7 @@ def verify(self, token, **kwargs): # pragma: no cover 'text': '', }, ) - valid = response.text == 'missing_text_or_fallback_or_attachments' + valid = response.text in ['missing_text_or_fallback_or_attachments', 'no_text'] else: response = requests.post( 'https://slack.com/api/auth.test', From 91226b462f840588083f27c29e6bd5fb408d9754 Mon Sep 17 00:00:00 2001 From: droyni Date: Sun, 9 Aug 2020 01:39:19 +0300 Subject: [PATCH 2/3] added secret length to every secret attributes --- detect_secrets/core/potential_secret.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/detect_secrets/core/potential_secret.py b/detect_secrets/core/potential_secret.py index a8fca2d8c..abb2156b3 100644 --- a/detect_secrets/core/potential_secret.py +++ b/detect_secrets/core/potential_secret.py @@ -58,6 +58,7 @@ def __init__( def set_secret(self, secret): self.secret_hash = self.hash_secret(secret) + self.secret_len = len(secret) # Note: Originally, we never wanted to keep the secret value in memory, # after finding it in the codebase. However, to support verifiable @@ -86,6 +87,7 @@ def json(self): 'filename': self.filename, 'line_number': self.lineno, 'hashed_secret': self.secret_hash, + 'secret_len': self.secret_len, 'is_verified': self.is_verified, } From aa1e52b50f61793cd98faa0e07d6a89bd8143299 Mon Sep 17 00:00:00 2001 From: droyni Date: Sun, 9 Aug 2020 01:47:35 +0300 Subject: [PATCH 3/3] Revert "added secret length to every secret attributes" This reverts commit 91226b462f840588083f27c29e6bd5fb408d9754. --- detect_secrets/core/potential_secret.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/detect_secrets/core/potential_secret.py b/detect_secrets/core/potential_secret.py index abb2156b3..a8fca2d8c 100644 --- a/detect_secrets/core/potential_secret.py +++ b/detect_secrets/core/potential_secret.py @@ -58,7 +58,6 @@ def __init__( def set_secret(self, secret): self.secret_hash = self.hash_secret(secret) - self.secret_len = len(secret) # Note: Originally, we never wanted to keep the secret value in memory, # after finding it in the codebase. However, to support verifiable @@ -87,7 +86,6 @@ def json(self): 'filename': self.filename, 'line_number': self.lineno, 'hashed_secret': self.secret_hash, - 'secret_len': self.secret_len, 'is_verified': self.is_verified, }