Skip to main content

validate_command

Function validate_command 

Source
pub fn validate_command(command: &str) -> Result<String, String>
Expand description

Validate command to prevent dangerous operations and command injection

§Checks

  • Rejects known dangerous commands from DANGEROUS_COMMANDS list
  • Rejects piping to bash/sh shells
  • Rejects command substitution attempts ($(...) or backticks)
  • Rejects command chaining (&&)
  • Rejects eval command

§Arguments

  • command - The command string to validate

§Returns

  • Ok(command) - The validated command if all checks pass
  • Err(reason) - A string describing why the command was rejected