Fix Bitbucket line highlighting URLs#4854
Open
shahzadhaider1 wants to merge 6 commits intotrufflesecurity:mainfrom
Open
Fix Bitbucket line highlighting URLs#4854shahzadhaider1 wants to merge 6 commits intotrufflesecurity:mainfrom
shahzadhaider1 wants to merge 6 commits intotrufflesecurity:mainfrom
Conversation
amanfcp
approved these changes
Apr 2, 2026
alafiand
approved these changes
Apr 9, 2026
Contributor
alafiand
left a comment
There was a problem hiding this comment.
This looks like a good fix to make these links more useful. I imagine downstream consumers of these links could have systems in place relying on the old URL format, but I can't imagine they will be upset to see that the links have been fixed.
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.
Problem
Bitbucket source links generated by TruffleHog do not highlight the correct line when clicked.
GenerateLink()produces/commits/{hash}URLs with no file path or line fragment.UpdateLinkLineNumber()explicitly skips Bitbucket with a comment saying "it doesn't support line links", which is incorrect.determineProvider()doesn't recognize, so they fall through to the default case which appends GitHub-style#L{line}fragments. This format does not work on Bitbucket Server.Root Cause
determineProvider()only detects Bitbucket Cloud (bitbucket.org). Bitbucket Server URLs are unrecognized and treated as GitHub/GitLab. Neither Cloud nor Server gets the correct line fragment format.Fix
GenerateLink(): Bitbucket Cloud now generates/src/{commit}/{file}URLs (matching the existing behavior in the scanner's makeCommitURL) with #lines-{line} fragments.UpdateLinkLineNumber():determineProvider(): NewproviderBitbucketServerdetection usingisBitbucketServerURL()which checks for the distinctive /projects/ + /repos/ path pattern in Bitbucket Server URLs.Correct URL formats
Platform: Bitbucket Cloud
View: Source File
Fragment format: #lines-{line}
Platform: Bitbucket Server
View: Source File
Fragment format: #{line}
References
Verification
Working examples:
Checklist:
make test-community)?make lintthis requires golangci-lint)?Testing
Scan now produces results that include the line number in the secret location URL and upon clicking those URLs, the secrets are correctly highlighted, as shown in the screenshots below:



Note
Low Risk
Low risk: changes are limited to URL/provider detection and link formatting, with added unit tests; primary impact is on generated report links for Bitbucket Cloud/Server.
Overview
Fixes Bitbucket links so TruffleHog can deep-link to the correct source file and highlighted line.
GenerateLinknow produces Bitbucket Cloud/src/{commit}/{file}URLs (optionally with#lines-{N}), andUpdateLinkLineNumberupdates Bitbucket Cloud fragments using thelines-{N}format while adding Bitbucket Server/Data Center support via new provider detection (/projects/.../repos/...) that uses#{N}fragments. Tests are expanded to cover the new Bitbucket Cloud and Bitbucket Server behaviors.Reviewed by Cursor Bugbot for commit 4f22ca1. Bugbot is set up for automated code reviews on this repo. Configure here.