Rule YAML Schema
Here’s a complete custom rule example:Required Fields
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (e.g., CUSTOM_001) |
name | string | Human-readable rule name |
description | string | What the rule detects |
severity | string | CRITICAL, HIGH, MEDIUM, LOW, or INFO |
category | string | Rule category (e.g., custom, prompt-injection) |
patterns | array | List of detection patterns (see below) |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
targets | array | All files | File globs (e.g., ["*.md", "*.json"]) |
match_mode | string | any | any (OR) or all (AND) |
exclude_patterns | array | None | Patterns that suppress matches |
remediation | string | None | How to fix the issue |
examples | object | None | Test cases for validation |
Pattern Types
Regex Patterns
Use Go’s RE2 regex syntax (no lookaheads or lookbehinds):\\) in YAML strings.
Flags:
(?i)— case-insensitive(?m)— multiline mode(?s)— dot matches newline
Contains Patterns
Simple substring matching (case-insensitive):Match Modes
Any Mode (OR)
Default. Any pattern match triggers the rule:All Mode (AND)
All patterns must match:Exclude Patterns
Suppress matches in specific contexts:Example: Suppress in Code Blocks
File Targets
Limit rules to specific file types:targets to scan all files.
Examples (Self-Testing)
Provide test cases to validate your rule:aguara test-rules to validate your custom rules against these examples (future feature).
Multi-Document YAML
Define multiple rules in one file using--- separators:
Loading Custom Rules
Place custom rules in a directory and pass--rules:
Real-World Examples
Detect Internal Hostnames
Detect Hardcoded IP Addresses
Detect Sensitive Environment Variables
Detect Debugging Artifacts
Detect Deprecated MCP Servers
Best Practices
1. Start with High-Signal Patterns
Avoid overly broad patterns that cause false positives:2. Use Exclude Patterns Liberally
Reduce noise by excluding common false-positive contexts:3. Provide Remediation Guidance
Help users fix the issue:4. Test with Examples
Validate your rule before deployment:5. Use Descriptive IDs and Names
Constraints
RE2 Regex Syntax
Go’sregexp package uses RE2 syntax, which does not support:
- Lookaheads:
(?=...),(?!...) - Lookbehinds:
(?<=...),(?<!...) - Backreferences:
\1,\2 - Possessive quantifiers:
*+,++
match_mode: all:
File Size Limit
Rule files larger than 1 MB are skipped with a warning.No Cross-File Analysis
Rules scan files independently — no cross-file taint tracking (use built-in Toxic Flow analyzer for that).Sharing Rules
Share your custom rules with the community:- Publish to a GitHub repo
- Document the threat model and remediation
- Include
examplesfor validation - Submit a PR to Aguara’s built-in rules if widely applicable
Next Steps
Rule Overview
Learn how to list and explain built-in rules
Browse Categories
See all 177 built-in rules across 13 categories
