The pre-commit hook is run first, before you even type in a commit message. It’s used to inspect the snapshot that’s about to be committed,
It can be used to detect
Pre-commit is a framework for managing and maintaining multi-language pre-commit hooks.
https://github.com/pre-commit/pre-commit
pip install pre-commit
pre-commit installed at .git/hooks/pre-commit
pre-commit --version
pre-commit 1.21.0
We have already created the .pre-commit-config.yaml in the Files directory
cat ~/environment/aws-container-devsecops/content/development/development.files/.pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: detect-private-key
`cd ~/environment/aws-container-devsecops/content/development/development.files''
Using the pre-commit hook cli we can run the checks and see that the commit would fail. pre-commit run --all-files
Detect Private Key.......................................................Failed
- hook id: detect-private-key
- exit code: 1
Private key found: content/development/development.files/secret.yaml