Skip to content

Add Together AI secret detector#4943

Open
asivaprasad09 wants to merge 1 commit intotrufflesecurity:mainfrom
asivaprasad09:add-togetherai-detector
Open

Add Together AI secret detector#4943
asivaprasad09 wants to merge 1 commit intotrufflesecurity:mainfrom
asivaprasad09:add-togetherai-detector

Conversation

@asivaprasad09
Copy link
Copy Markdown

@asivaprasad09 asivaprasad09 commented May 4, 2026

Summary

  • Adds a new detector for Together AI API keys (tgp_v1_ format)
  • Verifies keys via read-only GET https://api.together.xyz/v1/models
  • Registers detector in defaults.go and proto as TogetherAI = 1049
  • Populates SecretParts with "key" per detector conventions

Test plan

  • go test ./pkg/detectors/togetherai/... -tags=detectors passes all 4 cases (found+verified, found+unverified, not found, timeout)
  • Verified against a real Together AI key returning HTTP 200
  • Invalid key correctly returns HTTP 401 (unverified, no error)

Note

Low Risk
Low risk: adds a new detector and enum wiring with a simple read-only verification call; main risk is potential false positives/verification network flakiness impacting scan performance.

Overview
Adds a new togetherai secret detector that identifies Together AI API keys in the tgp_v1_ format and (optionally) verifies them via GET https://api.together.xyz/v1/models using a Bearer token.

Registers the detector in the default detector list and introduces a new DetectorType_TogetherAI enum value (TogetherAI = 1049) in the proto/generated bindings, along with unit tests and a benchmark covering verified/unverified/not-found/timeout cases.

Reviewed by Cursor Bugbot for commit 4298c97. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds a detector for Together AI API keys (tgp_v1_ format).
Verifies keys via GET /v1/models endpoint.
@asivaprasad09 asivaprasad09 requested a review from a team May 4, 2026 07:00
@asivaprasad09 asivaprasad09 requested review from a team as code owners May 4, 2026 07:00
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Akshara Sivaprasad seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 4298c97. Configure here.

@@ -0,0 +1,138 @@
package togetherai
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test missing build tag will break regular CI

Medium Severity

The test file calls common.GetSecret to fetch secrets from GCP but is missing the //go:build detectors build tag. Every other test file in the project that calls common.GetSecret has this build tag and is named *_integration_test.go. Without the tag, this test will be compiled and run during regular go test invocations (without -tags=detectors), failing immediately because GCP access is not available in that context.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4298c97. Configure here.

func TestTogetherAI_FromData(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
defer cancel()
testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors5")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1ms context timeout causes GCP secret fetch failure

Medium Severity

The context created with time.Millisecond timeout is passed to common.GetSecret. Inside GetSecret, a derived context with context.WithTimeout(ctx, time.Second*10) inherits the parent's shorter deadline. This means the GCP secretmanager call will fail with "context deadline exceeded" almost immediately. Other integration tests use time.Second*5 for this purpose. The short-timeout context intended for the "timeout" test case needs to be separate from the one used for secret retrieval.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4298c97. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants