Check if rule matches input data. Args: rule: Rule to evaluate input_data: Hook input data Returns: True if rule matches, False otherwise
(self, rule: Rule, input_data: Dict[str, Any])
| 94 | return {} |
| 95 | |
| 96 | def _rule_matches(self, rule: Rule, input_data: Dict[str, Any]) -> bool: |
| 97 | """Check if rule matches input data. |
| 98 | |
| 99 | Args: |
| 100 | rule: Rule to evaluate |
| 101 | input_data: Hook input data |
| 102 | |
| 103 | Returns: |
| 104 | True if rule matches, False otherwise |
| 105 | """ |
| 106 | # Extract tool information |
| 107 | tool_name = input_data.get('tool_name', '') |
| 108 | tool_input = input_data.get('tool_input', {}) |
| 109 | |
| 110 | # Check tool matcher if specified |
| 111 | if rule.tool_matcher: |
| 112 | if not self._matches_tool(rule.tool_matcher, tool_name): |
| 113 | return False |
| 114 | |
| 115 | # If no conditions, don't match |
| 116 | # (Rules must have at least one condition to be valid) |
| 117 | if not rule.conditions: |
| 118 | return False |
| 119 | |
| 120 | # All conditions must match |
| 121 | for condition in rule.conditions: |
| 122 | if not self._check_condition(condition, tool_name, tool_input, input_data): |
| 123 | return False |
| 124 | |
| 125 | return True |
| 126 | |
| 127 | def _matches_tool(self, matcher: str, tool_name: str) -> bool: |
| 128 | """Check if tool_name matches the matcher pattern. |
no test coverage detected