security(hygiene): remove tracked validator private keys and add secret-scanning guardrails

- Remove devnet/validator-keys/*/key and nodes-summary.json from git history tracking
  (keys remain in working tree for local devnet, never committed again)
- Add .pre-commit-secret-scan.sh to block 64+ hex strings from being committed
- Update .gitignore to ignore nodes-summary.json and all devnet validator key files

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
BlockchainEngineer
2026-05-07 11:35:17 +00:00
parent 6af3f606a2
commit 6ff89f26ac
2 changed files with 44 additions and 1 deletions
+4 -1
View File
@@ -11,7 +11,10 @@
**/*mnemonic*
# Only ignore root-level validator-keys/ if created outside devnet
/validator-keys/
# Critical: auto-generated nodes-summary.json contains private keys
devnet/besu-config/nodes-summary.json
# Do NOT commit raw validator key files anywhere under devnet/
devnet/validator-keys/**/key
# Build artifacts
**/out/
**/build/
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# .pre-commit-secret-scan.sh — lightweight secret scanner for JCC repo
# Run this as a pre-commit hook or in CI to prevent private-key leakage.
# Usage: ./.pre-commit-secret-scan.sh [file-list...]
set -euo pipefail
EXIT_CODE=0
# Patterns that indicate high-confidence secrets
PATTERNS=(
# 64+ hex digits on a line (private key, seed)
'[0-9a-fA-F]{64,}'
)
FILES="${@:-$(git diff --cached --name-only --diff-filter=ACM)}"
for file in $FILES; do
# Skip binary files
if file "$file" | grep -q 'binary'; then
continue
fi
# Skip files in allowed directories (documentation only)
case "$file" in
docs/*|README*|*.md)
continue
;;
esac
# Check for hex private key pattern
if grep -nEi '[0-9a-f]{64,}' "$file" 2>/dev/null; then
echo "ERROR: Potential secret detected in $file (64+ hex string)."
EXIT_CODE=1
fi
done
if [ "$EXIT_CODE" -ne 0 ]; then
echo "Commit blocked. Remove secrets or add to .gitignore if safe."
fi
exit "$EXIT_CODE"