cc-safe-setup 29.6.8 → 29.6.10
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,41 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# no-force-flag.sh — Block dangerous --force flags
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# --force flags bypass safety checks in package managers and git.
|
|
7
|
+
# This hook blocks common dangerous --force patterns:
|
|
8
|
+
# - npm install --force (ignores peer dependency conflicts)
|
|
9
|
+
# - pip install --force-reinstall (skips cache, wastes time)
|
|
10
|
+
# - git push --force (overwrites remote history)
|
|
11
|
+
# - docker system prune --force (removes all unused data)
|
|
12
|
+
#
|
|
13
|
+
# TRIGGER: PreToolUse
|
|
14
|
+
# MATCHER: "Bash"
|
|
15
|
+
# ================================================================
|
|
16
|
+
|
|
17
|
+
INPUT=$(cat)
|
|
18
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
19
|
+
[ -z "$COMMAND" ] && exit 0
|
|
20
|
+
|
|
21
|
+
# npm install --force / --legacy-peer-deps
|
|
22
|
+
if echo "$COMMAND" | grep -qE 'npm\s+install.*--force|npm\s+i\s.*--force'; then
|
|
23
|
+
echo "BLOCKED: npm install --force bypasses peer dependency checks." >&2
|
|
24
|
+
echo "Fix the dependency conflict instead of forcing." >&2
|
|
25
|
+
exit 2
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# git push --force (not --force-with-lease)
|
|
29
|
+
if echo "$COMMAND" | grep -qE 'git\s+push.*--force($|\s)' && ! echo "$COMMAND" | grep -q 'force-with-lease'; then
|
|
30
|
+
echo "BLOCKED: git push --force can destroy remote history." >&2
|
|
31
|
+
echo "Use --force-with-lease for safer force-push." >&2
|
|
32
|
+
exit 2
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# docker system prune --force
|
|
36
|
+
if echo "$COMMAND" | grep -qE 'docker\s+(system\s+)?prune.*-f|docker\s+(system\s+)?prune.*--force'; then
|
|
37
|
+
echo "BLOCKED: docker prune --force removes all unused data without confirmation." >&2
|
|
38
|
+
exit 2
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
exit 0
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# output-credential-scan.sh — Detect credentials in command output
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# Claude Code can accidentally expose credentials by running
|
|
7
|
+
# commands like `env`, `cat .env`, or `printenv`. This PostToolUse
|
|
8
|
+
# hook scans stdout for common credential patterns and warns.
|
|
9
|
+
#
|
|
10
|
+
# TRIGGER: PostToolUse
|
|
11
|
+
# MATCHER: "Bash"
|
|
12
|
+
# ================================================================
|
|
13
|
+
|
|
14
|
+
INPUT=$(cat)
|
|
15
|
+
STDOUT=$(echo "$INPUT" | jq -r '.tool_result.stdout // empty' 2>/dev/null)
|
|
16
|
+
|
|
17
|
+
[ -z "$STDOUT" ] && exit 0
|
|
18
|
+
|
|
19
|
+
# Check for common credential patterns in output
|
|
20
|
+
if echo "$STDOUT" | grep -qiE '(sk-[a-zA-Z0-9]{20,}|ghp_[a-zA-Z0-9]{36}|AKIA[A-Z0-9]{16}|xox[bpsa]-[a-zA-Z0-9-]+|eyJ[a-zA-Z0-9_-]+\.eyJ)'; then
|
|
21
|
+
echo "⚠ Possible credential detected in command output!" >&2
|
|
22
|
+
echo " This output may contain API keys, tokens, or secrets." >&2
|
|
23
|
+
echo " Avoid sharing this output or committing it to version control." >&2
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
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.10",
|
|
4
|
+
"description": "One command to make Claude Code safe. 420 example hooks + 8 built-in. 52 CLI commands. 5662 tests. Works with Auto Mode.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|