[INS-351] Added Duffel Token Detector - #4795
Conversation
kashifkhan0771
left a comment
There was a problem hiding this comment.
Just two non-blocking comments but I would highly appreciate if we can improve pattern test cases as I mentioned.
| res, err := client.Do(req) | ||
| if err != nil { | ||
| return false, err | ||
| } |
There was a problem hiding this comment.
Non-blocking comment: As now we have a DoWithDedup we can use it in new detectors.
Example:
resp, err := detectors.DoWithDedup(client, detector_typepb.DetectorType_Meraki, match, req)
if err != nil {
return nil, false, err
}| "github.com/trufflesecurity/trufflehog/v3/pkg/engine/ahocorasick" | ||
| ) | ||
|
|
||
| func TestDuffelTestToken_Pattern(t *testing.T) { |
There was a problem hiding this comment.
Pattern test cases are one of the most critical parts of any detector, so I'd suggest taking the time to write them thoroughly.
We've already spent a lot of time cleaning up and improving the test cases across existing detectors, and I'd like to avoid creating another backlog of fixes.
For reference, have a look at:
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit f3c209a. Configure here.

Description
This PR adds the Duffel API Token Detector for TruffleHog.
It scans for Duffel sandbox API tokens (prefix
duffel_test_orduffel_live_) and optionally verifies them via the Duffel API.Regex:
\b(duffel_(test|live)_[A-Za-z0-9_-]{43})(?:$|[^A-Za-z0-9_-])Verification
For verification, we use the Duffel Users API:
/identity/customer/users?limit=1.We send a GET request with the token in the
Authorizationheader.A response code of:
This endpoint is part of the official Duffel API and can be used safely for verification.
It is read-only, does not create or modify resources, and simply confirms whether the provided token is valid.
Corpora Test
The detector does not appear in the list.

Checklist:
make test-community)?make lintthis requires golangci-lint)?Note
Low Risk
Additive detector behind a feature flag; verification only performs a read-only external API call, matching existing TruffleHog detector patterns.
Overview
Adds a DuffelToken detector that finds
duffel_test_andduffel_live_API tokens (43-character suffix) and optionally verifies them against Duffel’s read-only GET/identity/customer/users?limit=1endpoint (Bearer +Duffel-Version: v2).Wiring follows the usual new-detector path:
DetectorType_DuffelToken(1059) in proto, scanner registered inbuildDetectorList(), gated byDuffelTokenDetectorEnabled(enabled inmain.go), and listed inexcludedFromDefaultListfor the proto coverage test. Unit, pattern, integration, and benchmark tests are included underpkg/detectors/duffeltoken/.Reviewed by Cursor Bugbot for commit 91cb3f0. Bugbot is set up for automated code reviews on this repo. Configure here.