A pre-commit hook to verify that sensitive files are encrypted with SOPS before being committed.
- Checks for unencrypted sensitive files before commit
- Default patterns for common sensitive files (
.env,.envrc, etc.) - Support for custom patterns via
.sops-required-files - Skips gitignored files automatically
- Comprehensive test suite
- Automatic updates via
latesttag
-
Install pre-commit
-
Add this to your
.pre-commit-config.yaml:
repos:
- repo: https://github.com/timmyb824/sops-file-encryption-checker
rev: latest # Always use the latest version
hooks:
- id: sops-encryption-check- Install the pre-commit hook:
pre-commit installThe following file patterns are checked by default:
.env.envrc*.keysecrets.*credentials.*
Create a .sops-required-files file in your repository root to specify additional files or patterns to check:
secrets/production.yaml
*.secret
config/*.key
# Make scripts executable
chmod +x scripts/sops-check.sh
chmod +x test/test-sops-check.sh
# Run tests
./test/test-sops-check.shThe project includes a GitHub Actions workflow that:
- Runs the test suite
- Verifies the pre-commit hook configuration
- Tests against the latest version of SOPS
- Automatically updates the
latesttag on successful tests
The latest tag is automatically updated whenever tests pass on the main branch, ensuring that users always get the most recent working version.
MIT