Skip to content

Add Perplexity API key detector - #5513

Open
eeee2345 wants to merge 1 commit into
trufflesecurity:mainfrom
eeee2345:feat/perplexity-detector
Open

eeee2345 wants to merge 1 commit into
trufflesecurity:mainfrom
eeee2345:feat/perplexity-detector

Conversation

@eeee2345

@eeee2345 eeee2345 commented Nov 2, 2026 •

Copy link
Copy Markdown

Description:

Adds a detector and verifier for Perplexity API keys.

Perplexity's API (search, Agent API and model inference) is paid per request and billed to the key owner's account. Keys are pplx- followed by 48 alphanumeric characters; the same shape is used by gitleaks' perplexity-api-key rule.

Verification uses the read-only List Models endpoint:

  • GET https://api.perplexity.ai/v1/models with Authorization: Bearer <key> (https://docs.perplexity.ai/api-reference/models-get)
  • 200: verified
  • 401: unverified (the endpoint also returns 401 with no Authorization header and with a malformed key)
  • anything else, or a transport error: indeterminate verification error

The structure follows the Fireworks detector added in #5447.

Changes:

  1. proto/detector_type.proto: Perplexity = 1078; (happy to renumber if another detector lands first)
  2. pkg/pb/detector_typepb/detector_type.pb.go: regenerated with make protos
  3. pkg/detectors/perplexity/: detector, unit tests (pattern, including too-short and too-long keys, and verifier status handling via a fake transport), and an integration test that reads PERPLEXITY / PERPLEXITY_INACTIVE from the detectors5 test secret
  4. pkg/engine/defaults/defaults.go: registered in the default detectors

I don't have a live Perplexity key, so the integration test has not been run against a verified key and the secrets would need adding on your side. I did build the binary and run trufflehog filesystem --include-detectors=Perplexity on a file with a well-formed fake key: it is reported once, with live verification returning unverified and no verification error.

Checklist:

  • Tests passing: go test ./pkg/detectors/perplexity/... ./pkg/engine/defaults/... (did not run the full make test-community)
  • Lint passing: golangci-lint run ./pkg/detectors/perplexity/... reports 0 issues; gofmt, go vet (with and without the detectors tag), go run ./hack/checksecretparts -fail ./pkg/detectors and the hack/semgrep-rules/detectors.yaml semgrep rules are clean

Note

Low Risk
Additive detector following the same pattern as other API-key scanners; verification only performs a read-only models list request when explicitly enabled.

Overview
Introduces a new Perplexity secret detector so TruffleHog can find pplx- keys (48 alphanumeric characters after the prefix) in scanned content, with optional live verification.

Detection uses keyword pplx- and a bounded regex; results include a rotation guide and SecretParts. When verification is enabled, keys are checked with a read-only GET https://api.perplexity.ai/v1/models call—200 marks verified, 401 unverified, other statuses or transport failures surface as verification errors.

Wiring adds DetectorType_Perplexity = 1080 in proto/detector_type.proto (and regenerated detector_type.pb.go), registers perplexity.Scanner in default detectors, and adds unit tests (pattern edge cases, mocked HTTP verifier) plus a detectors-tagged integration test against GCP test secrets.

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

@eeee2345
eeee2345 requested a review from a team November 2, 2026 20:49
@eeee2345
eeee2345 requested a review from a team as a code owner November 2, 2026 20:49
@CLAassistant

CLAassistant commented Nov 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@eeee2345
eeee2345 force-pushed the feat/perplexity-detector branch from e393214 to aced6f9 Compare November 30, 2026 06:05
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