Add .claude/hooks for command auditing, dangerous command blocking, file protection, and auto-formatting; update documentation and configuration to integrate new hooks.
This commit is contained in:
21
.claude/hooks/audit-log.sh
Executable file
21
.claude/hooks/audit-log.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
# Log all Bash commands with timestamp for audit trail
|
||||
# Event: PostToolUse | Matcher: Bash
|
||||
# Logs to .claude/hooks/audit.log
|
||||
|
||||
INPUT=$(cat)
|
||||
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
||||
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // "unknown"')
|
||||
|
||||
if [ -z "$COMMAND" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LOG_DIR="$(dirname "$0")"
|
||||
LOG_FILE="$LOG_DIR/audit.log"
|
||||
|
||||
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
echo "[$TIMESTAMP] [$TOOL_NAME] $COMMAND" >> "$LOG_FILE"
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user