nexo-brain 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ #!/bin/bash
2
+ # Pre-commit hook: prevent private data from being committed to the public repo.
3
+ # Installed by create-nexo or manually: cp scripts/pre-commit-check.sh .git/hooks/pre-commit
4
+
5
+ RED='\033[0;31m'
6
+ NC='\033[0m'
7
+
8
+ # Add patterns specific to your private data here.
9
+ # These are checked against staged files to prevent accidental leaks.
10
+ # The pre-commit-check.sh script itself is excluded from scanning.
11
+ BLOCKED_PATTERNS=(
12
+ # Add your own patterns below, e.g.:
13
+ # "my-private-api-key"
14
+ # "my-private-domain.com"
15
+ # "my-server-ip"
16
+ )
17
+
18
+ STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR)
19
+
20
+ if [ -z "$STAGED_FILES" ]; then
21
+ exit 0
22
+ fi
23
+
24
+ FOUND=0
25
+ for pattern in "${BLOCKED_PATTERNS[@]}"; do
26
+ MATCHES=$(echo "$STAGED_FILES" | xargs grep -l "$pattern" 2>/dev/null)
27
+ if [ -n "$MATCHES" ]; then
28
+ echo -e "${RED}BLOCKED: Found private data pattern '$pattern' in:${NC}"
29
+ echo "$MATCHES" | sed 's/^/ /'
30
+ FOUND=1
31
+ fi
32
+ done
33
+
34
+ # Also check for .db files, tokens, credentials
35
+ DB_FILES=$(echo "$STAGED_FILES" | grep -E '\.(db|db-wal|db-shm|key|pem)$')
36
+ if [ -n "$DB_FILES" ]; then
37
+ echo -e "${RED}BLOCKED: Database/key files staged:${NC}"
38
+ echo "$DB_FILES" | sed 's/^/ /'
39
+ FOUND=1
40
+ fi
41
+
42
+ TOKEN_FILES=$(echo "$STAGED_FILES" | grep -E '_token\.|credentials|\.env$')
43
+ if [ -n "$TOKEN_FILES" ]; then
44
+ echo -e "${RED}BLOCKED: Token/credential files staged:${NC}"
45
+ echo "$TOKEN_FILES" | sed 's/^/ /'
46
+ FOUND=1
47
+ fi
48
+
49
+ if [ $FOUND -eq 1 ]; then
50
+ echo ""
51
+ echo -e "${RED}Commit blocked. Remove private data before pushing to public repo.${NC}"
52
+ exit 1
53
+ fi
54
+
55
+ exit 0