Block secrets from leaking
Pre-commit hooks
5min
Pre-commit hooks are a useful way to prevent secrets in code from being pushed from a git repository. Preventing them from being leaked in the first place is always the best approach. If you run your own git server, see the pre-receive hooks option which can block commits with secrets from being accepted.
An easy way to get started is to use the pre-commit framework.
Install it via pip:
Then, you will need a .pre-commit-config.yaml file in your repository.
You can place the launcher in your path to use directly, or use Docker.
Once your config is in place, you just need to install the hook and you should be good to go!
Updated 23 Apr 2024
Did this page help you?