Some out-of-the-box hooks for pre-commit.
See also: https://github.com/pre-commit/pre-commit
- Create
.pre-commit-config.yaml
in the root directory - Select the hooks to use, as shown below
repos:
- repo: https://github.com/tanx-libs/precommit-hooks
rev: v1.0.1 # please check the latest release, under releases
hooks:
- id: private_key_check # checkout all hooks under .pre-commit-hooks.yaml
- Run
pre-commit install
in the root directory
Now with every new commit, staged files would be checked
to run the hook throughout the exixting codebase, run pre-commit run --all-files
- Check for any private keys in the staged files
- detects private keys of length
[64,66]
- private keys can also begin with
0x
, - to skip the checks for a line, use
# noqa:keycheck
PRIVATE_ADDRESS="1a4b0778f...e99fc33fff87c821829" # noqa:keycheck
script - pre_commit_hooks/private_key_check.py