docker / docker-credential-helpers

Programs to keep Docker login credentials safe by storing in platform keystores
MIT License
1.05k stars 166 forks source link

pass: fix interpolation of $PASSWORD_STORE_DIR, and use os.UserHomeDir() #287

Closed thaJeztah closed 1 year ago

thaJeztah commented 1 year ago

commit a13ff500176e7570239691424050fb46b0a7f05b (https://github.com/docker/docker-credential-helpers/pull/109) simplified the handling of env-vars in getPassDir(), but moved interpolation of env-vars to the end of the function.

As a result, a custom path passed through $PASSWORD_STORE_DIR would now be interpolated, instead of taken as-is. For example;

PASSWORD_STORE_DIR=$PWD/world

Would now interpolate $PWD, instead of using a literal $PWD.

This patch changes the logic to only expand env-vars for the default location.

pass: make home-dir resolution platform agnostic

Use stdlib's os.UserHomeDir() instead of depending only on $HOME. Note that this does not yet does nss lookups for situations where $HOME / $USERPROFILE is not set.

thaJeztah commented 1 year ago

I'll do a follow-up to improve the home-dir lookup (now that we made pass compile for other platforms as well), but making this fix separate first.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 50.00% and no project coverage change.

Comparison is base (2860ca4) 54.68% compared to head (372315b) 54.68%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #287 +/- ## ======================================= Coverage 54.68% 54.68% ======================================= Files 9 9 Lines 673 673 ======================================= Hits 368 368 Misses 262 262 Partials 43 43 ``` | [Impacted Files](https://app.codecov.io/gh/docker/docker-credential-helpers/pull/287?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=docker) | Coverage Δ | | |---|---|---| | [pass/pass.go](https://app.codecov.io/gh/docker/docker-credential-helpers/pull/287?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=docker#diff-cGFzcy9wYXNzLmdv) | `67.25% <50.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

thaJeztah commented 1 year ago

@crazy-max ptal 😅

thaJeztah commented 1 year ago

Added a commit to use os.UserHomeDir() PTAL