Pre-commit Hook
whac scan --staged scans the staged version of each changed file. It
reports only findings on the lines that the commit adds. A secret that is
already in the repository does not block the commit.
Use the pre-commit framework
Section titled “Use the pre-commit framework”-
Add this entry to
.pre-commit-config.yaml:repos:- repo: https://github.com/infrashift/whac-a-leakrev: v0.2.0hooks:- id: whac -
Run
pre-commit install. -
Stage a file that contains a fake token, then run
git commit.
- Expected result: the hook prints the finding, and git stops the commit.
The hook builds whac with Go 1.25 or newer. Update rev with
pre-commit autoupdate when a new release exists.
Use a plain git hook
Section titled “Use a plain git hook”-
Build whac with
make build, and putbin/whacon yourPATH. -
Create the file
.git/hooks/pre-commitwith this content:#!/bin/shexec whac scan --staged -
Run
chmod +x .git/hooks/pre-commit.
- Expected result:
git commitruns whac first. A finding stops the commit with exit code1.
Handle a finding
Section titled “Handle a finding”- Remove the secret from the staged file, then rotate the secret.
- For a false positive, add
whac:ignoreto the line, or runwhac allow add <fingerprint> --reason "…".
Do not use git commit --no-verify to skip the hook for a real secret.