diff --git a/crates/execpolicy/src/bash_arity.rs b/crates/execpolicy/src/bash_arity.rs new file mode 100644 index 00000000..225a75cc --- /dev/null +++ b/crates/execpolicy/src/bash_arity.rs @@ -0,0 +1,574 @@ +//! Bash arity dictionary for command-prefix allow rule matching. +//! +//! [`BashArityDict`] maps a command prefix (space-separated, lowercase) to the +//! number of positional (non-flag) words, *including the base command word*, +//! that form the canonical prefix. +//! +//! ## Invariant +//! +//! Flags (tokens starting with `-`) are **never** counted toward arity. +//! `auto_allow = ["git status"]` must match `git status -s` and +//! `git status --porcelain`, but **not** `git push`. +//! +//! ## Coverage +//! +//! 30+ common tools are covered across: git, npm, yarn, pnpm, cargo, docker, +//! kubectl, go, python/pip, gh, rustup, deno, bun, aws, terraform, make, +//! and more. + +/// Static arity table: `(prefix, arity)`. +/// +/// Arity is the total number of *positional* tokens (including the base +/// command) that form the canonical prefix. For example: +/// +/// * `("git status", 2)` — 2 positional tokens: `git` + `status`. +/// * `("npm run", 3)` — 3 positional tokens: `npm` + `run` + `