diff --git a/detect_secrets/plugins/slack.py b/detect_secrets/plugins/slack.py index 17f172334..b7c881ed9 100644 --- a/detect_secrets/plugins/slack.py +++ b/detect_secrets/plugins/slack.py @@ -26,12 +26,18 @@ class SlackDetector(RegexBasedDetector): re.compile(r'xox(?:a|b|p|o|s|r)-(?:\d+-)+[a-z0-9]+', flags=re.IGNORECASE), # Slack Webhooks re.compile( +<<<<<<< HEAD r'https://hooks.slack.com/services/T[a-zA-Z0-9_]+/B[a-zA-Z0-9_]+/[a-zA-Z0-9_]+', +======= + r""" + https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24} + """, +>>>>>>> Catch Slack webhook with 10 char (#325) flags=re.IGNORECASE | re.VERBOSE, ), ) - def verify(self, token, **kwargs): # pragma: no cover + def verify(self, token, *args, **kwargs): # pragma: no cover if token.startswith('https://hooks.slack.com/services/T'): response = requests.post( token, @@ -39,7 +45,14 @@ def verify(self, token, **kwargs): # pragma: no cover 'text': '', }, ) +<<<<<<< HEAD valid = response.text in ['missing_text_or_fallback_or_attachments', 'no_text'] +======= + valid = ( + response.text == 'missing_text_or_fallback_or_attachments' + or response.text == 'no_text' + ) +>>>>>>> Catch Slack webhook with 10 char (#325) else: response = requests.post( 'https://slack.com/api/auth.test', diff --git a/tests/plugins/slack_test.py b/tests/plugins/slack_test.py index af945c092..049ef2c00 100644 --- a/tests/plugins/slack_test.py +++ b/tests/plugins/slack_test.py @@ -33,6 +33,9 @@ class TestSlackDetector: ( 'https://hooks.slack.com/services/Txxxxxxxx/Bxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx' ), + ( + 'https://hooks.slack.com/services/Txxxxxxxx/Bxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx' + ), ], ) def test_analyze(self, file_content):