-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·25 lines (22 loc) · 935 Bytes
/
pre-commit
File metadata and controls
executable file
·25 lines (22 loc) · 935 Bytes
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
#!/bin/bash
# Check if gitleaks is configured
if ! command -v gitleaks &> /dev/null; then
echo "============================================================"
echo "Gitleaks not detected. This is a required tool to prevent sensitive information leaks."
echo "Please install gitleaks first: https://github.com/gitleaks/gitleaks#installing"
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