Scanner deep dive
Sourcegraph
Slug: sourcegraphMaintainer view: off. Activate to show technical details for maintainers.Overview
Sourcegraph is a code search and navigation engine. Sourcegraph tokens can be used to access and interact with Sourcegraph APIs.
Provider and detector details
Summary
ProviderNo provider details added yet.
- Pattern only
- Unchanged since Sep 18, 2026
- Source at 2325546
Runs on any connection. Triggered by keywords in the content, after decoding.How TruffleHog works
How detection works
The Sourcegraph detector looks for a single value in text that resembles a credential. It uses the word “sgp_” to narrow its search.
Matching rules and source
- Keywords
- sgp_
Regex
Regexsourcegraph.go:26 (opens TruffleHog source on GitHub)
\b(sgp_(?:[a-fA-F0-9]{16}|local)_[a-fA-F0-9]{40}|sgp_[a-fA-F0-9]{40}|[a-fA-F0-9]{40})\bShow as a diagram
How it works
- Skips any text that doesn’t contain “sgp_”. This keeps scanning fast.
- Looks for text matching its pattern.
- Values are trimmed before use.
- Reports each remaining match as a possible Sourcegraph credential. It isn’t known to work until it’s verified.
- Regular expression
- One value
Guards against false matches
- Not found in source
- Not found in source
How it behaves
What this detector does at each step of the TruffleHog pipeline.
Keywords
Any one of these in the decoded text wakes the detector.
- sgp_
Behavior
- Multi-part
- No
- Match window
- 512 bytes on each side of a keyword
- ahocorasickcore.go line 159 (opens TruffleHog source on GitHub)
- Custom endpoints
- No
- Cloud endpoint
- None
- Randomness check
- None in this detector's own code
- False-positive check
- The shared word lists
Verification. When a scan allows it, TruffleHog tests a match by calling the provider. A scan can turn this off for every detector or for this one. Atlas only describes this; it never tests credentials. How the verify decision works
Analyzer.Sourcegraph Analyzer
In short
Wakes on “sgp_” and tests matches with the provider. A default scan runs it.
How verification works
What it means
The verification code lists sourcegraph.com as a destination. The detector decides whether a match passes using its own rules.
The detection and verification evidence on this page comes from the Open Source implementation. Check the Enterprise coverage guide for product availability.
Does checking a key change anything at the provider?
Probably not, but not certain: the source declares no changes, and many checks use POST only to read. POST can change data, so check the source if it matters.
Verification walkthrough
How it works
- Sends a POST to sourcegraph.com.
- Puts the found credential in the request: credential is sent in the Authorization header; scheme is not Bearer/token in source.
- Verified means HTTP 2xx.
- If the request can’t reach the provider, the result is an error, not a rejection.
Evidence from source
How responses are judged
| Status | Outcome | Source |
|---|---|---|
| 2xx | Verified | sourcegraph.go:71 (opens TruffleHog source on GitHub) |
Troubleshoot this check
If a result looks wrong, work through these steps. They’re built from the request and status rules above. The Atlas doesn’t send anything.
1. Send the same request yourself
No command for this check. The check sends a POST request with a body the Atlas doesn't record, so a command might get a different answer and might not be read-only.
2. Likely causes
- The scanner couldn't reach the provider. The scanner needs outbound HTTPS access to sourcegraph.com. A firewall, proxy or DNS problem is reported as an error, not a rejection, and the key can be checked again.
- The provider changed its API. If the provider answers differently from the table above, its API may have changed since this check was written. Compare against the provider's docs.
3. Check the provider’s docs
No provider doc recorded for this check yet. Look up the API docs for sourcegraph.com and compare what they say each status means.
4. Still stuck
Report it to TruffleHogInclude the status code and response you got. Never include the key.
Errors, timeouts and rate limits
- Not found in source
- Not found in source
- If the provider can’t be reached
- The result is an error, not a rejection, and the key can be checked again.
All URLs found in source
- https://howtorotate.com/docs/tutorials/sourcegraph/
- https://sourcegraph.com/.api/graphql
Verified findings
Open Source · Standard output (stdout)
The CLI prints verified findings to stdout. Use --json for structured output.
Example scan output · credential redacted
✅ Found verified result 🐷🔑
Detector Type: Sourcegraph
Decoder Type: PLAIN
Raw result: [redacted]Terminal printer sourceCI formats
With --github-actions, GitHub Actions displays this workflow command as a warning on the indicated file and line.
::warning file=config/example.env,line=8,endLine=8::Found verified Sourcegraph result 🐷🔑GitHub Actions printer sourceLegacy compatibility. --json-legacy writes pre-v3 JSON for Git, GitLab, and GitHub sources only.
Enterprise alerts
When Enterprise verifies that a secret is live, a configured notifier can alert your team. The finding is also available through the Enterprise API.
A notifier that displays rotation guides can include this link with the alert.
Open rotation guideOptional analysis
What the analyzer checks
In Open Source, run trufflehog analyze separately from the scan. Enterprise runs enabled self-discovery analyzers on first discovery of a supported live secret.
- Open Sourcegraph Analyzer →
- Picks a preset by testing
Probes a site-admin query and assigns one of two fixed permission levels.
Permissions and sources
2 permission names in source
Alert delivery has no documented ordering relative to analysis. How Analyze runs.
Rotation resources
Use the rotation guide to replace this credential.
Token types
TruffleHog’s source doesn’t name a token type or require a fixed prefix for this detector.
Pages TruffleHog’s source links to (1)
Written in the detector’s source by its authors. Shown as written: this doesn’t say what each page covers.
Coverage in other scanners
4 scanners have a confirmed match.
BetterleaksConfirmed match
GitHub Secret ProtectionConfirmed match
- Sourcegraph Access Token
sourcegraph_access_tokenPush protection yes · Validity check yes - Sourcegraph Access Token with Instance Identifier
sourcegraph_instance_identifier_access_tokenPush protection yes · Validity check yes
- Sourcegraph Access Token
GitleaksConfirmed match
KingfisherConfirmed match
betterleaks.sourcegraph-access-tokenThe rule declares validation.
Changes
No changes to Sourcegraph since Sep 18, 2026, when Atlas started recording.
When TruffleHog changes this detector, the changed fields, the pull request and the source diff appear here for review.
Source
Facts on this page were read from trufflesecurity/trufflehog at commit 2325546.