Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Pre-commit hook to prevent sensitive data leaks

set -e

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

echo "🔍 Checking for sensitive files..."

# Critical patterns to block
blocked_patterns=(
"canary-.*/"
"node[0-9]+/"
"cluster-lock\.json"
"validator_keys/"
"keystore-.*\.(json|txt)"
"charon-enr-private-key"
".*private.*key"
)
Comment on lines +13 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just add those to .gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR add them to both


found_issues=0
for file in $(git diff --cached --name-only); do
for pattern in "${blocked_patterns[@]}"; do
if echo "$file" | grep -qE "$pattern"; then
echo -e "${RED}❌ BLOCKED: $file (matched: $pattern)${NC}"
found_issues=1
fi
done
done

if [ $found_issues -eq 0 ]; then
echo -e "${GREEN}✅ No sensitive files detected${NC}"
else
echo -e "${RED}Remove sensitive files before committing!${NC}"
exit 1
fi
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ data/
.charon
prometheus/prometheus.yml
commit-boost/config.toml

# Cluster data and keys
**/canary-*/
**/node[0-9]*/
**/cluster-lock.json
**/validator_keys/
**/keystore-*.json
**/keystore-*.txt
**/charon-enr-private-key
Loading