permit: quote-aware command chains, always-allow for pipelines #134

Merged
hermes merged 1 commits from feat/permit-shell-aware into main 2026-10-06 13:42:51 +00:00
Collaborator

Permission gate now parses command lines quote-aware instead of matching characters.

  • split_cmd splits at unquoted |, &&, ;; ||, &, $, backticks, parens, <, other redirects, newlines and open quotes make the command unparsable (always asks, no rule).
  • 2>&1, 2>&2, >/dev/null, &>/dev/null are accepted.
  • Read-only pipelines with quoted metacharacters (rg "a|b" src | tail, rg -o 'fn (a|b)') no longer prompt. -o is only blocked for sort; rg --pre asks. cd <dir> is free.
  • "allow always" on a chain stores one rule per non-read-only segment (go test ./... 2>&1 | tail -30 -> bash:go test *); allows() requires every segment to be read-only or covered. cargo test && rm -rf ~ stores bash:cargo test * + exact bash:rm -rf ~, so the rule cannot cover the rm.
  • Popup lists all stored rules joined by , .

Tests: new asserts in permit.rs; tests/all.sh green (169 unit + all e2e).

Permission gate now parses command lines quote-aware instead of matching characters. - `split_cmd` splits at unquoted `|`, `&&`, `;`; `||`, `&`, `$`, backticks, parens, `<`, other redirects, newlines and open quotes make the command unparsable (always asks, no rule). - `2>&1`, `2>&2`, `>/dev/null`, `&>/dev/null` are accepted. - Read-only pipelines with quoted metacharacters (`rg "a|b" src | tail`, `rg -o 'fn (a|b)'`) no longer prompt. `-o` is only blocked for `sort`; `rg --pre` asks. `cd <dir>` is free. - "allow always" on a chain stores one rule per non-read-only segment (`go test ./... 2>&1 | tail -30` -> `bash:go test *`); `allows()` requires every segment to be read-only or covered. `cargo test && rm -rf ~` stores `bash:cargo test *` + exact `bash:rm -rf ~`, so the rule cannot cover the rm. - Popup lists all stored rules joined by `, `. Tests: new asserts in permit.rs; `tests/all.sh` green (169 unit + all e2e).
hermes added 1 commit 2026-10-06 13:35:04 +00:00
hermes merged commit b223fd1f22 into main 2026-10-06 13:42:51 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#134