cc-safe-setup 29.6.15 → 29.6.16

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,31 @@
1
+ #!/bin/bash
2
+ # dns-config-guard.sh — Block DNS/hosts file modifications
3
+ #
4
+ # Solves: Claude Code modifying /etc/hosts or /etc/resolv.conf which
5
+ # can redirect traffic, break name resolution, or create
6
+ # security vulnerabilities.
7
+ #
8
+ # TRIGGER: PreToolUse MATCHER: "Bash|Edit|Write"
9
+
10
+ INPUT=$(cat)
11
+ TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
12
+
13
+ case "$TOOL" in
14
+ Bash)
15
+ CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
16
+ [ -z "$CMD" ] && exit 0
17
+ if echo "$CMD" | grep -qE '(echo|tee|sed|awk).*(/etc/hosts|/etc/resolv\.conf|/etc/nsswitch)'; then
18
+ echo "BLOCKED: DNS configuration modification detected." >&2
19
+ exit 2
20
+ fi
21
+ ;;
22
+ Edit|Write)
23
+ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
24
+ if echo "$FILE" | grep -qE '/etc/hosts$|/etc/resolv\.conf$|/etc/nsswitch\.conf$'; then
25
+ echo "BLOCKED: Cannot modify DNS configuration file: $FILE" >&2
26
+ exit 2
27
+ fi
28
+ ;;
29
+ esac
30
+
31
+ exit 0
@@ -0,0 +1,61 @@
1
+ #!/bin/bash
2
+ # git-history-rewrite-guard.sh — Block git history rewriting commands
3
+ #
4
+ # Solves: Claude Code rewriting git history which can cause permanent
5
+ # data loss and break shared branches. History rewriting on
6
+ # pushed commits requires force-push and affects all collaborators.
7
+ #
8
+ # Detects:
9
+ # git filter-branch (legacy history rewriter)
10
+ # git filter-repo (modern history rewriter)
11
+ # git rebase -i (interactive rebase, can reorder/squash)
12
+ # git reset --hard HEAD~N (discards recent commits)
13
+ # git reflog expire --all (destroys reflog recovery data)
14
+ #
15
+ # Does NOT block:
16
+ # git rebase <branch> (non-interactive, covered by no-git-rebase-public)
17
+ # git reset --soft (safe, keeps changes staged)
18
+ # git reset --mixed (safe, keeps changes in working tree)
19
+ # git reflog (read-only, viewing history)
20
+ #
21
+ # TRIGGER: PreToolUse MATCHER: "Bash"
22
+
23
+ INPUT=$(cat)
24
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
25
+
26
+ [ -z "$COMMAND" ] && exit 0
27
+
28
+ # Block filter-branch (legacy, dangerous)
29
+ if echo "$COMMAND" | grep -qE '\bgit\s+filter-branch\b'; then
30
+ echo "BLOCKED: git filter-branch rewrites entire repository history." >&2
31
+ echo " This is irreversible on shared branches." >&2
32
+ exit 2
33
+ fi
34
+
35
+ # Block filter-repo
36
+ if echo "$COMMAND" | grep -qE '\bgit\s+filter-repo\b'; then
37
+ echo "BLOCKED: git filter-repo rewrites repository history." >&2
38
+ exit 2
39
+ fi
40
+
41
+ # Block interactive rebase
42
+ if echo "$COMMAND" | grep -qE '\bgit\s+rebase\s+-i\b'; then
43
+ echo "BLOCKED: Interactive rebase can reorder, squash, or drop commits." >&2
44
+ echo " Use non-interactive rebase instead." >&2
45
+ exit 2
46
+ fi
47
+
48
+ # Block git reset --hard with commit count
49
+ if echo "$COMMAND" | grep -qE '\bgit\s+reset\s+--hard\s+(HEAD|origin)'; then
50
+ echo "BLOCKED: git reset --hard discards commits permanently." >&2
51
+ echo " Use 'git reset --soft' to keep changes staged." >&2
52
+ exit 2
53
+ fi
54
+
55
+ # Block reflog destruction
56
+ if echo "$COMMAND" | grep -qE '\bgit\s+reflog\s+(expire|delete)\b'; then
57
+ echo "BLOCKED: Destroying reflog removes the safety net for recovering commits." >&2
58
+ exit 2
59
+ fi
60
+
61
+ exit 0
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ # log-truncation-guard.sh — Block log file truncation/deletion
3
+ #
4
+ # Solves: Claude Code truncating or deleting log files which destroys
5
+ # audit trails and makes debugging incidents impossible.
6
+ #
7
+ # Detects:
8
+ # > /var/log/syslog (truncation via redirect)
9
+ # truncate -s 0 <logfile> (explicit truncation)
10
+ # rm /var/log/* (log deletion)
11
+ # echo "" > <logfile> (content erasure)
12
+ #
13
+ # TRIGGER: PreToolUse MATCHER: "Bash"
14
+
15
+ INPUT=$(cat)
16
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
17
+
18
+ [ -z "$COMMAND" ] && exit 0
19
+
20
+ # Block log file truncation
21
+ if echo "$COMMAND" | grep -qE '>\s*/var/log/|truncate.*(/var/log/|\.log)|rm\s+.*(/var/log/|\.log)'; then
22
+ echo "BLOCKED: Log file truncation/deletion detected." >&2
23
+ echo " Destroying logs removes audit trails." >&2
24
+ echo " Use log rotation instead: logrotate." >&2
25
+ exit 2
26
+ fi
27
+
28
+ exit 0
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ # network-interface-guard.sh — Block network interface modifications
3
+ #
4
+ # Solves: Claude Code modifying network interfaces which can cause
5
+ # immediate loss of connectivity on remote servers.
6
+ #
7
+ # Detects:
8
+ # ifconfig <iface> down (disable interface)
9
+ # ip link set <iface> down (modern equivalent)
10
+ # ip addr del (remove IP address)
11
+ # ip route del (remove route)
12
+ # nmcli connection delete (NetworkManager)
13
+ #
14
+ # TRIGGER: PreToolUse MATCHER: "Bash"
15
+
16
+ INPUT=$(cat)
17
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
18
+
19
+ [ -z "$COMMAND" ] && exit 0
20
+
21
+ # Block interface disable
22
+ if echo "$COMMAND" | grep -qE '\bifconfig\s+\S+\s+down\b'; then
23
+ echo "BLOCKED: Disabling network interface will cause connectivity loss." >&2
24
+ exit 2
25
+ fi
26
+
27
+ # Block ip link/addr/route destructive operations
28
+ if echo "$COMMAND" | grep -qE '\bip\s+(link\s+set\s+\S+\s+down|addr\s+del|route\s+del)\b'; then
29
+ echo "BLOCKED: Network configuration change can cause connectivity loss." >&2
30
+ exit 2
31
+ fi
32
+
33
+ # Block NetworkManager connection deletion
34
+ if echo "$COMMAND" | grep -qE '\bnmcli\s+connection\s+delete\b'; then
35
+ echo "BLOCKED: Deleting NetworkManager connection." >&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.15",
4
- "description": "One command to make Claude Code safe. 434 example hooks + 8 built-in. 52 CLI commands. 5800 tests. Works with Auto Mode.",
3
+ "version": "29.6.16",
4
+ "description": "One command to make Claude Code safe. 438 example hooks + 8 built-in. 52 CLI commands. 5835 tests. Works with Auto Mode.",
5
5
  "main": "index.mjs",
6
6
  "bin": {
7
7
  "cc-safe-setup": "index.mjs"