Skip to content

Scan for plaintext secrets and install the hook

vaultfold scan looks for plaintext secrets. The pre-commit hook runs it on every commit.

  • A git repository (scan can also take file paths anywhere).
  • Somewhere to put what you find: a vault to move values into (see store and read).

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.

Terminal window
vaultfold scan
vaultfold scan config/prod.env

--staged scans the staged content of files, so a fix in the working tree that is not staged does not hide a leak.

Terminal window
git add config/prod.env
vaultfold scan --staged

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.

Terminal window
vaultfold add prod/aws#access_key --stdin
vaultfold link config/prod.env AWS_KEY vault://prod/aws#access_key

vaultfold init installs the hook for you. In a repository that predates it, or after removing it:

Terminal window
vaultfold hook install
vaultfold hook uninstall

With 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.

  • Vault commands start the agent daemon and unlock once, for example the add in the fix above. Set VAULTFOLD_NO_AGENT=1 to skip the daemon and unlock in-process for that command only.
  • scan is 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.