Skip to main content

evaluate_command

Function evaluate_command 

Source
pub fn evaluate_command(
    command: &str,
    config: &Config,
    enabled_keywords: &[&str],
    compiled_overrides: &CompiledOverrides,
    allowlists: &LayeredAllowlist,
) -> EvaluationResult
Expand description

Evaluate a command against all patterns and packs using precompiled overrides.

This is the main entry point for command evaluation. It performs all checks in the correct order and returns a structured result.

§Arguments

  • command - The raw command string to evaluate
  • config - Loaded configuration with pack settings
  • enabled_keywords - Keywords from enabled packs for quick rejection
  • compiled_overrides - Precompiled config overrides (avoids per-command regex compilation)

§Returns

An EvaluationResult indicating whether the command is allowed or denied, with detailed pattern match information for denials.

§Performance

This function is optimized for the common case (allow):

  • Quick rejection skips regex for 99%+ of commands
  • Config overrides use precompiled regexes (no per-command compilation)
  • Short-circuits on first match