Match Conditions
Match conditions determine which tool calls a policy applies to and which specific rules within that policy should trigger. This page documents both policy-level matching (thematch clause) and rule-level conditions (the when clause).
Policy-Level Match Clause
Thematch clause at the policy level determines which tool types and agents the policy applies to:
Match Fields
Tool type(s) this policy applies to. Can be a single string or array of strings.Standard tool types:
exec- Shell commandsread- File read operationswrite- File write/edit operationsfetch- HTTP/network requestsmcp- Generic MCP tool callsmcp-destructive- MCP tools with destructive keywords (delete, destroy, remove, drop, purge, kill)mcp-dangerous- MCP tools with dangerous keywords (stop, restart, execute, modify, send, post)
mcp__server__toolname- Target a specific MCP tool (e.g.,create_issue,send_message)
Glob pattern matching agent identity. Defaults to
* (all agents).Rule-Level When Clause
Thewhen clause defines conditions for a specific rule to trigger. All conditions are optional - omit when entirely for unconditional rules.
Command Conditions (exec tools)
Glob patterns matching the full command string. Case-sensitive.Glob syntax:
*- Any characters (single segment)**- Any characters (crosses/)?- Any single character
Use
** to match paths with slashes. Limited to 2 ** per pattern for performance.Exclude patterns. Rule only matches if command does NOT match any of these patterns.
Substring matching (case-insensitive). Checks if command contains any of these strings.
Path Conditions (read/write tools)
Glob patterns matching file paths. Works on both Unix and Windows paths.
Windows paths require double backslashes (
\\) in YAML strings.Exclude path patterns. Rule only matches if path does NOT match any of these.
Network Conditions (fetch tools)
Glob patterns matching full URLs.
Glob patterns matching domain names. Automatically extracts domain from URLs.
Session Conditions
Glob patterns matching session identity. Sessions are auto-detected as
repo/branch from git.Exclude sessions. Rule only matches if session does NOT match any pattern.
Agent Depth Conditions
Match nested sub-agent depth.
0 = top-level agent, 1+ = sub-agents.MCP Parameter Conditions
Match MCP tool input parameters by case-insensitive glob pattern. Keys are parameter names, values are glob patterns. Rule matches if any parameter condition matches.
Response Conditions
Regex patterns matching tool output. Used for credential leak detection and prompt injection defense.
Exclude response patterns. Rule only matches if response does NOT match any pattern.
Rate Limiting
Sliding-window rate limiting for tool calls. Rampart increments the counter on every PreToolUse event.
Default Catch-All
Catch-all condition. When
true, matches any tool call that reaches this rule.Complete Examples
Block Credential Access
Block Destructive Commands with Exceptions
Detect Credential Leaks in Output
Rate Limit Network Calls
Validation Rules
Pattern Syntax
- Glob patterns use
*,**, and?wildcards **limited to 2 per pattern for performancecommand_containsis case-insensitive, all others case-sensitive- Regex patterns (response_matches) use Go RE2 syntax
Logical Operators
- Multiple conditions within
whenare AND’ed together - Multiple patterns within a condition field are OR’ed together
*_not_matchescreates exclusions
Best Practices
Order Matters
Rules evaluate top-to-bottom. Place specific denies first, then catch-all allows.
Use command_contains for Bypasses
Substring matching catches obfuscation tricks that evade glob patterns (e.g.,
SUDO, Rm -Rf).Test Before Deploy
Use
rampart test "command" to dry-run commands against your policy.Next Steps
- Learn about Actions (deny, allow, watch, ask)
- Configure Webhooks for external decision logic
- Review Policy Structure for top-level schema