File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # rm-tmp.sh — Delete files under .claude/tmp/ only.
3+ # Usage: bash <path>/rm-tmp.sh <path> [<path> ...]
4+ #
5+ # Restricts deletion to files under the project's .claude/tmp/ directory
6+ # so that Bash(rm:*) need not be added to the permission allowlist.
7+ # Rejects: paths outside .claude/tmp/, paths containing '..', and directories.
8+
9+ set -euo pipefail
10+
11+ if [ $# -eq 0 ]; then
12+ echo " Error: at least one file path is required" >&2
13+ exit 2
14+ fi
15+
16+ ALLOWED_PREFIX=" .claude/tmp/"
17+
18+ for target in " $@ " ; do
19+ normalized=" ${target# ./ } "
20+
21+ if [[ " ${normalized} " == * ..* ]]; then
22+ echo " Error: path containing '..' is not allowed: ${target} " >&2
23+ exit 1
24+ fi
25+
26+ if [[ " ${normalized} " != " ${ALLOWED_PREFIX} " * ]]; then
27+ echo " Error: path is not under ${ALLOWED_PREFIX} : ${target} " >&2
28+ exit 1
29+ fi
30+
31+ if [ -d " ${normalized} " ]; then
32+ echo " Error: directory deletion is not allowed: ${target} " >&2
33+ exit 1
34+ fi
35+
36+ rm -f -- " ${normalized} "
37+ done
Original file line number Diff line number Diff line change 2424 " Bash(clang-format:*)" ,
2525 " Bash(cmake-format:*)" ,
2626 " Bash(.claude/scripts/fetch-diff.sh:*)" ,
27+ " Bash(.claude/scripts/rm-tmp.sh:*)" ,
2728 " Bash(python .claude/scripts/render-review.py:*)" ,
2829 " Read(.claude/tmp/**)" ,
2930 " Write(.claude/tmp/**)" ,
You can’t perform that action at this time.
0 commit comments