Answer stability round 4: 2 🔴, 1 🟡; the wrapper allows only listed options, takes the clone from the environment, and skips only a message its flag takes whole

This commit is contained in:
2026-10-16 22:30:24 +02:00
parent 4438ab04f3
commit b30c91aafc
9 changed files with 258 additions and 85 deletions
+9 -6
View File
@@ -23,7 +23,7 @@ import sys
import time
BENCH = pathlib.Path(__file__).resolve().parent
REVIEW_GIT = BENCH / "review-git.py"
REVIEW_GIT = BENCH / "review_git.py"
SOURCES = pathlib.Path(os.environ["BENCH_SOURCES"])
CASES = {
"cjk": ("151bf38^", "6c49912"),
@@ -38,16 +38,19 @@ def permission_flags(clone, version_dir, report):
"""The tools a review needs, each limited to what it may touch; the run denies every other call."""
# A permission rule writes an absolute path as "//<path>"; a trailing "/**" matches everything under it.
trees = (f"/{clone}/**", f"/{version_dir}/**")
# git can reach outside the clone through an argument, an option or a hook, and a quote or redirect can
# smuggle one past a text pattern. So the run gets no bare git: review-git.py is its one shell command
# and confines git to the clone (see its docstring). The clone's own .git and .claude stay unwritable,
# lest an edit plant a hook or widen the run's tools; the user's settings would add ~/code to the trees.
# git can reach outside the clone through an argument, an option or a hook, so the run gets no bare git:
# review_git.py is its one shell command (see its docstring). The clone's own .git and .claude stay
# unwritable, lest an edit plant a hook or widen the run's tools.
allowed = [
"Agent", "Skill(security-review)", f"Edit(/{clone}/**)", f"Edit(/{report})",
# Claude Code, not the wrapper, refuses what a shell adds to this command: a redirect, `$(…)`, backticks,
# or a second command after `;`, `&` or `&&`. It lets through `cd <dir> && …`, which is why run() names
# the clone in REVIEW_GIT_CLONE, and a pipe into a reader such as `| head`.
f"Bash(python3 {REVIEW_GIT} *)",
*(f"{tool}({tree})" for tool in ("Read", "Grep", "Glob") for tree in trees),
]
denied = ["Bash(git *)", f"Edit(/{clone}/.git/**)", f"Edit(/{clone}/.claude/**)"]
# No "user" source: ~/.claude/settings.json would add ~/code to the trees and run its hooks.
return ["--setting-sources", "project,local", "--permission-mode", "dontAsk", "--permission-prompts", "none",
"--allowedTools", *allowed, "--disallowedTools", *denied]
@@ -101,7 +104,7 @@ def run(name):
subprocess.run(
["claude", "-p", prompt, *permission_flags(clone, version_dir, report),
"--model", "claude-opus-5-5", "--output-format", "stream-json", "--verbose"],
cwd=clone, stdout=out, stderr=subprocess.STDOUT)
cwd=clone, env={**os.environ, "REVIEW_GIT_CLONE": str(clone)}, stdout=out, stderr=subprocess.STDOUT)
if report.exists():
return f"{name}: done on attempt {attempt}"
time.sleep(max(1200, rate_limit_reset(log) + 120 - time.time()))