Files
hx/docs/adr/0014-permission-command-parsing-and-rules.md
johannesandClaude Sonnet 5.5 a94632ea3d chore: delete code comments, add ratchet lint and ADRs
Classify every comment as tautology, stale, excuse or decision record.
Tautology/stale/excuse comments are deleted (excuses filed as issues
#196-#236), decisions moved to docs/adr/0001-0034.

- scripts/lint-comments.sh + .comment-baseline: per-file comment count
  may only go down; wired into tests/all.sh
- .claude/skills/delete-comment: repeatable audit workflow
- cargo fmt applied to touched crates

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 13:37:32 +01:00

18 lines
1.2 KiB
Markdown

# Command parsing and "allow always" rules are conservative
Status: accepted
## Context
Read-only commands run without a prompt and "allow always" persists patterns. A permissive parser or glob would let a harmless-looking prefix authorise a dangerous chain, e.g. `cargo test && rm -rf ~`.
## Decision
- The auto-run read-only list deliberately omits `env`, `xargs`, `sed`, `cargo`, `curl` (they exec, write or reach the network).
- The chain splitter accepts only `|`, `&&`, `;` and the redirects `2>&1` / `>/dev/null`. Anything else the shell would interpret (`||`, `&`, `$`, backticks, parens, `<`, `>`, newlines, open quotes) returns `None` and asks.
- `cd` is free: it only matters for what follows, which is checked on its own.
- "Allow always" stores one rule per non-read-only segment (first word plus subcommand, e.g. `bash:cargo test *`), joined by newlines; risky segments store their exact text; unparsable commands get no rule. A rule therefore cannot cover a chain it was not granted for. File tools get no rule; the prompt offers "allow all edits this session".
## Consequences
Heredocs, `{}` groups and similar always prompt. Rules are coarse globs.
Code: crates/hx-core/src/permit.rs (READONLY list, `split_chain`, `cd` handling, `rule`)