-
-
Notifications
You must be signed in to change notification settings - Fork 227
git: Exit clearly when in a "dubious" directory #1235
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
base: main
Are you sure you want to change the base?
Conversation
8672538 to
5c0c447
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for bringing this up and preparing the details
this is indeed a problematic oversight
unfortunately this direly needed correction is also something that may possibly need a opt-out, as bringing it about may break pipelines that "seemed to work"
the new behavior you added is correct, unfortunately we have to account for prior accidental miss-use that's unable to correct timely
so lets add a env var to allow the misbehavior to continue for people unable to currectly fix their pipelines in a timely fashion
however if a git config call can fix the issue as well then we may just document that in the error message instead of adding a opt out env var
i just fear that some ci envs are enough of a mess the env var will still be needed
Yes, I suspect you are right that people hit this and crafted unnecessary |
5d26033 to
386da56
Compare
The output I get in a failure case is There's like 3 levels of warnings (the setuptools_scm |
I hit a _very_ hard to diagnose issue today after switching part of a CI environment. It turns out that due to non-privileged container magic the CI step was not running as the user that cloned the repo. This manifested as the sdist generated during this step just not having a few extra data files; but the build still passed. So several steps later, suddenly files have just vanished from the sdist, which of course is not something that is checked for and so testing blows up in very strange ways. After I understood what was going on, there is a _tiny_ little message hidden amongst the logs that gives a hint of what's going on. ... writing requirements to src/proj.egg-info/requires.txt writing top-level names to src/proj.egg-info/top_level.txt listing git files failed - pretending there aren't any reading manifest file 'src/proj.egg-info/SOURCES.txt' writing manifest file 'src/proj.egg-info/SOURCES.txt' ... What is actually happening is that if you run git you get "git status fatal: detected dubious ownership in repository at '/..proj'". This is the well-known CVE-2022-24765 issue where trusting a `.git` config dir from another user causes problems. In 6a3bb96 all the calls in setuptools_scm/git.py were updated to use `--git-dir` directly -- git will not complain if you have told it to explicitly trust the config dir like this. However, there are calls in _file_finders/git.py to find the top-level that are not using this. It silently (modulo an easily missed log) skips adding files when this occurs. I can not see that this would ever be the behaviour you would want. If it had of exploded telling me the git call failed, it would have short-cut all of the problem finding. This adds an explicit match on the static part of this git failure message and raises a SystemExit if it hits. A test case that mocks such a situation is added. Closes: pypa#784 Signed-off-by: Ian Wienand <[email protected]>
I hit a very hard to diagnose issue today after switching part of a CI environment. It turns out that due to non-privileged container magic the CI step was not running as the user that cloned the repo. This manifested as the sdist generated during this step just not having a few extra data files; but the build still passed. So several steps later, suddenly files have just vanished from the sdist, which of course is not something that is checked for and so testing blows up in very strange ways.
After I understood what was going on, there is a tiny little message hidden amongst the logs that gives a hint of what's going on.
What is actually happening is that if you run git you get
git status fatal: detected dubious ownership in repository at '/..proj'. This is the well-known CVE-2022-24765 issue where trusting a.gitconfig dir from another user causes problems. In 6a3bb96 all the calls insetuptools_scm/git.pywere updated to use--git-dirdirectly -- git will not complain if you have told it to explicitly trust the config dir like this.However, there are calls in
_file_finders/git.pyto find the top-level that are not using this. It silently (modulo an easily missed log) skips adding files when this occurs.I can not see that this would ever be the behaviour you would want. If it had of exploded telling me the git call failed, it would have short-cut all of the problem finding.
This adds an explicit match on the static part of this git failure message and raises a
SystemExitif it hits. A test case that mocks such a situation is added.Closes: #784