This script sets up a pre-commit hook for Git that automatically checks for secrets in your code using Gitleaks.
- Python 3
- Git
- Curl (for installation)
- tar
git clone https://github.com/vitalibit/security-pre-commit
cd security-pre-commitRun the Python script pre-commit.py to install Gitleaks and enable the pre-commit hook:
python3 pre-commit.pyOr you can install it with one command:
curl -fsL https://raw.githubusercontent.com/vitalibit/security-pre-commit/main/pre-commit.py | python3 -After the installation, the pre-commit hook will automatically run before each commit. If any secrets or sensitive information are detected by Gitleaks, the commit will be rejected and an error message will be displayed.
To disable the pre-commit hook, you can set the gitleaks.enabled configuration option to false:
git config gitleaks.enabled falseTo enable the pre-commit hook, run the following command:
git config gitleaks.enabled true