Back to docs

Installation Methods

Git Pre-commit Hook

The Git Pre-commit Hook is the easiest way to prevent hardcoded secrets from ever leaving your machine.

Installation

Create a file at .git/hooks/pre-commit and paste the following bash script:

#!/bin/bash
DIFF=$(git diff --cached)
if [ -z "$DIFF" ]; then exit 0; fi

# We recommend pointing this to your BLAZLE Local Proxy (Edge Node)
RESPONSE=$(curl -s -X POST http://localhost:8081/intercept/diff \
  -H "Authorization: Bearer blz_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"diff\": $(echo "$DIFF" | jq -Rs .)}")

ALLOWED=$(echo "$RESPONSE" | jq -r '.allowed')
if [ "$ALLOWED" = "false" ]; then
  echo "🚨 BLAZLE: Security risks detected in commit!"
  echo "$RESPONSE" | jq -r '.findings[] | "- \(.description)"'
  exit 1
fi
exit 0

Make the hook executable: chmod +x .git/hooks/pre-commit