Create Docker registry auth detector #2677
Open
+755
−0
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:
This implements a detector to find Docker registry credentials, inspired by this suggestion from @bgoareguer.
The current code works, but is a bit messy and requires more feedback + testing.
Questions/TODO
Should this also match and decode Kubernetes.dockerconfigjson
results, or rely on the base64 decoder?json.Unmarshal
) that are worth noting, as it could be indicative of a bug.gcr.io
credential, as that registry uses base64-encoded GCP service principals as the password. It's possible that this doesn't work with the current logic (e.g., encoded newlines.)Handle username for GCR credentials? (It's a static_json_key
, the real username is in the auth)Are there any other potential formats this data gets stored in? (e.g., YAML)\n
as well as literal?docker.io
which is a special case (https://stackoverflow.com/a/68654659)Future work?
json.NewDecoder
instead ofjson.Unmarshal
(https://github.com/Azure/ARO-RP/blob/25b8569698b61abd7af6cdefe680fdc1306b001f/pkg/operator/admission/validation/pullsecret/request.json#L1)base64-encoded auth does not match source
is a legitimate issue (probably not, seems to be caused by base64 decoder)Checklist:
make test-community
)?make lint
this requires golangci-lint)?