feat(detectors): add Dynatrace token detector#5085
Open
beer4code wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a detector for Dynatrace API tokens, personal access tokens, and platform tokens (shape
dt0<x><nn>.<public-id>.<secret>, e.g.dt0c01,dt0s16).azure_cosmosdb/cexiodetectors).appssubdomain only a very limited platform API, so it is normalized to the environment API host before the request: prod...apps.dynatrace.com→...live.dynatrace.com; dev/sprint drop the extraappslabel.ExtraData(visible in plain output) andSecretParts/RawV2.Verification
POST https://{tenant}/api/v2/apiTokens/lookupwithAuthorization: Api-Token <token>.200→ verified403→ verified but token lacks permissions to lookup scopes (this case has been thoroughly tested with live tokens)401→ unverified, or other status / transport errors → surfaced viaSetVerificationError(reported asunknown).Testing
dynatrace_test.go): regex coverage, host normalization (live/apps/dev/sprint variants), redaction (secret masked), and verification status mapping via mock clients (200/403/401/5xx/transport error).dynatracesecret; runnable locally viaTEST_SECRET_FILE).Registered as
DetectorType_Dynatrace = 741(already reserved in the proto; removed fromexcludedFromDefaultList).Checklist:
make test-community)make lintthis requires golangci-lint)Note
Low Risk
Additive detector-only change with tests; verification performs outbound calls to customer Dynatrace tenants when verify mode is on, consistent with other API-key detectors.
Overview
Adds a Dynatrace secret scanner for API/PAT/platform tokens (
dt0…three-segment form) and wires it into the default engine asDetectorType_Dynatrace(741), dropping the proto “not yet implemented” note and removing it fromexcludedFromDefaultList.Detection uses keyword
dt0, regex for tokens and SaaS tenant hosts, and cartesian pairing of each token with every tenant in the chunk (tenant inExtraData/RawV2). Tokens without a tenant in the chunk are still reported unverified. VerificationPOSTs to/api/v2/apiTokens/lookupon a normalized API host (apps→live/ stripped on labs); 200 and 403 count as verified, 401 as invalid, and other HTTP/transport failures surface viaSetVerificationError. Secret segments are redacted in output.Unit tests cover patterns, host normalization, redaction, and mocked verification; an optional integration test runs when
dynatracetest secrets are configured.Reviewed by Cursor Bugbot for commit 02d5637. Bugbot is set up for automated code reviews on this repo. Configure here.