cc-safe-setup 2.0.1 → 2.0.2
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 +1 -0
- package/examples/README.md +1 -0
- package/examples/env-var-check.sh +38 -0
- package/index.mjs +3 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -155,6 +155,7 @@ Or browse all available examples in [`examples/`](examples/):
|
|
|
155
155
|
- **network-guard.sh** — Warn on suspicious network commands sending file contents ([#37420](https://github.com/anthropics/claude-code/issues/37420))
|
|
156
156
|
- **test-before-push.sh** — Block `git push` when tests haven't been run ([#36970](https://github.com/anthropics/claude-code/issues/36970))
|
|
157
157
|
- **large-file-guard.sh** — Warn when Write tool creates files over 500KB
|
|
158
|
+
- **commit-message-check.sh** — Warn on non-conventional commit messages (feat:, fix:, docs:, etc.)
|
|
158
159
|
|
|
159
160
|
## Learn More
|
|
160
161
|
|
package/examples/README.md
CHANGED
|
@@ -19,6 +19,7 @@ npx cc-safe-setup --examples
|
|
|
19
19
|
| **allowlist.sh** | Block everything not explicitly approved | [#37471](https://github.com/anthropics/claude-code/issues/37471) |
|
|
20
20
|
| **block-database-wipe.sh** | Block migrate:fresh, DROP DATABASE, Prisma reset | [#37405](https://github.com/anthropics/claude-code/issues/37405) |
|
|
21
21
|
| **deploy-guard.sh** | Block deploy with uncommitted changes | [#37314](https://github.com/anthropics/claude-code/issues/37314) |
|
|
22
|
+
| **env-var-check.sh** | Block hardcoded API keys in export commands | |
|
|
22
23
|
| **git-config-guard.sh** | Block git config --global | [#37201](https://github.com/anthropics/claude-code/issues/37201) |
|
|
23
24
|
| **network-guard.sh** | Warn on suspicious network commands | [#37420](https://github.com/anthropics/claude-code/issues/37420) |
|
|
24
25
|
| **protect-dotfiles.sh** | Block changes to ~/.bashrc, ~/.aws/, ~/.ssh/ | [#37478](https://github.com/anthropics/claude-code/issues/37478) |
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# env-var-check.sh — Warn when setting environment variables with secrets
|
|
3
|
+
#
|
|
4
|
+
# Solves: Claude hardcoding API keys or passwords into export commands
|
|
5
|
+
# that end up in shell history and process environment.
|
|
6
|
+
#
|
|
7
|
+
# Usage: Add to settings.json as a PreToolUse hook
|
|
8
|
+
#
|
|
9
|
+
# {
|
|
10
|
+
# "hooks": {
|
|
11
|
+
# "PreToolUse": [{
|
|
12
|
+
# "matcher": "Bash",
|
|
13
|
+
# "hooks": [{ "type": "command", "command": "~/.claude/hooks/env-var-check.sh" }]
|
|
14
|
+
# }]
|
|
15
|
+
# }
|
|
16
|
+
# }
|
|
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
|
+
# Check for export/set with sensitive-looking values
|
|
24
|
+
if echo "$COMMAND" | grep -qiE 'export\s+(API_KEY|SECRET|TOKEN|PASSWORD|CREDENTIALS|AUTH)='; then
|
|
25
|
+
echo "" >&2
|
|
26
|
+
echo "⚠ SECURITY: Setting sensitive environment variable in shell" >&2
|
|
27
|
+
echo "This will appear in shell history. Use .env files or secret managers instead." >&2
|
|
28
|
+
echo "Command: $COMMAND" >&2
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Check for hardcoded key patterns (sk-, pk-, ghp_, etc.)
|
|
32
|
+
if echo "$COMMAND" | grep -qE 'export\s+\w+=.*(sk-[a-zA-Z0-9]{20,}|ghp_[a-zA-Z0-9]{36}|gho_[a-zA-Z0-9]{36}|glpat-[a-zA-Z0-9]{20,})'; then
|
|
33
|
+
echo "BLOCKED: Hardcoded API key detected in export command" >&2
|
|
34
|
+
echo "Use: export VAR=\$(cat ~/.credentials/key)" >&2
|
|
35
|
+
exit 2
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
exit 0
|
package/index.mjs
CHANGED
|
@@ -183,7 +183,7 @@ function status() {
|
|
|
183
183
|
const exampleFiles = [
|
|
184
184
|
'allowlist.sh', 'auto-approve-build.sh', 'auto-approve-docker.sh',
|
|
185
185
|
'auto-approve-git-read.sh', 'auto-approve-python.sh', 'auto-approve-ssh.sh',
|
|
186
|
-
'auto-checkpoint.sh', 'auto-snapshot.sh', 'block-database-wipe.sh',
|
|
186
|
+
'auto-checkpoint.sh', 'auto-snapshot.sh', 'block-database-wipe.sh', 'commit-message-check.sh',
|
|
187
187
|
'deploy-guard.sh', 'edit-guard.sh', 'enforce-tests.sh', 'git-config-guard.sh',
|
|
188
188
|
'large-file-guard.sh', 'network-guard.sh', 'notify-waiting.sh',
|
|
189
189
|
'protect-dotfiles.sh', 'scope-guard.sh', 'test-before-push.sh',
|
|
@@ -281,6 +281,7 @@ function examples() {
|
|
|
281
281
|
'allowlist.sh': 'Block everything not in allowlist (inverse permission model)',
|
|
282
282
|
'block-database-wipe.sh': 'Block destructive DB commands (migrate:fresh, DROP DATABASE, Prisma)',
|
|
283
283
|
'deploy-guard.sh': 'Block deploy when uncommitted changes exist',
|
|
284
|
+
'env-var-check.sh': 'Block hardcoded API keys in export commands',
|
|
284
285
|
'network-guard.sh': 'Warn on suspicious network commands (data exfiltration)',
|
|
285
286
|
'protect-dotfiles.sh': 'Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/',
|
|
286
287
|
'scope-guard.sh': 'Block file operations outside project directory',
|
|
@@ -311,7 +312,7 @@ function examples() {
|
|
|
311
312
|
|
|
312
313
|
console.log();
|
|
313
314
|
console.log(c.bold + ' cc-safe-setup --examples' + c.reset);
|
|
314
|
-
console.log(c.dim + '
|
|
315
|
+
console.log(c.dim + ' 21 hooks beyond the 8 built-in ones' + c.reset);
|
|
315
316
|
console.log();
|
|
316
317
|
|
|
317
318
|
for (const [cat, hooks] of Object.entries(CATEGORIES)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "One command to make Claude Code safe for autonomous operation. 8 built-in hooks +
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "One command to make Claude Code safe for autonomous operation. 8 built-in hooks + 21 installable examples. Destructive blocker, branch guard, database wipe protection, dotfile guard, and more.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|