Answer security round 2: 1 🔴, 0 🟡; deny a git argument that names a path outside the clone, in place of listing options
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- `workflow-bench/bench.py` gives each run a fixed list of allowed tools, where it skipped every permission check. A run may launch agents, run `/security-review`, edit its clone (not the clone's `.git/`) and its report, read its clone and the copy of `~/.claude` it benches, and run `git log`, `diff`, `show`, `status`, `ls-files`, `add` and `commit -m`, without options that name a path git reads or writes. It loads no user settings, so `~/.claude/settings.json`'s hooks and extra directories do not apply to it. Every other call is denied. Expect a benched review that needs to run a project's code or tests to say in its report that it could not.
|
||||
- `workflow-bench/bench.py` gives each run a fixed list of allowed tools, where it skipped every permission check. A run may launch agents, run `/security-review`, edit its clone (not the clone's `.git/`) and its report, read its clone and the copy of `~/.claude` it benches, and run `git log`, `diff`, `show`, `status`, `ls-files`, `add` and `commit -m` (also as `-am` or `-a -m`). A git argument that names a path outside the clone is denied: an absolute path, one from `~`, one through `..` or one through a shell variable. It loads no user settings, so `~/.claude/settings.json`'s hooks and extra directories do not apply to it. Every other call is denied. Expect a benched review that needs to run a project's code or tests to say in its report that it could not.
|
||||
- Every goal in `README.md` → Goals is marked `**Maintain:**`, a state to hold, or `**Achieve:**`, a direction to pursue. Each achieve goal has a signal, a counter-signal and a one-line reason under it. A change that breaks a maintain goal is redesigned or dropped, whatever it scores: `rules/todo-items.md` says so, and larv-review's goal alignment step no longer merges such a PR. `rules/goals-and-audience.md` states the form for every project's README. Expect larv-review to stop a PR on a maintain goal where it asked you before.
|
||||
- Reshape every project's `todo.md` to the new shape below: until it is reshaped, that is the project's only work, as it is while README.md lacks Goals and Audience, and `rank_todo.py` says so. First move every machine to this release: an older release rejects the new formula, so it fails on every reshaped `todo.md`. Then mark the README's goals `**Maintain:**` or `**Achieve:**`, score each item's L, E and I, and set a bar on the new scale below the score of every item to keep, since the old bar would drop most items. Until then, an old-shape `todo.md` still ranks by its own formula and weights.
|
||||
- `todo.md` ranks items by value per cost: this setup's own plan uses `Score = 100 * V / (2**S + 8)`, where 8 is a chunk's fixed cost, about one size-3 change, and `rank_todo.py --help` shows it. A Moves column replaces A, G and Goals, naming each achieve goal an item moves and how far, such as `1.1 by 8, 1.2 by 5`. V sums each named goal's weight times its move. `rank_todo.py` weighs each achieve goal by its position in README.md, the first heaviest, so the goal weights table goes. An item names the most specific goal it moves, never a goal beside its own sub-goal. `rules/todo-items.md` and `rank_todo.py --help` show the new shape.
|
||||
|
||||
@@ -37,14 +37,17 @@ 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 = ("log", "diff", "show", "status", "ls-files", "add", "commit -m", "commit -am")
|
||||
commands = ("log", "diff", "show", "status", "ls-files", "add", "commit -m", "commit -am", "commit -a -m")
|
||||
allowed = [
|
||||
"Agent", "Skill(security-review)", f"Edit(/{clone}/**)", f"Edit(/{report})",
|
||||
*(f"Bash(git {command} *)" for command in git),
|
||||
*(f"Bash(git {command} *)" for command in commands),
|
||||
*(f"{tool}({tree})" for tool in ("Read", "Grep", "Glob") for tree in trees),
|
||||
]
|
||||
# git reads or writes any path through these options, and runs any command through a hook or config.
|
||||
denied = [f"Edit(/{clone}/.git/**)", *(f"Bash(git * {option}*)" for option in ("--no-index", "--output", "-F", "--file", "-t", "--template"))]
|
||||
# git reaches a path outside the clone only through an argument that names one: absolute, from ~, up
|
||||
# through "..", through a variable, or glued to -O or -X. With -m, git refuses -F and ignores -t
|
||||
# before reading either file. An edit to .git/ could add a hook, which runs any command.
|
||||
outside = (" /", "=/", " ~", "=~", "../", " ..", "$", "O/", "X/")
|
||||
denied = [f"Edit(/{clone}/.git/**)", *(f"Bash(git *{shape}*)" for shape in outside)]
|
||||
# Only the clone's own settings: the user's add every checkout under ~/code to the readable trees.
|
||||
return ["--setting-sources", "project,local", "--permission-mode", "dontAsk", "--permission-prompts", "none",
|
||||
"--allowedTools", *allowed, "--disallowedTools", *denied]
|
||||
|
||||
Reference in New Issue
Block a user