Commit Graph

3 Commits

Author SHA1 Message Date
Moiri Gamboni a0b4da050c fix: dangerous-command-blocker hook references wrong script path (#367)
The installer (`installIndividualHook` in index.js) places companion
Python scripts in `.claude/hooks/`, but the hook config referenced
`.claude/scripts/`. This meant the hook would always fail with a
"file not found" error at runtime, silently rendering it non-functional.

Also removed the `2>&1` stderr redirect which masked the error by
merging stderr into stdout, causing the hook runner to report the
unhelpful "No stderr output" message instead of the actual cause.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:17:44 -08:00
Daniel Avila ceb3a9e40c feat(hooks): enhance dangerous-command-blocker with multi-level security (#281)
Enhanced the dangerous-command-blocker hook with comprehensive protection:

## Features:
- **3-Level Security System:**
  - Level 1: Block catastrophic commands (rm -rf /, dd, mkfs, fork bombs)
  - Level 2: Protect critical paths (.claude/, .git/, node_modules/, .env, etc.)
  - Level 3: Warn about suspicious patterns (wildcards, chained commands)

- **Python Script Architecture:**
  - Moved from inline Python to dedicated script for better maintainability
  - Script auto-installed to .claude/scripts/dangerous-command-blocker.py
  - Clear regex patterns and detailed error messages

- **Protected Resources:**
  - Claude Code configuration (.claude/)
  - Git repository (.git/)
  - Node.js dependencies (node_modules/, package.json, package-lock.json)
  - Environment files (.env, .env.local, etc.)
  - Language manifests (Cargo.toml, go.mod, requirements.txt, Gemfile, composer.json)

## Testing:
- 16/16 test cases passing (100%)
- Blocks catastrophic operations
- Protects critical project files
- Warns on suspicious patterns
- Allows safe operations

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-17 23:10:35 -05:00
Daniel Avila 5d4f4f1ac0 feat(hooks): add dangerous-command-blocker security hook (#279)
Add new security hook to prevent accidental execution of dangerous shell
commands like rm -rf, dd, mkfs, and other destructive operations.

Features:
- Blocks rm with dangerous flags (recursive, force) on critical paths
- Detects wildcards and system directory targets (/, ~, *)
- Prevents disk operations (dd, mkfs, format)
- Blocks fork bombs and direct disk device access
- Provides clear safety guidelines in error messages
- Allows safe operations (e.g., rm -rf /tmp/specific-folder)

Reviewed by component-reviewer agent.

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-17 22:37:14 -05:00