Implement detectors.EndpointCustomizer on datadogtoken #2510
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.
Description
As reported in #2265, Datadog API and app key verification only works if the tokens were generated in the main Datadog region (US East 1, aka
api.datadoghq.com
). This PR makes it possible to override the Datadog API endpoint at runtime.Please note: when specifying a custom verifier host on the command line, trufflehog checks both the custom host and the default host. (See example below of when I ran this.) I wasn't expecting this, but it does appear to be the expected behaviour of
detectors.EndpointCustomizer
when usingdetectors.EndpointSetter
. Please let me know if I've misunderstood anything here. (Very possible.)Closes #2265
Typical usage
By default, validate against https://api.datadoghq.com only:
Validate against a different endpoint:
Validate against multiple endpoints:
Sample output
I registered API and app tokens on both https://api.datadoghq.com/ and https://api.datadoghq.eu. (I gave both app tokens access to the
user_access_read
scope, since this is needed by the verifier; removing this dependency would be nice to do, but belongs in a separate PR.)With the default verifier host:
With a custom verifier host:
Checklist:
make test-community
)?make lint
this requires golangci-lint)?Notes on testing
make test-community
but it failed, for an issue unrelated to this change.datadogtoken_test.go
here, to also test Datadog credentials from an instance other than the default (api.datadoghq.com
), but I think this needs to be done by someone with access to the test secrets in GCP.