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

A docker auth password that contains a colon truncates the password #838

Closed
joshystuart opened this issue Oct 2, 2024 · 1 comment · Fixed by #839
Closed

A docker auth password that contains a colon truncates the password #838

joshystuart opened this issue Oct 2, 2024 · 1 comment · Fixed by #839
Labels
bug Something isn't working

Comments

@joshystuart
Copy link
Contributor

Expected Behaviour
The docker auth password should not be truncated if it contains a :

Actual Behaviour
The docker auth password is truncated if it contains a :

eg. If the password is password1:1 it will be reduced to password1.

Testcontainer Logs
Since the password is truncated, it ends up producing the unauthorized error:

 testcontainers [ERROR] Failed to pull image "testcontainers/ryuk:0.5.1": Error: (HTTP code 500) server error - Head "https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.5.1": unauthorized: incorrect username or password

Steps to Reproduce

  1. Create a docker auth password that contains a colon (:)
  2. Set the credentials in the ~/.docker/config.json
  3. Run your tests with testcontainer

Code
You can clearly see in the code it is currently doing a naive string split on :

https://github.com/testcontainers/testcontainers-node/blob/main/packages/testcontainers/src/container-runtime/auth/auths.ts#L24

A simple fix could be something like this:

const [username, ...passwordParts] = decodedAuth.split(":");
const password = passwordParts.join(":");

I will raise a PR.

@joshystuart
Copy link
Contributor Author

Thanks @cristianrgreco. When will a new build be available with this fix?

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

Successfully merging a pull request may close this issue.

2 participants