Skip to main content

is_destructive_command

Function is_destructive_command 

Source
pub fn is_destructive_command(command: &str) -> bool
Expand description

Defense-in-depth pre-check for the execute_command path: callable before the policy engine to short-circuit obviously destructive commands. Splits the command into the segments sh -c would run and reports true if any segment is a destructive operation (contains_destructive_pattern), a raw network listener / reverse-shell primitive (nc -l, socat …-listen:…), or a remote download piped straight into a shell (curl … | sh). Tokenized and segment-aware — not a substring match — so spacing, case, quoting, flag bundling, and chaining can’t trivially evade it (#114). Over-blocking is the safe direction; the authoritative boundary is still deny-by-default + the policy engine, which this mirrors without changing its semantics.