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

RepositoryUrl may contain username and password #122

Closed
sbj42 opened this issue Sep 18, 2020 · 0 comments · Fixed by #123
Closed

RepositoryUrl may contain username and password #122

sbj42 opened this issue Sep 18, 2020 · 0 comments · Fixed by #123

Comments

@sbj42
Copy link
Contributor

sbj42 commented Sep 18, 2020

In a CI job, the git remote URL may contain sensitive information such as a username and password. For instance GitLab Runner jobs store a username gitlab-ci-token with a generated password for that job. GitInfo stores the remote URL in its RepositoryUrl field, and so that "token" password is leaked in the build output.

Steps to reproduce:

You can run the following command on any GitInfo-using project and check out the RepositoryUrl to see that the password is still stored:

git remote set-url origin https://jdoe:[email protected]/example.git

For a complete example:

  1. Clone https://github.com/sbj42/GitInfo-password-issue.git
  2. Set the remote url with this command: git remote set-url origin https://jdoe:[email protected]/example.git
  3. Open the solution in Visual Studio, build it, and run the resulting executable.

Expected results:

The output should not print the username and password portions of the remote URL.

The RepositoryUrl (which the program will print) should be https://example.com/example.git.

Actual results:

The program prints:

Hello World! https://jdoe:[email protected]/example.git

Recommendation

I don't know msbuild very well, but from browsing GitInfo.targets it looks like you can use regular expressions. So a possible solution would be to transform the RepositoryUrl with a regexp, replacing ://[^/]*@ with ://.

@kzu kzu closed this as completed in #123 Sep 21, 2020
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants