use destructive_command_guard::allowlist::LayeredAllowlist;
use destructive_command_guard::config::{CompiledOverrides, Config};
use destructive_command_guard::evaluator::evaluate_command;
fn evaluate(cmd: &str) -> bool {
let config = Config::default();
let compiled = CompiledOverrides::default();
let allowlists = LayeredAllowlist::default();
let keywords = &["git", "rm"];
let result = evaluate_command(cmd, &config, keywords, &compiled, &allowlists);
result.is_denied()
}
#[test]
fn test_backslash_exe_bypass() {
let cmd = "\\git.exe reset --hard";
assert!(evaluate(cmd), "Command '{cmd}' should be blocked");
}
#[test]
fn test_windows_path_bypass() {
let cmd = "C:/Git/bin/git.exe reset --hard";
assert!(evaluate(cmd), "Command '{cmd}' should be blocked");
}
#[test]
fn test_windows_path_quoted_bypass() {
let cmd = r#""C:/Program Files/Git/bin/git.exe" reset --hard"#;
assert!(evaluate(cmd), "Command '{cmd}' should be blocked");
}
#[test]
fn test_cpp_binary_normalization() {
let cmd = "\\rm.exe -rf /";
assert!(evaluate(cmd), "Command '{cmd}' should be blocked");
}