Skip to content

Commit

Permalink
↪️Merge pull request #233 from Patil2099/master
Browse files Browse the repository at this point in the history
Added Verifiability Slack
  • Loading branch information
OiCMudkips authored Sep 4, 2019
2 parents f996791 + 2dd2735 commit c38a437
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions detect_secrets/plugins/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@ class SlackDetector(RegexBasedDetector):
),
)

def verify(self, token, **kwargs): # pragma: no cover
response = requests.post(
'https://slack.com/api/auth.test',
data={
'token': token,
},
).json()

return VerifiedResult.VERIFIED_TRUE if response['ok'] \
def verify(self, token, **kwargs): # pragma: no cover
if token.startswith('https://hooks.slack.com/services/T'):
response = requests.post(
token,
json={
'text': '',
},
)
valid = response.text == "missing_text_or_fallback_or_attachments"
else:
response = requests.post(
'https://slack.com/api/auth.test',
data={
'token': token,
},
).json()
valid = response['ok']

return (
VerifiedResult.VERIFIED_TRUE
if valid
else VerifiedResult.VERIFIED_FALSE
)

0 comments on commit c38a437

Please sign in to comment.