feat(bitbucket-cloud): add HMAC webhook secret validation - #2870
Conversation
|
e2e test would fail on it waiting for #2869 to be merged. |
There was a problem hiding this comment.
Code Review
This pull request introduces webhook secret validation for Bitbucket Cloud using HMAC-SHA256/SHA1 signatures, updating both the documentation and the provider implementation. The review feedback highlights a critical backward compatibility issue: the new validation logic blocks webhooks when no secret is configured, rather than falling back to IP-based validation. To resolve this, the reviewer suggests returning early with no error when the secret is empty and adjusting the corresponding unit tests.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
Adds webhook HMAC signature validation to the Bitbucket Cloud provider to align with the existing signature-validation patterns used by other providers, and updates docs/tests accordingly.
Changes:
- Implement HMAC signature validation in
bitbucket-cloudproviderValidate(). - Add unit tests covering signature validation scenarios for Bitbucket Cloud.
- Update Bitbucket Cloud provider documentation to describe configuring a webhook secret.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pkg/provider/bitbucketcloud/bitbucket.go |
Adds signature-header extraction and HMAC verification in Validate(). |
pkg/provider/bitbucketcloud/bitbucket_test.go |
Introduces unit tests for Bitbucket Cloud webhook validation. |
docs/content/docs/providers/bitbucket-cloud.md |
Documents webhook secret configuration and reframes IP-checking as defense-in-depth. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2870 +/- ##
==========================================
- Coverage 68.45% 68.43% -0.02%
==========================================
Files 197 197
Lines 16766 16777 +11
==========================================
+ Hits 11477 11482 +5
- Misses 4417 4423 +6
Partials 872 872
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| func (v *Provider) Validate(_ context.Context, _ *params.Run, _ *info.Event) error { | ||
| return nil | ||
| func (v *Provider) Validate(_ context.Context, _ *params.Run, event *info.Event) error { | ||
| signature := event.Request.Header.Get(github.SHA256SignatureHeader) |
There was a problem hiding this comment.
The docs suggest PaC validates X-Hub-Signature but github.SHA256SignatureHeader = X-Hub-Signature-256
There was a problem hiding this comment.
Bitbucket Cloud sends SHA-256 signatures as X-Hub-Signature: sha256=. The current tests cover X-Hub-Signature-256 with SHA-256 and X-Hub-Signature with SHA-1, but not the format Bitbucket actually sends. Please update the docs and add a positive test for X-Hub-Signature with SHA-256.
See the doc: https://support.atlassian.com/bitbucket-cloud/docs/manage-webhooks/
There was a problem hiding this comment.
yeah, this is weird bb cloud send X-Hub-Signature with sha256 prefix and calculated as sha256
b606f5d to
1e2dd36
Compare
Paco Review
|
zakisk
left a comment
There was a problem hiding this comment.
Paco inline comments -- see the Paco Review summary comment for the overview.
ad70d85 to
248d89e
Compare
248d89e to
734b7cb
Compare
theakshaypant
left a comment
There was a problem hiding this comment.
Minor suggestions for docs.
|
all good for me but please consider fix the spelling as highlighted by akshay |
9b04119 to
a849d4a
Compare
|
/retest |
1 similar comment
|
/retest |
Implement X-Hub-Signature / X-Hub-Signature-256 HMAC validation for Bitbucket Cloud webhooks, matching the existing GitHub and Bitbucket Data Center pattern. When a webhook_secret is configured on the Repository CR, incoming payloads are verified against the signature header. Repositories without a webhook_secret continue to rely on IP-based validation for backward compatibility. Signed-off-by: Zaki Shaikh <zashaikh@redhat.com> Assisted-by: Claude Opus 4.6 (via Claude Code)
a849d4a to
6cbe058
Compare
|
I think last week doc-deployment was failing due to cluster issue |
|
/retest |
theakshaypant
left a comment
There was a problem hiding this comment.
LGTM, all earlier review comments have been addressed.
📝 Description of the Change
Implement X-Hub-Signature / X-Hub-Signature-256 HMAC validation for Bitbucket Cloud webhooks, matching the existing GitHub and Bitbucket Data Center pattern. PaC first checks IP-Based validation if it's disabled then fallback to webhook secret validation and checks if a webhook_secret is configured on the Repository CR, incoming payloads are verified against the signature header.
Assisted-by: Claude Opus 4.6 (via Claude Code)
🔗 Linked GitHub Issue
Fixes #
🧪 Testing Strategy
🤖 AI Assistance
AI assistance can be used for various tasks, such as code generation,
documentation, or testing.
Please indicate whether you have used AI assistance
for this PR and provide details if applicable.
Important
Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Claude noreply@anthropic.com
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.