idps-escape

SONAR documentation

Comprehensive documentation for SONAR (SIEM-Oriented Neural Anomaly Recognition) - the scenario-based anomaly detection system for IDPS-ESCAPE.

⚠️ All commands should be run from project root (/home/alab/soar)

πŸ’» For Python API reference: See sonar/README.md for developer quickstart and programmatic usage examples.

Documentation overview

Document Purpose Audience
setup-guide.md Installation, configuration, CLI usage, debug mode Everyone
scenario-guide.md Complete scenario system guide with examples Users & Developers
data-injection-guide.md Inject synthetic data for fast testing Testers & Developers
data-shipping-guide.md Ship anomalies to Wazuh data streams (production feature) Operators & DevOps
model-naming-guide.md Model naming and versioning strategies Users & Developers
troubleshooting.md Error solutions and diagnostics Everyone
architecture.md System design, patterns, and principles Developers & Architects
uml-diagrams.md Visual system design diagrams Developers & Architects

Getting started

New users (5 minutes)

# 1. Install (from project root)
cd /home/alab/soar
poetry install --with sonar

# 2. Run a scenario (from project root)
poetry run sonar scenario --use-case sonar/scenarios/brute_force_detection.yaml --debug

Read: setup-guide.md

Understanding scenarios (15 minutes)

  1. Review built-in scenarios in sonar/scenarios/ (from project root):
    • brute_force_detection.yaml - SSH/authentication attacks
    • lateral_movement_detection.yaml - Network traversal attacks
    • privilege_escalation_detection.yaml - Privilege abuse
    • linux_resource_monitoring.yaml - Resource utilization anomalies
  2. Read scenario structure in scenario-guide.md
  3. Create custom scenario following templates

Troubleshooting issues

Check troubleshooting.md for:

Architecture deep dive

For developers extending the system:

  1. Read architecture.md - design principles and module structure
  2. Review uml-diagrams.md - class and sequence diagrams
  3. Examine source code in ../ with architecture context

Quick reference by task

Task Document Section
Install SONAR setup-guide.md Installation
Configure Wazuh connection setup-guide.md Configuration
Run first scenario scenario-guide.md Overview β†’ Example
Test with synthetic data data-injection-guide.md Quick start
Enable data shipping (production) data-shipping-guide.md Quick start
Integrate with RADAR data-shipping-guide.md Integration with RADAR
View system diagrams uml-diagrams.md All diagrams

Key concepts

Scenario-based approach

SONAR uses YAML scenarios to define anomaly detection workflows:

name: "Brute Force Detection"
training:
  lookback_hours: 168  # 1 week baseline
  numeric_fields: ["rule.level"]
detection:
  mode: "batch"
  threshold: 0.7

See scenario-guide.md for complete details.

Flexible execution

Scenarios automatically execute based on sections present:

See scenario-guide.md

Debug mode

Test without Wazuh infrastructure:

poetry run sonar scenario --use-case scenario.yaml --debug

Uses local JSON test data for development and CI/CD.

See setup-guide.md

Configuration separation

See setup-guide.md

System architecture

Conceptual view (high-level components):

CLI Commands (train, detect, scenario, check)
    ↓
Configuration (YAML β†’ Python dataclasses)
    ↓
Data Ingestion (WazuhIndexerClient | LocalDataProvider)
    ↓
Feature Engineering (WazuhFeatureBuilder)
    ↓
ML Engine (MVADModelEngine - Microsoft MVAD)
    ↓
Post-processing (MVADPostProcessor)
    ↓
Storage (Wazuh Indexer / OpenSearch)

Details: architecture.md

Built-in scenarios

Scenario Use Case File (from project root)
Brute Force Detection Authentication attacks sonar/scenarios/brute_force_detection.yaml
Lateral Movement Cross-host authentication sonar/scenarios/lateral_movement_detection.yaml
Privilege Escalation Unusual sudo/su usage sonar/scenarios/privilege_escalation_detection.yaml
Resource Monitoring CPU/memory anomalies sonar/scenarios/linux_resource_monitoring.yaml

See scenario-guide.md

Testing

# All tests
poetry run pytest tests/

# Specific component
poetry run pytest tests/engine_test.py

# With coverage
poetry run pytest --cov=sonar

Test files in ../../tests/

Integration

Wazuh

RADAR

SONAR anomalies trigger RADAR automated responses:

Details: setup-guide.md

Project structure

Relative to project root (/home/alab/soar/):

sonar/
β”œβ”€β”€ README.md                  # SONAR overview
β”œβ”€β”€ scenarios/                 # Built-in detection scenarios
β”‚   β”œβ”€β”€ brute_force_detection.yaml
β”‚   β”œβ”€β”€ lateral_movement_detection.yaml
β”‚   β”œβ”€β”€ privilege_escalation_detection.yaml
β”‚   └── linux_resource_monitoring.yaml
β”œβ”€β”€ test_data/                 # Test datasets for debug mode
β”‚   β”œβ”€β”€ synthetic_alerts/
β”‚   β”œβ”€β”€ generated_scenarios/
β”‚   └── resource_monitoring/
β”œβ”€β”€ models/                    # Trained model storage
β”œβ”€β”€ cli.py                     # Command-line interface
β”œβ”€β”€ config.py                  # Configuration system
β”œβ”€β”€ scenario.py                # Scenario loader
β”œβ”€β”€ engine.py                  # MVAD model wrapper
β”œβ”€β”€ features.py                # Feature engineering
β”œβ”€β”€ pipeline.py                # Post-processing
β”œβ”€β”€ wazuh_client.py            # Wazuh API client
└── local_data_provider.py     # Debug mode data provider

Contributing

When extending SONAR:

  1. Follow existing patterns in architecture.md
  2. Add tests for new features
  3. Update relevant documentation
  4. Test with debug mode before production

Documentation conventions

Documentation standards

All documentation in this folder follows these standards:


Quick reference

Run tests

# From project root (/home/alab/soar)
poetry run pytest tests/sonartests/ -v

Execute scenario

# From project root (/home/alab/soar)
poetry run sonar scenario --use-case sonar/scenarios/brute_force_detection.yaml

View documentation

# From project root (/home/alab/soar)
cat docs/manual/sonar_docs/setup-guide.md
cat docs/manual/sonar_docs/scenario-guide.md
cat docs/manual/sonar_docs/architecture.md

Support

For help with specific topics: