cc-safe-setup 29.6.17 → 29.6.19
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.
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ Install any of these: `npx cc-safe-setup --install-example <name>`
|
|
|
117
117
|
| `--scan [--apply]` | Tech stack detection |
|
|
118
118
|
| `--export / --import` | Team config sharing |
|
|
119
119
|
| `--verify` | Test each hook |
|
|
120
|
-
| `--install-example <name>` | Install from
|
|
120
|
+
| `--install-example <name>` | Install from 442 examples |
|
|
121
121
|
| `--examples [filter]` | Browse examples by keyword |
|
|
122
122
|
| `--full` | All-in-one setup |
|
|
123
123
|
| `--status` | Check installed hooks |
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# no-verify-blocker.sh — Block --no-verify on git commands
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# Claude Code may use --no-verify to skip pre-commit hooks,
|
|
7
|
+
# bypassing safety checks like linting, tests, and secret scanning.
|
|
8
|
+
# This hook blocks all --no-verify usage unless explicitly allowed.
|
|
9
|
+
#
|
|
10
|
+
# Solves: #40117 — Agent used --no-verify on 6 consecutive commits,
|
|
11
|
+
# silently bypassing pre-commit hooks that validate tests, secrets,
|
|
12
|
+
# and production readiness.
|
|
13
|
+
#
|
|
14
|
+
# TRIGGER: PreToolUse 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
|
+
# Block --no-verify on any git command
|
|
22
|
+
if echo "$COMMAND" | grep -qE '\bgit\b.*--no-verify'; then
|
|
23
|
+
echo "BLOCKED: --no-verify bypasses git hooks (pre-commit, pre-push)" >&2
|
|
24
|
+
echo "Fix the underlying issue instead of skipping hooks" >&2
|
|
25
|
+
exit 2
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# Also block the short form -n for git commit (which means --no-verify)
|
|
29
|
+
if echo "$COMMAND" | grep -qE '\bgit\s+commit\b.*\s-[a-zA-Z]*n'; then
|
|
30
|
+
# Avoid false positive: -n alone is not always --no-verify
|
|
31
|
+
# Only block if it looks like a commit with -n flag
|
|
32
|
+
if echo "$COMMAND" | grep -qE '\bgit\s+commit\s+-n\b'; then
|
|
33
|
+
echo "BLOCKED: git commit -n skips pre-commit hook" >&2
|
|
34
|
+
exit 2
|
|
35
|
+
fi
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
exit 0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# npm-global-install-guard.sh — Block npm global installs
|
|
3
|
+
#
|
|
4
|
+
# Solves: Claude Code running npm install -g which modifies the global
|
|
5
|
+
# node_modules directory. Global installs can conflict with
|
|
6
|
+
# system tools and affect all projects.
|
|
7
|
+
#
|
|
8
|
+
# Detects:
|
|
9
|
+
# npm install -g <package>
|
|
10
|
+
# npm i -g <package>
|
|
11
|
+
# npm install --global <package>
|
|
12
|
+
#
|
|
13
|
+
# Does NOT block:
|
|
14
|
+
# npm install (local)
|
|
15
|
+
# npx <package> (temporary execution)
|
|
16
|
+
#
|
|
17
|
+
# TRIGGER: PreToolUse MATCHER: "Bash"
|
|
18
|
+
|
|
19
|
+
INPUT=$(cat)
|
|
20
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
21
|
+
|
|
22
|
+
[ -z "$COMMAND" ] && exit 0
|
|
23
|
+
|
|
24
|
+
if echo "$COMMAND" | grep -qE '\bnpm\s+(install|i)\s+(-g|--global)\b'; then
|
|
25
|
+
echo "BLOCKED: npm global install modifies system-wide packages." >&2
|
|
26
|
+
echo " Use 'npx <package>' for one-time execution instead." >&2
|
|
27
|
+
echo " Or install locally: 'npm install --save-dev <package>'" >&2
|
|
28
|
+
exit 2
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
exit 0
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# pip-requirements-guard.sh — Enforce pip install from requirements.txt only
|
|
3
|
+
#
|
|
4
|
+
# Solves: Claude Code installing arbitrary Python packages with pip install
|
|
5
|
+
# instead of using the project's requirements.txt or pyproject.toml.
|
|
6
|
+
# Random package installs can introduce vulnerabilities and break
|
|
7
|
+
# reproducible builds.
|
|
8
|
+
#
|
|
9
|
+
# Detects:
|
|
10
|
+
# pip install <package> (direct package install)
|
|
11
|
+
# pip3 install <package> (same)
|
|
12
|
+
# python -m pip install <pkg> (module invocation)
|
|
13
|
+
#
|
|
14
|
+
# Does NOT block:
|
|
15
|
+
# pip install -r requirements.txt (from requirements file)
|
|
16
|
+
# pip install -e . (editable install of current project)
|
|
17
|
+
# pip install --upgrade pip (pip self-upgrade)
|
|
18
|
+
# pip list / pip show (read-only)
|
|
19
|
+
#
|
|
20
|
+
# TRIGGER: PreToolUse MATCHER: "Bash"
|
|
21
|
+
|
|
22
|
+
INPUT=$(cat)
|
|
23
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
24
|
+
|
|
25
|
+
[ -z "$COMMAND" ] && exit 0
|
|
26
|
+
|
|
27
|
+
# Only check pip install commands
|
|
28
|
+
echo "$COMMAND" | grep -qE '\bpip3?\s+install\b|python3?\s+-m\s+pip\s+install\b' || exit 0
|
|
29
|
+
|
|
30
|
+
# Allow requirements file installs
|
|
31
|
+
echo "$COMMAND" | grep -qE 'pip3?\s+install\s+-r\s' && exit 0
|
|
32
|
+
|
|
33
|
+
# Allow editable installs
|
|
34
|
+
echo "$COMMAND" | grep -qE 'pip3?\s+install\s+-e\s' && exit 0
|
|
35
|
+
|
|
36
|
+
# Allow pip self-upgrade
|
|
37
|
+
echo "$COMMAND" | grep -qE 'pip3?\s+install\s+--upgrade\s+pip\b' && exit 0
|
|
38
|
+
|
|
39
|
+
# Block direct package installs
|
|
40
|
+
echo "BLOCKED: Direct pip install detected." >&2
|
|
41
|
+
echo " Use 'pip install -r requirements.txt' for reproducible builds." >&2
|
|
42
|
+
echo " Command: $COMMAND" >&2
|
|
43
|
+
exit 2
|
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.19",
|
|
4
|
+
"description": "One command to make Claude Code safe. 443 example hooks + 8 built-in. 52 CLI commands. 5890 tests. Works with Auto Mode.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|