Check if tool names match (case-insensitive, wildcard-aware)
(&self, rule_tool: &str, actual_tool: &str)
| 100 | |
| 101 | /// Check if tool names match (case-insensitive, wildcard-aware) |
| 102 | fn matches_tool_name(&self, rule_tool: &str, actual_tool: &str) -> bool { |
| 103 | // If the rule contains wildcards, use glob matching on the tool name directly. |
| 104 | // e.g. "mcp__longvt__*" must use glob, not starts_with, because starts_with |
| 105 | // treats '*' as a literal character and will never match. |
| 106 | if rule_tool.contains('*') || rule_tool.contains('?') { |
| 107 | return self.glob_match(rule_tool, actual_tool); |
| 108 | } |
| 109 | |
| 110 | // Handle MCP tools: mcp__server matches mcp__server__tool |
| 111 | if rule_tool.starts_with("mcp__") && actual_tool.starts_with("mcp__") { |
| 112 | // mcp__pencil matches mcp__pencil__batch_design |
| 113 | if actual_tool.starts_with(rule_tool) { |
| 114 | return true; |
| 115 | } |
| 116 | } |
| 117 | rule_tool.eq_ignore_ascii_case(actual_tool) |
| 118 | } |
| 119 | |
| 120 | /// Match argument pattern against tool arguments |
| 121 | fn matches_args(&self, pattern: &str, tool_name: &str, args: &serde_json::Value) -> bool { |
no test coverage detected