Problem
Consider this file tree as my development repository.
- foo/ - .git/ - [...] - bar/ - backupclient.py - supersecretstoragecredentials.ini
For development, supersecretstoragecredentials.ini
needs to be filled in with valid credentials - while I still have to keep a clean version of it in the repository so that other users can easily set their credentials.
Possible solutions
.gitignore
supersecretstoragecredentials.ini
and create a supersecretstoragecredentials.ini-example
,
supersecretstoragecredentials.ini-example
to supersecretstoragecredentials.ini
.backup.py
which is ignored by git, e.g. supersecretstoragecredentials_local.ini
.As kan pointed out, these two solutions are similar but not entirely the same, workflow-wise.
are there any other alternatives? Does git
possess some kind of functionality to assist with this kind issues?
git-secrets scans commits, commit messages, and --no-ff merges to prevent adding secrets into your git repositories. If a commit, commit message, or any commit in a --no-ff merge history matches one of your configured prohibited regular expression patterns, then the commit is rejected.
GitHub uses a libsodium sealed box to help ensure that secrets are encrypted before they reach GitHub and remain encrypted until you use them in a workflow. For secrets stored at the organization-level, you can use access policies to control which repositories can use organization secrets.
Check in the supersecretstoragecredentials.ini file with some placeholder values and then
git update-index --assume-unchanged supersecretstoragecredentials.ini
Git will not track future changes to this file.
You can reset this using
git update-index --no-assume-unchanged supersecretstoragecredentials.ini
What you are describing in Option 1 is basically covered by the smudge
step of a content filter driver.
You have the two options presented in the "How to work on a drop-in library?" question.
the smudge script would take your supersecretstoragecredentials.ini-example
(versioned), copy it as a supersecretstoragecredentials.ini
(not versioned, ignored by Git), and fill its values from another source.
But beside the technical aspect of how you will implement your policy, the main measure is to make sure your secret values aren't store in a Git repo at all, but are comming from another referential.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With