this post was submitted on 07 Jun 2024
532 points (98.4% liked)
Technology
59575 readers
3481 users here now
This is a most excellent place for technology news and articles.
Our Rules
- Follow the lemmy.world rules.
- Only tech related content.
- Be excellent to each another!
- Mod approved content bots can post up to 10 articles per day.
- Threads asking for personal tech support may be deleted.
- Politics threads may be removed.
- No memes allowed as posts, OK to post as comments.
- Only approved bots from the list below, to ask if your bot can be added please contact us.
- Check for duplicates before posting, duplicates may be removed
Approved Bots
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
One of the first things you should do in a repo is add a .gitignore file and make sure there are rules to ignore things like
*secret*
or*private*
etc. Also, I pretty much never usegit add .
because I don't like the laziness of it and EVERY TIME one of my coworkers checked in secrets they were using that command.Even though that's a good extra precaution, per person config data, such as keys, should be stored outside of the repo, eg. in the parent directory or better in the users home dir. There is zero reason to have it in the repo. Even if you use a VM/containers, you can add the config in an extra mount/share.
What's the general consensus on storing encrypted data in the repo with the keys outside? I see people recommend that but I'm too paranoid and my secrets are very small in size so it hasn't been necessary.
the format of the encrypted file can give the attackers an advantage. if your code reads the decrypted file, the attacker can guess the first line is a comment or the name of a setting. a savvy person can combine that with the algorithm to perform a "known plaintext attack", for example by generating a number of possible passwords that would lead to files starting like that.
That's smart. Anyone trying that should definitely have a machine-generated strong password!
That's not quite the definition of known plaintext attack (cryptography nerd here), that's bruteforce with a "crib" to use older terminology (known patterns which allows you to test candidate keys).
A known plaintext attack is defined as an attack on the algorithm to extract the key faster than bruteforce with analytical attacks.
I've seen that done for configuration management like Salt or Ansible. The repos for that were always hosted on internal Gitlab instances though.
I see some of that in my job. We put encrypted data in settings files, and the keys for decryption are provided on the VMs where we deploy. The developers never actually see the keys.
I suppose it's as secure as the process for managing the production VMs, assuming the encryption isn't just md5!
I basically always do a
git add -p
Very useful command and it works with other git commands as well.
Everytime a colleague asks me for help with git that’s the one rule I suggest them to use.
What does that do?
Instead of just adding whole changed files, it starts an interactive mode where it shows every hunk of diffs one by one, and asks you to input yes or no for each change. Very helpful for doing your own mini code review or sanity check before you even commit.
I use vscode with plugins and manually add my files now. The workflow is beautiful.
If you ever Stage Selected Range in VSCode, that accomplishes basically the same thing as
git add -p
!That’s exactly why I do it
The
s
option is very useful to split the chunks.Better yet you can configure gitignore globally for git. I do this mostly to avoid polluting repo ignore files with my editor specific junk but *.key and similar can help prevent accidents.
https://git-scm.com/docs/gitignore
For personal projects that's definitely a good idea. For team projects I like to keep that stuff in the project still so the "experience" of working in the project is mostly consistent.
I started using git-secret 2 years ago. It's nice for making secrets part of the repo, while not being readable by anyone that isn't explicitely allowed to do so (using GPG).
I think you really need the project specific gitignore as well, to make sure any other contributor that joins by default has the same protections in place.
I never understood why everyone uses it as a ignore list. In my own and work repositories I always exclude everything by default and re-add stuff explicitly. I have had enough random crap checked in in the past by coworkers. Granted, the whole source folder is fully included but that has never been a problem.
git add -u
is pretty nice, it only adds modified files.I usually do
git add -p
which is interactive (helps avoid committing debugging prints and whatnot), but the other is nice for bigger refactors.