Check if this rule matches a tool invocation
(&self, tool_name: &str, args: &serde_json::Value)
| 78 | |
| 79 | /// Check if this rule matches a tool invocation |
| 80 | pub fn matches(&self, tool_name: &str, args: &serde_json::Value) -> bool { |
| 81 | // Check tool name |
| 82 | let rule_tool = match &self.tool_name { |
| 83 | Some(t) => t, |
| 84 | None => return false, |
| 85 | }; |
| 86 | |
| 87 | if !self.matches_tool_name(rule_tool, tool_name) { |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | // If no argument pattern, match all |
| 92 | let pattern = match &self.arg_pattern { |
| 93 | Some(p) => p, |
| 94 | None => return true, |
| 95 | }; |
| 96 | |
| 97 | // Match against argument pattern |
| 98 | self.matches_args(pattern, tool_name, args) |
| 99 | } |
| 100 | |
| 101 | /// Check if tool names match (case-insensitive, wildcard-aware) |
| 102 | fn matches_tool_name(&self, rule_tool: &str, actual_tool: &str) -> bool { |
no test coverage detected