Files
claude/.claude/tasks/plans/2026-11-14-docker-mount-bench/bench.sh
T
bchanot 0f73d7ee01 fix(settings): deny docker mounts of the host root in 7 spellings
The single legacy row matched no real spelling (bench M5). 28 rows (7 shapes x 4 prefixes, bench-proven with an echo analogue) now deny them; soft_deny covers create, container run and compose up; T41 locks the rows.
2026-11-15 15:22:34 +01:00

33 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# bench.sh [id…] — one isolated headless run per cases.tsv row (all rows, or
# the ids given), auto mode, rule present; one control per ASKED/DENIED row
# with the same command and no rule. Appends to results.tsv, never
# truncates: the last row per id wins. Harmless commands, fresh temp dir.
set -u
B="$(cd "$(dirname "$0")" && pwd)"
W="$(mktemp -d)" || exit 1
mkdir -p "$W/sub" && git -C "$W" init -q
printf 'X=1\n' > "$W/.env"; printf 'X=1\n' > "$W/sub/.env"
settings() { # settings <kind|none> <rule> <file>
jq -n --arg k "$1" --arg r "$2" '{permissions: ({allow: ["Bash(*)"],
defaultMode: "auto"} + (if $k == "none" then {} else {($k): [$r]} end)),
skipAutoPermissionPrompt: true}' > "$3"
}
wanted() { [ "$#" -eq 1 ] && return 0; local x; for x in "${@:2}"; do
[ "$x" = "$1" ] && return 0; done; return 1; }
while IFS=$'\t' read -r id kind rule cmd want; do
[ -n "$id" ] || continue
wanted "$id" "$@" || continue
printf '%b' "$cmd" > "$W/cmd.txt"
settings "$kind" "$rule" "$W/s.json"
printf '%s\t' "$want" >> "$B/results.tsv"
bash "$B/run.sh" "$id" "$W/cmd.txt" "$W/s.json" "$W" </dev/null \
>> "$B/results.tsv"
case "$want" in ASKED|DENIED) ;; *) continue ;; esac
settings none "" "$W/n.json"
printf 'control\t' >> "$B/results.tsv"
bash "$B/run.sh" "$id-ctl" "$W/cmd.txt" "$W/n.json" "$W" </dev/null \
>> "$B/results.tsv"
done < "$B/cases.tsv"
echo "bench dir kept: $W"