public/
— Source YAML playbooks (edit these)sigma/
— Playbooks for Sigma detection rulesnids/
— Playbooks for NIDS rulesyara/
— Playbooks for YARA rules
securityonion-normalized/
— Normalized output (auto-generated, do not edit by hand)scripts/patterns_sigma.yaml
— Substitution patterns for Sigma rules and enginescripts/patterns_nids.yaml
— Substitution patterns for NIDS rules and enginescripts/validate_playbooks.py
— Python script for validation - run before normalizationscripts/normalize_playbooks.py
— Python script for normalization
Playbook IDs use a 7-digit numbering system with organized ranges by type:
- Overall Range: 1,000,000 - 1,999,999 (reserved for Security Onion Playbooks)
- NIDS Indidivual Range: 1,200,001 - 1,499,999 (individual NIDS detection playbooks)
- Sigma Indidivual Range: 1,500,001 - 1,599,999 (individual Sigma detection playbooks)
- Category/Engine Range: 1,600,001 - 1,999,999 (category and engine-level playbooks)
- Individual detection playbooks: Use appropriate range (NIDS or Sigma)
- Category-level playbooks: Use 1,600,001+ range
- Engine-level playbooks: Use 1,600,001+ range
- Format: 7-digit number (e.g., 1200001, 1500001, 1600001)
The validation script recursively checks source playbooks in all subdirectories for correct metadata and valid Sigma query syntax. It should be run before normalization to ensure playbook quality.
python scripts/validate_playbooks.py public/
This will validate all YAML files in public/
and its subdirectories (public/sigma/
, public/nids/
, public/yara/
, etc.)
python scripts/validate_playbooks.py public/ --fixup
- Automatically fixes common Sigma query structure issues
- Fixes misplaced
condition
fields - Adds missing
condition: selection
for simple cases - Corrects
|regex
modifiers to|re
- Updates detection_category when detection_id is set
python scripts/validate_playbooks.py public/ --staged
- Only validates files staged for git commit
- Useful for pre-commit hooks
--workers N
— Set number of parallel workers (default: auto, max 8)--reset DIR
— Delete failed playbooks from validation and reset directories, create backups in ./failed/--verbose
— Show detailed validation output
-
Metadata Requirements:
- Required fields: name, id, description, type, detection_id, detection_category, detection_type, contributors, created, questions
- ID must be between 1200001-1999999
- Name must include "ET" or "GPL" category
- Type must be "detection"
- Detection type must be "nids"
- Contributors must include "SecurityOnionSolutions"
- Created date must be YYYY-MM-DD format
- Must have 8-15 questions
-
Sigma Query Validation:
- Validates each question's Sigma query syntax using sigma-cli
- Checks for required fields: logsource, detection
- Ensures no unexpanded template references exist
- Validates query structure and syntax
-
Duplicate ID Detection:
- Checks for duplicate playbook IDs across all files
python scripts/normalize_playbooks.py --all
- Normalizes all YAML files in
public/
and writes tosecurityonion-normalized/
. - Deletes any orphaned files in
securityonion-normalized/
.
python scripts/normalize_playbooks.py --staged
- Only normalizes files staged for commit (added/modified/deleted).
- Intended for use with pre-commit hooks.
- Install pre-commit (if not already):
pip install pre-commit
- Add a
.pre-commit-config.yaml
- Install the hook:
pre-commit install
- Always edit files in
public/
. - Never edit
securityonion-normalized/
by hand. - Use the normalization script to keep everything in sync.