Guardrails use pattern matching to evaluate queries and block dangerous operations before they execute. This page covers configuration options and rule syntax.Documentation Index
Fetch the complete documentation index at: https://mintlify.hoop.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
For an introduction to what Guardrails do and common use cases, see Guardrails Overview.
Prerequisites
Guardrails are evaluated by the Microsoft Presidio Analyzer — patterns and word lists are sent to Presidio as ad-hoc recognizers, and matching happens inside Presidio. Before configuring guardrails, deploy Presidio and point the gateway at it:Deploy Presidio
Helm chart, sizing, and autoscaling for the Analyzer, Anonymizer, and Envoy Proxy.
Microsoft Presidio Integration
Required gateway environment variables and integration overview.
Creating a Guardrail
Set Basic Information
- Name: A short identifier (e.g.,
block-ddl,read-only-mode) - Description: Explain what this guardrail protects against
Rule Configuration
Input Rules
Input rules evaluate queries before they execute. Use these to block dangerous commands.| Field | Description | Example |
|---|---|---|
| Pattern | Regex pattern to match | (?i)DROP\s+TABLE |
| Action | What to do when pattern matches | Block, Warn, Require Approval |
| Message | Error message shown to user | DDL commands are blocked |
Output Rules
Output rules evaluate query results after execution. Use these to filter or redact output.| Field | Description | Example |
|---|---|---|
| Pattern | Regex pattern to match in output | \b\d{3}-\d{2}-\d{4}\b (SSN) |
| Action | What to do when pattern matches | Redact, Block, Warn |
| Replacement | Text to replace matches with | [REDACTED] |
For data masking that automatically detects PII, see Live Data Masking instead.
Pattern Syntax
Guardrail patterns are compiled by Microsoft Presidio, which uses Python’sre module. Write patterns using Python regex syntax — not JavaScript/ECMAScript and not Go’s RE2.
Basic Syntax
| Syntax | Meaning | Example |
|---|---|---|
(?i) | Case-insensitive | (?i)drop matches DROP, Drop, drop |
\s+ | One or more whitespace | DROP\s+TABLE matches DROP TABLE |
\s* | Zero or more whitespace | DROP\s*TABLE matches DROPTABLE too |
\b | Word boundary | \bDROP\b won’t match BACKDROP |
^ | Start of string | ^SELECT only matches SELECT at start |
$ | End of string | ;\s*$ matches trailing semicolon |
.* | Any characters | SELECT.*FROM matches anything between |
(?!...) | Negative lookahead | (?!.*WHERE) means “not followed by WHERE” |
Common Patterns
Block UPDATE without WHERE:Testing Patterns
Before deploying a pattern, test it at regex101.com:- Select Flavor: Python
- Paste your pattern in the Regular Expression field
- Enter test queries in the Test String field
- Verify matches highlight correctly
Inline flags (
(?i), (?m), (?s)), lookaheads ((?!...)), lookbehinds ((?<=...)), and word boundaries (\b) are all supported by Python’s re. Avoid JavaScript-only constructs — for example, Python’s named groups use (?P<name>...), not (?<name>...).Actions
Block
Prevents the query from executing and returns an error. Use when: The operation should never be allowed (e.g.,DROP TABLE in production)
User sees:
Warn
Allows the query but shows a warning message. Use when: You want to educate users without blocking work (e.g., missing LIMIT) User sees:Require Approval
Blocks the query until an approver approves it. Use when: Some queries need human review before execution (e.g., bulk updates) User sees:Require Approval uses the same workflow as Action Access Requests.
Resource Role Assignment
Each guardrail can be assigned to multiple resource roles. You can also have multiple guardrails on a single resource role.Assignment Options
| Option | Description |
|---|---|
| Specific resource roles | Select individual resource roles from the list |
| All resource roles | Apply to every resource role in your organization |
| Resource role tags | Apply to resource roles matching specific tags |
Evaluation Order
When multiple guardrails apply to a resource role, they are evaluated in order of priority:- Priority 1 (highest) evaluated first
- First matching rule determines the action
- If no rules match, query is allowed
- Go to Manage > Guardrails
- Drag guardrails to reorder them
- Higher position = higher priority
Environment Variables
Guardrails run inside Microsoft Presidio, so they share the same gateway environment variables as Live Data Masking. Configure these on the gateway — guardrails will not evaluate without them:| Variable | Description | Example |
|---|---|---|
DLP_PROVIDER | Must be set to enable Presidio-backed guardrails | mspresidio |
MSPRESIDIO_ANALYZER_URL | URL of the Presidio Analyzer service | http://presidio-envoy-lb:3010 |
MSPRESIDIO_ANONYMIZER_URL | URL of the Presidio Anonymizer service | http://presidio-envoy-lb:3010 |
DLP_MODE | best-effort or strict (shared with Live Data Masking) | best-effort |
Monitoring Guardrails
Viewing Blocked Queries
- Go to Sessions in the sidebar
- Filter by Status: Blocked
- Click a session to see details
- The query that was blocked
- Which guardrail and rule triggered
- The error message
- User and timestamp
Audit Log
All guardrail evaluations are logged:- Blocked queries - Logged with full query text
- Warnings - Logged with warning message
- Approval requests - Logged with request status
Best Practices
Start with Warn
Use Warn mode first to understand impact before blocking
Test in Dev First
Apply guardrails to test resource roles before production
Be Specific
Use precise patterns to avoid false positives
Document Rules
Write clear descriptions explaining why each rule exists
Pattern Guidelines
- Always use
(?i)for case-insensitive matching - Use
\bfor word boundaries to avoid partial matches - Use
^\s*to allow leading whitespace - Test edge cases like multi-line queries and comments
- Keep patterns simple - complex regex is hard to maintain
Troubleshooting
Pattern Not Matching
Check:- Test the pattern at regex101.com with the exact query
- Verify case sensitivity (add
(?i)if needed) - Check for leading/trailing whitespace in the query
Too Many False Positives
Fix:- Make the pattern more specific
- Add word boundaries (
\b) - Use negative lookahead for exceptions
DROP blocks DROP_SHIPPED_ITEMS table name
Fix: (?i)^\s*DROP\s+(TABLE|DATABASE) only matches DDL commands
Performance Issues
If queries are slow:- Reduce the number of rules per resource role
- Simplify complex regex patterns
- Avoid patterns with excessive backtracking (e.g.,
.*.*.*)
Related
Guardrails Overview
Learn what guardrails do and see common recipes
Live Data Masking
Configure automatic PII detection and masking
Action Access Requests
Configure the “Require Approval” action
Access Control
Control who can access which resource roles