Skip to content

Hatch ignores global .gitignore, leaking private keys #1958

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

Open
skorokithakis opened this issue Apr 18, 2025 · 8 comments
Open

Hatch ignores global .gitignore, leaking private keys #1958

skorokithakis opened this issue Apr 18, 2025 · 8 comments

Comments

@skorokithakis
Copy link

I built a package using hatch, which, unbeknownst to me, ignored my ~/.gitignore_global, including in the package my .envrc with secret keys.

This is a fairly major footgun, as I imagine quite a few packages like this will include files that their authors didn't intend (files which git ignores, so the authors don't realize will be included).

@skorokithakis skorokithakis changed the title Hatch ignores global .gitignore, with disastrous consequences Hatch ignores global .gitignore, leaking private keys Apr 18, 2025
@ofek
Copy link
Collaborator

ofek commented Apr 18, 2025

Hey there Stavros, good to see you again!

There is another similar issue open which I will fix by introducing an option to use the Git CLI. Something to keep in mind about why I choose files by default is because building from the source directory on your local machine or CI is not the only way projects are built and indeed it is the rarest situation. More often than not people build packages using a GitHub release archive or even more frequently the source distributions from PyPI. In these cases there is no Git checkout to speak of.

@skorokithakis
Copy link
Author

Haha, hello! The internet is small.

I definitely agree, but it's usually a good idea to ignore all the files in all the .gitignore files by default, as they're usually build artifacts and the like. What do you mean when you say "the git CLI", would this not just be hatch parsing the ignore files in the same way git does?

@ofek
Copy link
Collaborator

ofek commented Apr 18, 2025

Yes ignore files within the repo are used by default but Git takes into account locations other than the project directory which is the issue here.

@skorokithakis
Copy link
Author

Agreed, but I mean, are you planning to call out to git somehow to get a list of files, or to reimplement its logic?

@ofek
Copy link
Collaborator

ofek commented Apr 18, 2025

To call it directly when the new option is enabled.

@skorokithakis
Copy link
Author

I see, thanks!

@ofek
Copy link
Collaborator

ofek commented Apr 18, 2025

Happy to help! I will post the other issue here sometime tonight when I find it.

OT: this is still one of my favorite contributions skorokithakis/catt#92

@skorokithakis
Copy link
Author

Hahah that was great, I loved it. Such a good PR.

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

No branches or pull requests

2 participants