-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add verifiability for Slack webhooks #232
Comments
@KevinHock Can I work on this? |
Sure thing @Patil2099 :) Let me know if you have any questions. |
@KevinHock Can you help me a little bit? I might be able to do it for mailchimp and stripe also. |
Sure @Patil2099 , for this you would change the def verify(self, token, **kwargs): # pragma: no cover
if token.startswith('https://hooks.slack.com/services/T'):
# From https://github.com/streaak/keyhacks#slack-webhook
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
) where the Afterwards you can make sure the tests still pass with |
As @dgzlopes helpfully linked to, https://github.com/streaak/keyhacks#slack-webhook shows how we can add this.
See #194 for an example of how we do this in detect-secrets, e.g. we already have validation for Slack tokens
detect-secrets/detect_secrets/plugins/slack.py
Lines 30 to 39 in cba0446
The parent issue (#153) is still opened but figured I'd make this as a
good first issue
.The text was updated successfully, but these errors were encountered: