cc-safe-setup 29.6.16 → 29.6.17
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,61 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# disk-partition-guard.sh — Block disk partitioning and mount operations
|
|
3
|
+
#
|
|
4
|
+
# Solves: Claude Code running disk operations that can cause data loss
|
|
5
|
+
# or system instability. Mounting/unmounting, partitioning, and
|
|
6
|
+
# formatting are irreversible on production systems.
|
|
7
|
+
#
|
|
8
|
+
# Detects:
|
|
9
|
+
# mount / umount (filesystem mount operations)
|
|
10
|
+
# fdisk / parted / gdisk (partition table editors)
|
|
11
|
+
# mkfs / mkswap (filesystem/swap creation)
|
|
12
|
+
# dd if= (raw disk writes)
|
|
13
|
+
# swapon / swapoff (swap management)
|
|
14
|
+
#
|
|
15
|
+
# Does NOT block:
|
|
16
|
+
# df / lsblk / blkid (read-only disk info)
|
|
17
|
+
# mount (no args) (list mounts)
|
|
18
|
+
#
|
|
19
|
+
# TRIGGER: PreToolUse MATCHER: "Bash"
|
|
20
|
+
|
|
21
|
+
INPUT=$(cat)
|
|
22
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
23
|
+
|
|
24
|
+
[ -z "$COMMAND" ] && exit 0
|
|
25
|
+
|
|
26
|
+
# Block partition editors
|
|
27
|
+
if echo "$COMMAND" | grep -qE '\b(fdisk|parted|gdisk|cfdisk|sfdisk)\b'; then
|
|
28
|
+
echo "BLOCKED: Disk partitioning tool detected." >&2
|
|
29
|
+
echo " Partitioning can cause irreversible data loss." >&2
|
|
30
|
+
exit 2
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Block filesystem creation
|
|
34
|
+
if echo "$COMMAND" | grep -qE '\b(mkfs|mkswap|mke2fs)\b'; then
|
|
35
|
+
echo "BLOCKED: Filesystem creation/formatting detected." >&2
|
|
36
|
+
exit 2
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# Block mount/umount with arguments
|
|
40
|
+
if echo "$COMMAND" | grep -qE '\bumount\b|\bumount\b'; then
|
|
41
|
+
echo "BLOCKED: Unmounting filesystem can cause data loss." >&2
|
|
42
|
+
exit 2
|
|
43
|
+
fi
|
|
44
|
+
if echo "$COMMAND" | grep -qE '\bmount\s+\S' && ! echo "$COMMAND" | grep -qE '\bmount\s*$'; then
|
|
45
|
+
echo "BLOCKED: Mounting filesystem requires administrator oversight." >&2
|
|
46
|
+
exit 2
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Block dd (raw disk writes)
|
|
50
|
+
if echo "$COMMAND" | grep -qE '\bdd\s+if='; then
|
|
51
|
+
echo "BLOCKED: Raw disk write (dd) detected." >&2
|
|
52
|
+
exit 2
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
# Block swap management
|
|
56
|
+
if echo "$COMMAND" | grep -qE '\b(swapon|swapoff)\b'; then
|
|
57
|
+
echo "BLOCKED: Swap management operation detected." >&2
|
|
58
|
+
exit 2
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
exit 0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# user-account-guard.sh — Block user/group account modifications
|
|
3
|
+
#
|
|
4
|
+
# Solves: Claude Code creating, deleting, or modifying system user
|
|
5
|
+
# accounts which can create security backdoors or lock out
|
|
6
|
+
# legitimate users.
|
|
7
|
+
#
|
|
8
|
+
# Detects:
|
|
9
|
+
# useradd / adduser (create user)
|
|
10
|
+
# userdel / deluser (delete user)
|
|
11
|
+
# usermod (modify user)
|
|
12
|
+
# passwd (change password)
|
|
13
|
+
# groupadd / groupdel (group management)
|
|
14
|
+
# visudo / sudoers editing (privilege escalation)
|
|
15
|
+
#
|
|
16
|
+
# TRIGGER: PreToolUse MATCHER: "Bash"
|
|
17
|
+
|
|
18
|
+
INPUT=$(cat)
|
|
19
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
20
|
+
|
|
21
|
+
[ -z "$COMMAND" ] && exit 0
|
|
22
|
+
|
|
23
|
+
if echo "$COMMAND" | grep -qE '\b(useradd|adduser|userdel|deluser|usermod|groupadd|groupdel|groupmod)\b'; then
|
|
24
|
+
echo "BLOCKED: User/group account modification detected." >&2
|
|
25
|
+
echo " Creating or modifying system accounts requires administrator oversight." >&2
|
|
26
|
+
exit 2
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
if echo "$COMMAND" | grep -qE '\bpasswd\b'; then
|
|
30
|
+
echo "BLOCKED: Password change detected." >&2
|
|
31
|
+
exit 2
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
if echo "$COMMAND" | grep -qE '\bvisudo\b|/etc/sudoers'; then
|
|
35
|
+
echo "BLOCKED: Sudoers modification (privilege escalation risk)." >&2
|
|
36
|
+
exit 2
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "29.6.
|
|
4
|
-
"description": "One command to make Claude Code safe.
|
|
3
|
+
"version": "29.6.17",
|
|
4
|
+
"description": "One command to make Claude Code safe. 440 example hooks + 8 built-in. 52 CLI commands. 5855 tests. Works with Auto Mode.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|