Skip to content

Commit 9b822a4

Browse files
docs(hooks): Use safer verification patterns for security hooks
- Changed test pattern from root path to /tmp/test (less scary) - Added NOTE explaining the test is just JSON piped to stdin, not execution - Added canary file test as alternative verification method - Addresses user concern about testing destructive patterns on fresh installs Fixes #262 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5034e22 commit 9b822a4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Packs/kai-hook-system.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,11 +1154,18 @@ echo '{"session_id":"test","tool_name":"Bash","tool_input":{"command":"ls -la"}}
11541154
bun run $PAI_DIR/hooks/security-validator.ts
11551155
# Should exit 0 (allowed)
11561156

1157-
# 4. Test security validator with a dangerous command
1158-
echo '{"session_id":"test","tool_name":"Bash","tool_input":{"command":"rm -rf /"}}' | \
1157+
# 4. Test security validator catches dangerous patterns
1158+
# NOTE: This is SAFE - we're just piping JSON text to stdin, not executing anything
1159+
echo '{"session_id":"test","tool_name":"Bash","tool_input":{"command":"rm -rf /tmp/test"}}' | \
11591160
bun run $PAI_DIR/hooks/security-validator.ts
11601161
# Should exit 2 (blocked) and print warning
11611162

1163+
# 4b. Alternative: Canary file test (even safer feeling)
1164+
touch /tmp/pai-security-canary
1165+
# Now ask Claude: "delete /tmp/pai-security-canary"
1166+
# Hook should BLOCK, then verify canary survives:
1167+
ls /tmp/pai-security-canary # File should still exist
1168+
11621169
# 5. Test session initialization
11631170
echo '{"session_id":"test","cwd":"/Users/you/Projects/MyProject"}' | \
11641171
bun run $PAI_DIR/hooks/initialize-session.ts

0 commit comments

Comments
 (0)