News for hackers. Stuff that matters.
Re:Global scan – exposed .git repos by ashton314 on Thursday September 06, 2018 @01:58PM (#17928019)
Why would you ever want to put a git repo on a production server in the first place? Unless you're using the production server for development (gasp) it sounds like a waste of space and (as pointed out here) a major security vulnerability.
Re:Global scan – exposed .git repos by ktpsns on Thursday September 06, 2018 @02:51PM (#17928563)
An answer for Subversion would be: Because "svn update" (http://svnbook.red-bean.com/en/1.8/svn.ref.svn.c.update.html) runs faster then "svn export" (http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.export.html).

For git there is not even an "export" option anymore (cf. https://stackoverflow.com/questions/160608/do-a-git-export-l...), but nevertheless "git pull/push" is an easy way to keep the production server code synced. It is certainly not the best.

Re:Global scan – exposed .git repos by wongarsu on Thursday September 06, 2018 @03:01PM (#17928665)
>It is certainly not the best.

What is the better alternative? Git checkout makes reverting to a previous version fast and convinient, and git's protocol seems more efficient than transmitting the files via scp or similar since most of the files are already there.

I guess I could have a build server rsync the files over, but that seems like a lot of complexity for little gain.

Re:Global scan – exposed .git repos by icebraining on Thursday September 06, 2018 @04:24PM (#17929261)
Git doesn't ensure the checkout process is atomic; it might leave you with an unfinished mess if it fails for some reason.

Also, it means that everything you ever committed on the release branch will be available on a more exposed server.

Re:Global scan – exposed .git repos by _-david-_ on Thursday September 06, 2018 @09:21PM (#17931187)
>What is the better alternative?

This is a bit complicated to do by hand, but this is probably the best way. I would suggest using existing software to handle this though

Create a file that just has "2" with no quotes in it. Create a directory called 1. Create a symlink that points to that directory. Have the webserver use the symlink instead of the actual code directory.

When you want to update code lock the file that has the number in it. Read in the contents of the file. Replace the contents of the file with the next number. Unlock the file. Create a directory with whatever number you read in. Git clone in that new directory. Do whatever else you need to do (compilation or whatever). If all goes well then change a symlink to point to the new directory.

If you need to revert then change the symlink to the old directory. You could also delete old directories as well to save some space.

Re:Global scan – exposed .git repos by cpburns2009 on Thursday September 06, 2018 @05:14PM (#17929600)
Using git pull (or some equivalent) to update a production environment is fragile and just asking for trouble.
Re:Global scan – exposed .git repos by tzs on Thursday September 06, 2018 @03:31PM (#17928912)
You can go a long way toward avoiding the security issue by making good use of the GIT_DIR and GIT_WORK_TREE environment variables.
Re:Global scan – exposed .git repos by nooyurrsdey on Thursday September 06, 2018 @02:03PM (#17928054)
This question basically restate the problem. It's not that people want to do that, they just don't know better
Re:Global scan – exposed .git repos by siruncledrew on Thursday September 06, 2018 @03:17PM (#17928807)
I've seen someone SCP a local git repo to an Amazon EC2 (obviously not best practice) for a manual deployment.