README
¶
prehook
Stop secrets before they ship. prehook is a single-binary CLI that installs local pre-commit and pre-push Git hooks to scan for leaked secrets, vulnerable dependencies, and code quality issues -- before your code ever leaves your machine.
Install
From source (requires Go 1.23+)
go install github.com/arunsanna/prehook@latest
Homebrew (macOS / Linux)
brew tap arunsanna/tap
brew install prehook
Scoop (Windows)
scoop bucket add arunsanna https://github.com/arunsanna/scoop-bucket
scoop install prehook
Binary download
Download the latest release from the Releases page.
| Platform | Archive | Binary |
|---|---|---|
| macOS | prehook_*_darwin_amd64.tar.gz / arm64 |
prehook |
| Linux | prehook_*_linux_amd64.tar.gz / arm64 |
prehook |
| Windows | prehook_*_windows_amd64.zip / arm64 |
prehook.exe |
Extract and place the binary somewhere on your PATH.
Quickstart
- Initialize config in your repository root:
prehook init
- Install managed hooks:
prehook install
- Check local dependencies:
prehook doctor
- Enforce pinned scanner versions (optional hard mode):
prehook doctor --require-pins
Commands
prehook initcreates.prehook.yamlwith secure defaults.prehook installinstalls managedpre-commitandpre-pushhooks.prehook doctorvalidates required scanner binaries and configured version pins.prehook run --stage pre-commit|pre-pushruns stage gates directly.prehook cleanupprints manual secret remediation guidance.prehook versionprints the CLI version.
Stage Behavior
pre-commit
- Builds a temporary snapshot from the Git index (not the working tree).
- Runs
gitleaksandtrufflehogagainst staged content. trufflehogpolicy defaults to block verified secrets and warn on unknown/unverified findings.- Blocks commit on scanner failures by default.
pre-push
- Computes changed files from pre-push refs; falls back to
HEAD~1..HEADwhen refs are absent. - Runs
semgrepon changed files. - Runs
osv-scannerwhen dependency manifest or lock files changed. - Runs
trivyfilesystem scan with configured severity. - Runs quality test command and optional coverage command + threshold gate.
- Blocks push on failures by default.
Tool Dependencies
prehook delegates scanning to external tools. Install the ones you enable in .prehook.yaml:
| Tool | Required by | macOS / Linux | Windows |
|---|---|---|---|
git |
all | preinstalled / apt install git |
git-scm.com |
gitleaks |
pre-commit | brew install gitleaks |
scoop install gitleaks |
trufflehog |
pre-commit | brew install trufflehog |
GitHub releases |
semgrep |
pre-push | brew install semgrep / pip install semgrep |
pip install semgrep |
osv-scanner |
pre-push | brew install osv-scanner |
scoop install osv-scanner |
trivy |
pre-push | brew install trivy |
scoop install trivy |
git-filter-repo |
cleanup (optional) | brew install git-filter-repo |
pip install git-filter-repo |
Run prehook doctor after installing to verify everything is found and version-compatible.
Example Config
version: 1
pre_commit:
blocking: true
gitleaks:
enabled: true
blocking: true
timeout: 2m
trufflehog:
enabled: true
blocking: true
timeout: 2m
block_verified: true
block_unknown: false
pre_push:
blocking: true
semgrep:
enabled: true
blocking: true
timeout: 5m
osv:
enabled: true
blocking: true
timeout: 5m
trivy:
enabled: true
blocking: true
timeout: 8m
severity: HIGH,CRITICAL
quality:
enabled: true # opt-in: set your own test command
blocking: true
test_command: go test ./... # replace with your language's test runner
test_timeout: 10m
coverage:
enabled: true
blocking: true
command: go test ./... -coverprofile=coverage.out
timeout: 15m
threshold: 60
file: coverage.out
tool_versions:
gitleaks: ">=8.0.0"
trufflehog: ">=3.0.0"
semgrep: ">=1.0.0"
osv_scanner: ">=1.0.0"
trivy: ">=0.50.0"
allowlist:
- pattern: "example-test-secret"
reason: "fixture data"
owner: "security@company.com"
expires_on: "2026-12-31"
Homebrew Tap Packaging
- Compute source tarball sha256 for
vX.Y.Z. - Render formula from template:
packaging/scripts/prepare-homebrew-formula.sh \
--owner <github-owner> \
--repo <github-repo> \
--version <x.y.z>
- Copy
packaging/homebrew/prehook.rbinto your tap repo underFormula/prehook.rb. - Publish release artifacts with
goreleaser.
Advanced manual rendering: packaging/scripts/render-homebrew-formula.sh.
Template file: packaging/homebrew/prehook.rb.tmpl.
Caveat
Git hooks are local controls and can be bypassed intentionally with --no-verify. Treat prehook as a local guardrail, not a complete enforcement layer.
Documentation
¶
There is no documentation for this package.