MCPcopy Create free account
hub / github.com/AI45Lab/Code / matches

Method matches

core/src/permissions/rule.rs:80–99  ·  view source on GitHub ↗

Check if this rule matches a tool invocation

(&self, tool_name: &str, args: &serde_json::Value)

Source from the content-addressed store, hash-verified

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 {

Callers 3

checkMethod · 0.45
get_matching_rulesMethod · 0.45
checkMethod · 0.45

Calls 2

matches_tool_nameMethod · 0.80
matches_argsMethod · 0.80

Tested by

no test coverage detected