-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat(bitbucket): check bitbucket webhook signature if webhook_secret is defined #84309
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #84309 +/- ##
===========================================
+ Coverage 46.61% 87.66% +41.05%
===========================================
Files 9563 9575 +12
Lines 541874 542418 +544
Branches 21264 21252 -12
===========================================
+ Hits 252589 475535 +222946
+ Misses 288933 66531 -222402
Partials 352 352 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, not sure what the request
is being used for in the handler though
@@ -206,6 +262,6 @@ def post(self, request: HttpRequest, organization_id: int) -> HttpResponse: | |||
domain=IntegrationDomain.SOURCE_CODE_MANAGEMENT, | |||
provider_key=event_handler.provider, | |||
).capture(): | |||
event_handler(event, organization=organization) | |||
event_handler(event, request=request, organization=organization) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do we need the request
for here? it's not being used in BitbucketWebhook
except to check that it's passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request
contains X-Hub-Signature
header and request body which are used here:
sentry/src/sentry/integrations/bitbucket/webhook.py
Lines 135 to 142 in 90fc14b
method, signature = request.META["HTTP_X_HUB_SIGNATURE"].split("=", 1) | |
except (IndexError, KeyError, ValueError): | |
raise WebhookMissingSignatureException() | |
if method != "sha256": | |
raise WebhookUnsupportedSignatureMethodException() | |
if not is_valid_signature(request.body, secret, signature): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wait, can we do this in the webhook itself before calling the handler?
Preparing Bitbucket webhook secret validation. This is actual signature header validation, but no integrations/repos have the associated secret yet.
Follow-up PRs:
webhook_secret
: feat(bitbucket): add webhook secret on each repository creation #84311Previous attempt (#82541) had repository-level secrets but we decided to go with integration-level secret to align with other integrations (GitLab, GitHub).