Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggcr: authn.AuthConfig JSON marshaling logic does not handle some edge cases correctly #1864

Open
mvasl opened this issue Jan 15, 2024 · 1 comment
Labels
bug Something isn't working lifecycle/stale

Comments

@mvasl
Copy link

mvasl commented Jan 15, 2024

Describe the bug

Where there is nothing in the Username and Password fields and only the Auth field of authn.AuthConfig is filled, custom json marshalling fails to produce proper output.

To Reproduce

authConfig := authn.AuthConfig{Username: "", Password: "", Auth: "<any valid base64 auth string>"}
dockerCfgAuth, err := json.Marshal(authConfig)

Running the example above produces a JSON object with only the auth field as expected. However, the contents of this field will always be Og==, which is base64 for :.

This is due to the encodeDockerConfigFieldAuth function in pkg/authn/auth.go always overwriting contents of the Auth field with a concatenation of username + ":" + password, which leads to data corruption when there is only the auth string and no username and password is provided.

Expected behavior

Zero values of authn.AuthConfig are expected to marshal to {}, not {"auth": "Og=="} and values with only Auth fields filled are expected to either only produce JSON objects with this field and its contents or produce an object with both auth and username+password pair decoded from auth.

Additional context

Add any other context about the problem here.

  • Version of the module - v0.17.0
  • Registry used (e.g., GCR, ECR, Quay) - irrelevant
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lifecycle/stale
Projects
None yet
Development

No branches or pull requests

1 participant