Skip to content

Commit d428a1f

Browse files
committed
chore: apply AI code review suggestions from PR #42
- Add MultiEdit to PreToolUse hook matcher in .claude/settings.json to prevent bypass of vendor write protection - Add MultiEdit case in deny-vendor-write.sh to extract file_path - Fix realpath -m GNU-specific issue with python3 cross-platform fallback
1 parent 9c98fc1 commit d428a1f

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

.claude/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"hooks": {
33
"PreToolUse": [
44
{
5-
"matcher": "Write|Edit|NotebookEdit",
5+
"matcher": "Write|Edit|MultiEdit|NotebookEdit",
66
"hooks": [
77
{
88
"type": "command",

hooks/deny-vendor-write.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ input=$(cat)
1010
tool_name=$(echo "$input" | jq -r '.tool_name // empty')
1111

1212
case "$tool_name" in
13-
Write|Edit)
13+
Write|Edit|MultiEdit)
1414
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
1515
;;
1616
NotebookEdit)
@@ -35,9 +35,10 @@ case "$file_path" in
3535
;;
3636
esac
3737

38-
# .. 세그먼트를 정규화하여 경로 우회 방지 (realpath -m은 파일이 없어도 작동)
39-
# fail-open 대신 fail-closed: 경로 정규화 실패 시 요청 차단
40-
if ! abs_path="$(realpath -m "$abs_path" 2>/dev/null)"; then
38+
# .. 세그먼트를 정규화하여 경로 우회 방지
39+
# realpath -m은 GNU 전용이므로 python3로 크로스 플랫폼 폴백
40+
# fail-closed: 두 방법 모두 실패 시 요청 차단
41+
if ! abs_path="$(realpath -m "$abs_path" 2>/dev/null || python3 -c "import os.path, sys; print(os.path.normpath(sys.argv[1]))" "$abs_path" 2>/dev/null)"; then
4142
echo '{
4243
"hookSpecificOutput": {
4344
"permissionDecision": "deny",

0 commit comments

Comments
 (0)