forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate-shell.sh
More file actions
59 lines (51 loc) · 1.23 KB
/
Copy pathvalidate-shell.sh
File metadata and controls
59 lines (51 loc) · 1.23 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# Shell command validation hook for Cursor
# Blocks dangerous operations and checks for exposed secrets
set -e
# Get command from stdin
COMMAND="${1:-}"
if [ -z "$COMMAND" ]; then
exit 0
fi
# Dangerous commands to block
DANGEROUS_PATTERNS=(
"rm -rf /"
"rm -rf ~"
"rm -rf \$HOME"
"git push --force"
"git push -f"
"git push origin --force"
"dd if="
"mkfs"
"fdisk"
"format c:"
":(){ :|:& };:"
)
# Check for dangerous patterns
for pattern in "${DANGEROUS_PATTERNS[@]}"; do
if echo "$COMMAND" | grep -qi "$pattern"; then
echo "❌ BLOCKED: Dangerous command detected: $pattern"
exit 1
fi
done
# Check for potential secret exposure
SECRET_PATTERNS=(
"OPENAI_API_KEY="
"DEEPGRAM_API_KEY="
"PINECONE_API_KEY="
"REDIS_DB_PASSWORD="
"GOOGLE_APPLICATION_CREDENTIALS="
"api_key"
"secret"
"password"
"token"
)
# Warn about potential secret exposure (non-blocking)
for pattern in "${SECRET_PATTERNS[@]}"; do
if echo "$COMMAND" | grep -qi "$pattern"; then
echo "⚠️ WARNING: Potential secret exposure detected in command"
echo " Review command before executing: $COMMAND"
fi
done
# Allow command to proceed
exit 0