Scan for plaintext secrets and install the hook
vaultfold scan looks for plaintext secrets. The pre-commit hook runs it on
every commit.
Prerequisites
Section titled “Prerequisites”- A git repository (
scancan also take file paths anywhere). - Somewhere to put what you find: a vault to move values into (see store and read).
Scan the working tree or specific files
Section titled “Scan the working tree or specific files”With no arguments scan checks the working tree. It exits 2 when it finds
something and prints the file and line, never the whole value.
vaultfold scanvaultfold scan config/prod.envScan what is about to be committed
Section titled “Scan what is about to be committed”--staged scans the staged content of files, so a fix in the working tree
that is not staged does not hide a leak.
git add config/prod.envvaultfold scan --stagedFix a finding
Section titled “Fix a finding”Move the value into the vault and replace it in the file with a reference.
A false positive can carry a trailing vaultfold:allow comment.
vaultfold add prod/aws#access_key --stdinvaultfold link config/prod.env AWS_KEY vault://prod/aws#access_keyInstall and remove the hook
Section titled “Install and remove the hook”vaultfold init installs the hook for you. In a repository that predates it,
or after removing it:
vaultfold hook installvaultfold hook uninstallWith the hook installed, a commit that contains a finding is blocked and
the message tells you how to commit anyway once with git commit --no-verify.
Current limitations
Section titled “Current limitations”- Vault commands start the agent daemon and unlock once, for example the
addin the fix above. SetVAULTFOLD_NO_AGENT=1to skip the daemon and unlock in-process for that command only. scanis a heuristic, so it can miss a secret and can flag a harmless string.- The hook is per repository and can be bypassed with
--no-verify. vaultfold redact, for masking vault values in arbitrary text, is not available yet.