Block unsafe cloud configurations from being committed to version control.
The hook runs stave apply on staged observation, control, and YAML files.
If violations are found (exit code 3), the commit is blocked.
cp contrib/hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitAdd to .pre-commit-config.yaml:
repos:
- repo: https://github.com/sufield/stave
rev: v1.0.0
hooks:
- id: stave-applyInstall:
pre-commit installThe hook:
- Skips if
staveis not in PATH (soft dependency) - Skips if no
controls/directory orstave.yamlexists - Skips if no observation/control/YAML files are staged
- Runs
stave apply --format text - Blocks commit on exit code 3 (violations found)
- Allows commit on exit code 2 (input issues — non-blocking by default)
| Environment Variable | Default | Description |
|---|---|---|
STAVE_PRECOMMIT_PROFILE |
(none) | Compliance profile to evaluate (e.g., hipaa) |
STAVE_PRECOMMIT_STRICT |
0 |
Set to 1 to block on any stave error, not just violations |
STAVE_PRECOMMIT_SKIP |
0 |
Set to 1 to skip the hook entirely |
# Evaluate against HIPAA profile
export STAVE_PRECOMMIT_PROFILE=hipaa
# Strict mode — block on input errors too
export STAVE_PRECOMMIT_STRICT=1
# Emergency bypass
STAVE_PRECOMMIT_SKIP=1 git commit -m "emergency fix"When violations are detected:
stave: checking staged configuration files...
[critical] CTL.S3.PUBLIC.001 — No Public S3 Bucket Read
Asset: production-assets
Duration: 24h (OVERDUE, max 12h)
Exit code 3 — violations detected
stave: violations detected — commit blocked
Fix the violations above, then try again.
To skip: STAVE_PRECOMMIT_SKIP=1 git commit
When clean:
stave: checking staged configuration files...
stave: no violations found
The same evaluation runs in CI without the hook wrapper:
# GitHub Actions / GitLab CI / any CI
stave apply --format text # exit code 3 fails the step
stave apply --format sarif # for GitHub Security tabSee CI/CD Integration for full pipeline setup.
| Path | Description |
|---|---|
contrib/hooks/pre-commit |
Shell script for .git/hooks/ |
.pre-commit-hooks.yaml |
Hook definition for pre-commit framework |