[INS-399] Added Bitbucket data center(on prem) PAT detector#4883
Merged
MuneebUllahKhan222 merged 4 commits intotrufflesecurity:mainfrom Apr 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 1ab3d98. Configure here.
mustansir14
reviewed
Apr 14, 2026
| // Bitbucket pat start with BBDC- prefix | ||
| // and are usually between the length of 40-50 character | ||
| // consisting of both alphanumeric and some special character like +, _, @ and etc | ||
| userPat = regexp.MustCompile(`\b(BBDC-[A-Za-z0-9+/@_-]{40,50})(?:[^A-Za-z0-9+/@_-]|$)`) |
Contributor
There was a problem hiding this comment.
Are we sure that the length is variable? I'm asking because for JIra the length was fixed.
Contributor
Author
There was a problem hiding this comment.
I generated 10 tokens and they all had a fixed length of 44 but I have added a little relaxation in-case their is a little bit of variation in different versions of on-prem tokens.
Also the bitbucket token has a BBDC- prefix so we can get away with making the regex a bit loose.
mustansir14
reviewed
Apr 14, 2026
mustansir14
reviewed
Apr 14, 2026
mustansir14
approved these changes
Apr 14, 2026
Contributor
mustansir14
left a comment
There was a problem hiding this comment.
Approving to unblock, but it would be great if you could incorporate those comments.
rosecodym
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
This PR adds the Bitbucket Data Center Personal Access Token (PAT) Detector for TruffleHog.
It scans for Bitbucket Data Center (on-prem) personal access tokens (prefix
BBDC-) and optionally verifies them against theOn-prem Bitbucket REST API.
Regex:
\b(BBDC-[A-Za-z0-9+/@_-]{40,50})\bIn addition to detecting tokens, the detector attempts to extract associated Bitbucket endpoints from nearby context (e.g., URLs containing
atlassianorbitbucket) to enable accurate verification and also allows the user to configure the verification endpoint.Verification
For verification, we use the Bitbucket Data Center REST API:
GET /rest/api/1.0/projects?limit=1A request is sent to the detected Bitbucket base URL with the token in the header:
This endpoint is part of the standard Bitbucket Data Center API and is read-only, making it safe for verification. It does not perform any destructive actions and only attempts to fetch a minimal list of projects.
Corpora Test
The detector does not appear in the list.

Checklist:
make test-community)?make lintthis requires golangci-lint)?Note
Medium Risk
Introduces a new network-verifying detector that may change scanning behavior via endpoint extraction and outbound HTTP requests, though it is isolated to a new detector and covered by tests.
Overview
Adds a new
bitbucketdatacenterdetector that identifiesBBDC--prefixed Bitbucket Data Center PATs, associates them with nearby Bitbucket/Atlassian base URLs (or configured endpoints), and emits combinedRawV2results for verification.When verification is enabled, the detector performs a read-only
GET /rest/api/1.0/projects?limit=1request withAuthorization: Bearer <token>and marks results verified on200, unverified on401, and records other statuses/errors as verification errors; comprehensive unit tests cover pattern matching, endpoint handling, and verification outcomes/timeouts.Extends the detector type enum by adding
DetectorType_BitbucketDataCentertodetector_type.proto(and regenerateddetector_type.pb.go).Reviewed by Cursor Bugbot for commit 90bef4d. Bugbot is set up for automated code reviews on this repo. Configure here.