-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·30 lines (27 loc) · 1.03 KB
/
pre-commit
File metadata and controls
executable file
·30 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Check if gitleaks is configured
if ! command -v gitleaks &> /dev/null; then
echo "============================================================"
echo "❌ ERROR: Gitleaks not detected."
echo "This is a required tool to prevent sensitive information leaks."
echo ""
echo "Please install gitleaks first:"
echo " macOS: brew install gitleaks"
echo " Other: https://github.com/gitleaks/gitleaks#installing"
echo ""
echo "After installation, run: ./.git-hooks/install-hooks.sh"
echo "============================================================"
exit 1
fi
# Check for sensitive information
if [ -f ".gitleaks.toml" ]; then
gitleaks detect --source . --config .gitleaks.toml
if [ $? -ne 0 ]; then
echo "❌ Gitleaks detected sensitive information. Commit rejected."
echo "Please review the output above and remove sensitive information."
exit 1
fi
else
echo "⚠️ No .gitleaks.toml configuration file found, skipping sensitive information check."
fi
exit 0