Add Octopus Deploy API Key detector#5025
Conversation
This commit adds a detector for Octopus Deploy API keys:
- Detects API keys with the "API-" prefix followed by 26 uppercase alphanumerics
- Uses context-aware regex requiring "octopus" or "X-Octopus-ApiKey" nearby
- Implements CustomFalsePositiveChecker interface for additional validation
- Includes comprehensive test coverage for pattern matching and edge cases
The detector adds OctopusApiKey (ID 1053) to the detector type enum and
follows TruffleHog's best practices for secret detection.
Key features:
- Context-aware pattern matching to reduce false positives
- Strict uppercase alphanumeric validation (26 characters after prefix)
- Deduplication of repeated keys
- Proper SecretParts population
- Rotation guide in ExtraData
- Support for both "octopus" and "X-Octopus-ApiKey" keywords
Pattern: API-[A-Z0-9]{26} with "octopus" or "x-octopus-apikey" context
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit db92812. Configure here.
| name: "invalid pattern - wrong prefix", | ||
| input: `key = "AP1-ZNRMR7SL6L3ATMOIK7GKJDKLPY"`, | ||
| want: nil, | ||
| }, |
There was a problem hiding this comment.
Invalid pattern tests lack keyword context, testing wrong thing
Low Severity
The three "invalid pattern" test cases (too short, lowercase characters, wrong prefix) don't contain "octopus" or "x-octopus-apikey" in their input. They pass because the keyword context is missing, not because the format validation rejects them. If someone later accidentally weakens the format regex (e.g., changing [A-Z0-9] to [A-Za-z0-9]), the "lowercase characters" test would still pass since it never actually exercises that validation path. Each invalid test input needs the keyword prefix to properly validate format rejection.
Reviewed by Cursor Bugbot for commit db92812. Configure here.


Summary
This PR adds a detector for Octopus Deploy API keys used to authenticate requests to Octopus REST API endpoints.
Key features:
API-prefix followed by exactly 26 uppercase alphanumericsCustomFalsePositiveCheckerinterface for additional validationChanges
OctopusApiKey(ID 1053) toproto/detector_type.protopkg/detectors/octopusapikey/pkg/engine/defaults/defaults.goPattern Details
The detector uses a context-aware regex pattern:
This requires either "octopus" or "x-octopus-apikey" to appear before the token to avoid false positives. The API key format is highly specific:
API-prefixTesting
All tests pass successfully:
Test coverage includes:
X-Octopus-ApiKeyheader)Design Rationale
Why context-aware matching?
While the
API-[A-Z0-9]{26}format is specific, it could still match other API key formats. Requiring "octopus" or the standard HTTP header name "X-Octopus-ApiKey" in nearby context ensures high precision while maintaining excellent recall for actual Octopus Deploy keys.Why support both keywords?
"octopus"catches environment variables, config files, and code comments"X-Octopus-ApiKey"catches HTTP header usage, which is the standard way to use these keys in API requestsWhy no verification?
Octopus Deploy API keys require both the API key AND the Octopus Server URL to verify. Since the detector only extracts the key (not the associated server URL), verification is not possible without additional context. The key format itself is sufficiently distinctive to provide high-confidence detection.
SecretParts Population
The detector properly populates
SecretPartswith:And includes a rotation guide in
ExtraData:Example Matches
✅ Will detect:
❌ Will NOT detect (reducing false positives):
🤖 Generated with Claude Code
Note
Low Risk
Additive secret-detection only; no changes to auth, verification, or core scan pipeline beyond registering one more default detector.
Overview
Adds Octopus Deploy API key scanning as detector type
OctopusApiKey(ID 1053), wired into the default engine and protobuf enum.The new scanner matches
API-plus 26 uppercase alphanumerics only when nearby context includesoctopusorX-Octopus-ApiKey, deduplicates hits, fillsSecretPartsand a rotation-guide link, and uses the shared false-positive checker. There is no live verification (keys need a server URL). Unit tests cover headers, env vars, multi-key/dedup, and invalid formats.Reviewed by Cursor Bugbot for commit db92812. Bugbot is set up for automated code reviews on this repo. Configure here.