-
Notifications
You must be signed in to change notification settings - Fork 981
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
[feature] The git clone URL is no longer logged. #15684
Comments
Hi @shoeffner Thanks very much for your feedback. I am afraid this is not a bug, this was done deliberately, based on 2 things:
So overall, it was a trade-off between security and convenience, and in this case the balance clearly went in the direction of security.
That sounds nice and convenient, as long as users explicitly opt-in to print the URLs, I am good, if you want to contribute it, it will be welcome. Are you considering a |
Thanks, I was aware it's not really a bug, but was not sure what else from the issue templates would fit best; I agree feature is a good idea. I also completely understand the decision, which is why I also linked to the related issues and the merge request, and I certainly welcome security considerations -- in fact, that's the reason why we were looking at alternatives for authentication when Conan removed the credentials from the scm tools with Conan 2 and decided to let git handle it instead of encoding credentials in URLs.
That would be the simple option to re-enable logging and is what I had in mind, but I am note sure if it is a good idea to "bloat" up the API here with such a flag. Now that I spend another hour pondering on the subject, I think it might not be. I do not really know how other users perform the authentication right now, and I hope they do not store the credentials inside the recipe itself. If they provide them in the way "username" and "password/token", I could imagine two ways to solve authentication to disarm the credential-leak potential of printing the URL: First, one could use credential arguments (or git = Git(self, username=..., password=...)
git = Git(self, ssh_public_key=...)
git = Git(self, auth=(<username>, <password>)) The second option would be handle authentication similar to The first option would allow to use the Git wrapper for multiple repositories with different credentials; this is difficult for the second option. In both cases, it would be possible to allow to print the URL in multiple ways:
Or, of course, masking inside the credential helper, to prevent using extra environment variables for the
One major caveat is in any cases escaping the credentials properly for the shell, as shlex.quote (which is for unix systems) does not handle Long story short: For the short term, simply adding But especially for the git authentication, we should definitely discuss the details more to avoid a half-baked solution which has to be carried around. In fact, after initial confusion how to do authentication, we applauded the fact that Conan 2 moved the responsibility of authentication to git and the relevant tools, so that Conan does not need to handle credentials at all. But if it leads to recipe URLs containing credentials, this is certainly something worth discussing. |
Yes, mostly Conan 1.X did in fact a lot of effort to hide that password by parsing URLs, more or less with the strategies you describe, but that is difficult to make 100% perfect, so better not doing it at all than leaking 1% of our users doing this, with so many thousands it will be a bunch of them, and we cannot afford even a single one. I agree that providing auth for Git with Conan shouldn't be rushed, and doing it carefully is better, so we will keep recommending the git-provided credentials at the moment and keep monitoring the potential demand for this. Thanks for all the feedback! |
Thanks for the insights! While I did not consider url parsing yet, it sounds like a good idea, what are the cases which are hard to do? Shouldn't the standard library got this covered already? from urllib.parse import urlparse
res = urlparse("https://username:password@example.com/some/url/repo.git")
if res.username:
cmd = cmd.replace(res.username, "<hidden>")
if res.password:
cmd = cmd.replace(res.password, "<hidden>") Also, every CI system I know has some way to mask variables from any log output, so I am really not sure this should be something conan must be concerned with; for example, Jenkins GitSCM does not bother hiding URLs and instead relies on Jenkins to mask usernames and passwords from the logs, so does the GitLab CI. If the clone takes long, credentials might still be exposed either way, e.g. to other processes running on the build machine, you can simulate this with:
Which will show:
Granted, this is a non-trivial take-over and logs are much easier, but it's also something to consider. In any case, I will be happy to either provide an argument |
Following up from your comment in the other issue. I am fine with a |
I will have a look at it, thanks for the feedback! |
* Add hide_url tests for git scm tool * Add hide_url flag to clone and fetch_commit. Resolves #15684 * Update conans/test/functional/tools/scm/test_git.py * Update conans/test/functional/tools/scm/test_git.py --------- Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
* Add hide_url tests for git scm tool * Add hide_url flag to clone and fetch_commit. Resolves conan-io#15684 * Update conans/test/functional/tools/scm/test_git.py * Update conans/test/functional/tools/scm/test_git.py --------- Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
* Add hide_url tests for git scm tool * Add hide_url flag to clone and fetch_commit. Resolves conan-io#15684 * Update conans/test/functional/tools/scm/test_git.py * Update conans/test/functional/tools/scm/test_git.py --------- Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
* cmake deps internal refactor for readability * fix * fix * fix * fix * fix * copy only if different (#16031) * allow conf in exports-sources and export (#16034) * refactor apple_min_version_flag() (#16017) * refactor apple_min_version_flag() * Refactored all the apple module and where it was being used (AutotoolsToolchain and MesonToolchain for now) * Fixed bad return * Fixing tests * Keeping legacy behavior in apple_min_version_flag function * Preventing possible breaking change --------- Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com> * Allow to unhide git url (#16038) * Add hide_url tests for git scm tool * Add hide_url flag to clone and fetch_commit. Resolves #15684 * Update conans/test/functional/tools/scm/test_git.py * Update conans/test/functional/tools/scm/test_git.py --------- Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> * remove repeated non-running test (#16053) * refactor transitive_requires --------- Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com> Co-authored-by: Sebastian Höffner <info@sebastian-hoeffner.de> Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
* wip * wip * wip * Test for BazelDeps in the build context (#16025) * feat add test to bazeldeps * Fixed several bugs. Improved tests coverage * Reverted * Better name --------- Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com> * copy only if different (#16031) * allow conf in exports-sources and export (#16034) * refactor apple_min_version_flag() (#16017) * refactor apple_min_version_flag() * Refactored all the apple module and where it was being used (AutotoolsToolchain and MesonToolchain for now) * Fixed bad return * Fixing tests * Keeping legacy behavior in apple_min_version_flag function * Preventing possible breaking change --------- Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com> * Allow to unhide git url (#16038) * Add hide_url tests for git scm tool * Add hide_url flag to clone and fetch_commit. Resolves #15684 * Update conans/test/functional/tools/scm/test_git.py * Update conans/test/functional/tools/scm/test_git.py --------- Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> * wip * wip * wip * fix * Update conan/tools/build/cstd.py Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> * Update conan/tools/build/cstd.py Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> * Update conan/tools/build/cstd.py Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> --------- Co-authored-by: Ernesto de Gracia Herranz <vivalaburocracia@hotmail.com> Co-authored-by: Francisco Ramirez de Anton <franchuti688@gmail.com> Co-authored-by: Sebastian Höffner <info@sebastian-hoeffner.de> Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
Environment details
Steps to reproduce
Any Git(self).clone command will no longer log the URL, instead show
<hidden>
.Logs
We fork all our thirdparties internally so we have stable URLs in case they disappear and to avoid hitting external servers too much. As a side-effect, we build up our URLs as
https://internalgitserver/our-thirdparties/{name}.git
(and potentially usegit@internalgitserver:our-thirdparites/{name}.git
for local development).Since Conan 2 removed the authentication options initially (see e.g. conan-io/docs#2918), we are using git credential.helpers which we configure in our CI pipelines, which makes it trivial to provide credentials via Jenkins, GitLab CI, etc.:
Thus our credentials are masked by the CI runner already and we do not store them inside the recipes or anything.
However, due to the "dynamic" nature of our URLs, it is nice to actually see them -- with the recent change to hide the URLs, it's always a little bit of guesswork if the URL was actually correct.
As a work-around, I added logs for all recipes now, so it's no big blocker, but if there is need, I would offer to provide a patch to make the url-hiding optional.
The text was updated successfully, but these errors were encountered: