Skip to content

feat: add daemon mode for long-running real-time detection#6

Merged
mostafa merged 1 commit intomainfrom
feat/daemon-mode
Feb 26, 2026
Merged

feat: add daemon mode for long-running real-time detection#6
mostafa merged 1 commit intomainfrom
feat/daemon-mode

Conversation

@mostafa
Copy link
Copy Markdown
Member

@mostafa mostafa commented Feb 26, 2026

Summary

Adds a new daemon subcommand that runs rsigma as a persistent, long-running detection service — designed to sit behind a log collector (e.g. hel run | rsigma daemon ...) and process events continuously.

  • Continuous NDJSON processing — reads events from stdin, evaluates against Sigma detection and correlation rules, writes matches to stdout
  • HTTP management API — health (/healthz, /readyz), Prometheus metrics (/metrics), status and rule introspection (/api/v1/status, /api/v1/rules), and manual reload trigger (POST /api/v1/reload)
  • Hot-reload — file watcher on the rules directory (debounced 500ms), SIGHUP signal handler, and API endpoint all trigger rule reloads without restart
  • Prometheus metrics — events processed, detection/correlation matches, parse errors, rules loaded, state entries, reload counts, per-event latency histogram, uptime
  • Structured logging — JSON to stderr via tracing, configurable with RUST_LOG
  • Feature-gateddaemon feature (enabled by default) pulls in tokio, axum, prometheus, and notify as optional dependencies
  • CI updated — all workflows now use --all-features to ensure feature-gated code is always checked, linted, tested, and shipped

How it differs from eval

eval daemon
Lifecycle Exits after processing all input Stays alive, waits for more input
HTTP API None Health, metrics, management endpoints
Hot-reload N/A (one-shot) File watcher + SIGHUP + API
Observability Stderr summary Prometheus metrics + structured JSON logs
Use case Batch analysis, scripting, CI Production pipeline, real-time detection

New files

File Purpose
daemon/mod.rs Module structure, re-exports run_daemon
daemon/server.rs Main orchestration: HTTP server, stdin reader, reload logic, API handlers
daemon/state.rs DaemonEngine wrapper over stateless Engine or stateful CorrelationEngine
daemon/engine.rs Per-line event processing with filter application
daemon/metrics.rs Prometheus metric initialization and registration
daemon/health.rs Atomic readiness state
daemon/reload.rs File system watcher and SIGHUP handler

Test plan

  • cargo check --workspace --all-features passes
  • cargo clippy --workspace --all-targets --all-features -- -D warnings clean
  • cargo test --workspace --all-features — 60 tests pass
  • Smoke test: pipe a single event through rsigma daemon, confirm match output
  • Verify hot-reload: modify a rule file while daemon is running
  • Verify /healthz, /readyz, /metrics, /api/v1/status, /api/v1/rules responses
  • Verify POST /api/v1/reload triggers reload
  • Build without daemon feature: cargo build -p rsigma --no-default-features

@mostafa mostafa self-assigned this Feb 26, 2026
@mostafa mostafa changed the title Add daemon mode for long-running real-time detection feat: add daemon mode for long-running real-time detection Feb 26, 2026
Introduce a `daemon` subcommand that runs rsigma as a persistent service:
- Reads NDJSON events from stdin and writes matches to stdout
- Exposes HTTP endpoints for health (/healthz, /readyz), Prometheus
  metrics (/metrics), and management API (/api/v1/status, /api/v1/rules,
  /api/v1/reload)
- Supports hot-reload of Sigma rules via file watcher, SIGHUP, or API
- Feature-gated behind `daemon` (enabled by default) with tokio, axum,
  prometheus, and notify as optional dependencies
- Full structured JSON logging via tracing
- CI and release workflows now use --all-features

Made-with: Cursor
@mostafa mostafa merged commit 715e49f into main Feb 26, 2026
9 checks passed
@mostafa mostafa deleted the feat/daemon-mode branch February 26, 2026 10:45
mostafa added a commit that referenced this pull request Mar 10, 2026
Cargo.lock:
- aws-lc-sys 0.37.1 -> 0.38.0 (with aws-lc-rs 1.16.0 -> 1.16.1)
  Addresses alerts #7, #8, #9:
  - PKCS7_verify Signature Validation Bypass
  - Timing Side-Channel in AES-CCM Tag Verification
  - PKCS7_verify Certificate Chain Validation Bypass

editors/vscode/package-lock.json:
- minimatch 3.1.2 -> 3.1.5 (alert #6: ReDoS via GLOBSTAR segments)
- minimatch 10.2.1 -> 10.2.4 (alert #4: ReDoS via extglobs)
- underscore 1.13.7 -> 1.13.8 (alert #10: DoS via unlimited recursion)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant