Skip to content

feat(approval): command-level allow/deny patterns for run_command - #453

Merged
ajianaz merged 3 commits into
developfrom
feat/command-allow-deny-patterns
Oct 28, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/command-allow-deny-patterns

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What

run_command:<argv pattern> allow patterns and !-prefixed deny patterns, so specific commands can be pre-authorized (or refused) without handing over the shell.

Closes #438.

Why

--allow matched tool names only: run_command was all-or-nothing (approve every call, or --yes for every command). Headless/CI delegation needs "these commands are fine, those never".

Changes

  • tole-core/src/approval.rs: pattern_verdict(patterns, req) — the one allow-list evaluation both approvers use: deny first, then the wrapper rule, then allow.
    • run_command:<pattern> matches the argv from RunCommandTool::split_argv, the same splitter the tool executes with (no shell: git status; rm -rf / cannot chain). One glob_match per argument, a final lone * = any further arguments, otherwise equal arity. An ALLOW compares the program literally (/usr/bin/git ≠ git, run_command:* allows nothing).
    • ! prefix = deny (any pattern kind). A deny wins over every allow and over --yes; its program is a glob over argv[0] or its file name (/bin/rm cannot slip past rm *).
    • While any run_command deny is configured, known wrappers that can hide the real program (sh, bash, env, sudo, xargs, busybox, timeout, ...) return Ask: the interactive approver prompts even under --yes; headless approvers refuse.
    • deny_only treats run_command: patterns command-wise too.
  • tole-cli/src/approver.rs: InteractiveApprover uses pattern_verdict (deny > ask > allow > --yes > prompt).
  • tole-core/src/agents.rs: a child always inherits every parent deny; deny patterns are exempt from (and never satisfy) the subset check.
  • Design choice: --deny from the issue is a ! prefix in the existing allow list, so a deny travels everywhere allow patterns already go (config allow, ACP, serve, children) without new plumbing that could miss a path.
  • Not done: the "auto-allowed by pattern …" notice in the prompt (auto-allowed calls show no prompt today); can follow separately.
  • Docs: README, CHANGELOG, docs/epics.md, docs/threat-model.md (allowlist is the boundary; a deny narrows --yes but cannot make it safe; examples of argument-driven code execution such as git -c …).

Testing

  • Unit (core): arity and per-argument globs, literal program for allows, ; never chains, unterminated quotes never match, command patterns never match other tools, deny wins and sees through paths, wrappers → Ask (and → Deny headless), deny_only command-wise, deny patterns never allow.
  • Unit (cli): a deny beats --yes without prompting; a wrapper under a command deny prompts even under --yes.
  • Child agents: a child naming its own allows still carries the parent's denies; a parent deny never covers a child allow request.
  • cargo fmt, clippy (workspace all-targets, bare, shell-tools, mcp, tole-core bare), cargo test --workspace: green. Cora agent review (prepare + finalize): 1 info qual-clone rejected (the clone builds the child's list), should_block: false.

`run_command:<argv pattern>` in --allow / config allow matches
run_command calls by the argv the tool executes (same splitter, no
shell): one glob per argument, a final lone `*` = any further
arguments, the program compared literally for an allow. A leading `!`
makes any pattern a deny that wins over every allow and over --yes; a
deny's program also matches by file name. While a run_command deny is
set, wrapper programs (sh, env, sudo, xargs, ...) always ask the human.
Denies travel with allow lists and children always inherit them.
pattern_verdict is the one evaluation both approvers use.
@ajianaz ajianaz added this to the 0.10.0 milestone Oct 28, 2026
Comment thread crates/tole-core/src/agents.rs Fixed
Comment thread crates/tole-core/src/approval.rs Fixed
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…overage (#438)

Cora (alerts #118/#119) and the security review found three gaps in the
first revision:
- the child subset check globbed pattern TEXT, so a parent
  `run_command:*` (which allows nothing) "covered" a child
  `run_command:rm *`; pattern_covers now checks command patterns
  argument by argument with a literal program;
- a deny compared the program case-sensitively with its extension, so
  `/bin/RM` or `rm.exe` escaped `rm *`; denies now compare the
  lowercased file name without .exe/.cmd/.bat/.com;
- a wrapper denylist cannot be complete; while a command deny is set,
  a command now runs unattended only when an explicit `run_command:`
  allow names it (and never a wrapper); everything else asks.
Comment thread crates/tole-core/src/approval.rs Dismissed
Comment thread crates/tole-core/src/approval.rs Dismissed
Cora (alerts #120/#121) and the security review on dc8ece1:
- a parent `?` matched a child's literal `*`, so `cat t?st` covered
  `cat t*st`; a child token with a wildcard is now covered only by the
  identical glob or a lone `*` (token_covers, also for tool names);
- under a parent command deny the parent runs only explicitly allowed
  commands unattended, yet a bare `run_command` parent still covered a
  child `run_command:ls *`; list_covers now requires a parent
  `run_command:` allow there;
- deny_only skipped the fail-closed rule; a `run_command:` deny there
  now refuses every run_command call (it has no allows to name safe
  commands).
@ajianaz
ajianaz merged commit aea3521 into develop Oct 28, 2026
16 checks passed
@ajianaz
ajianaz deleted the feat/command-allow-deny-patterns branch October 28, 2026 01:54
@ajianaz ajianaz modified the milestones: 0.10.0, 0.9.0 Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tools): command-level allow/deny patterns for run_command

2 participants