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

Remove username and password in remote url for cache directory name #1186

Merged

Conversation

bond-os
Copy link
Contributor

@bond-os bond-os commented Jul 14, 2021

Currently, module remote url has some characters replaced to with - so it can be used as cache directory name on disk. However, when Puppetfile has module urls with authentication data in format of protocol://username:password@host, password will be leaked in cache directory name.

I've added replace action for username or username and password parts for the cache directory to avoid leaking credentials on filesystem. Using regex as some popular urls from eg. gitlab are not parsable with URI.parse.

- (JIRA ticket) Remove username and password from remote url for cache directory name. [Issue or PR #](link to issue or PR)

@bond-os bond-os requested a review from a team July 14, 2021 14:51
@CLAassistant
Copy link

CLAassistant commented Jul 14, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@mwaggett mwaggett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @bond-os thanks for this contribution!

Would you mind updating the CHANGELOG to include this change?

Also, have you done any manual testing of this?

lib/r10k/git/cache.rb Outdated Show resolved Hide resolved
@mwaggett
Copy link
Contributor

Also, would you mind updating your commit message to include the details you included in the PR description? thanks!

Currently, module remote url has some characters replaced to with - so it can
be used as cache directory name on disk. However, when Puppetfile has module
urls with authentication data in format of protocol://username:password@host,
password will be leaked in cache directory name.

Added replace action for username or username and password parts for the cache
directory name to avoid leaking credentials on filesystem. Using regex as some
popular urls from eg. gitlab are not parsable with URI.parse.
@bond-os bond-os force-pushed the remove-password-from-cache-dirname branch from 4a197f9 to 08fb638 Compare July 14, 2021 17:04
@bond-os
Copy link
Contributor Author

bond-os commented Jul 14, 2021

@mwaggett yes, tested locally with simple puppetfile and private repo:

mod 'test',
    :git => 'https://'+ENV['git_username']+':'+ENV['git_password']+'@github.com/bond-os/r10k-test.git',
    :branch => 'main'
git_username=bond-os git_password="ghp_xxx" bundle exec r10k puppetfile install -v -t
INFO	 -> Using Puppetfile '/Users/bernard/Documents/GitHub/r10k/Puppetfile'
INFO	 -> Deploying module to /Users/bernard/Documents/GitHub/r10k/modules/test

and cache dir on fs is:

-> % ll ~/.r10k/git/
total 0
drwxr-xr-x  10 bernard  staff  320 Jul 14 18:32 https---github.com-bond-os-r10k-test.git

Copy link
Contributor

@mwaggett mwaggett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
cats in sunglasses saying thanks! you're cool.

@mwaggett mwaggett merged commit 5c2b136 into puppetlabs:main Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants