You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Convert to LynxDB with a pipeline (custom index)
180
+
rsigma convert rules/ -t lynxdb -p pipeline.yml
181
+
182
+
# LynxDB minimal format (search expression only, for the API q parameter)
183
+
rsigma convert rules/ -t lynxdb -f minimal
184
+
176
185
# List available conversion backends
177
186
rsigma list-targets
178
187
@@ -260,7 +269,7 @@ From there, the AST can go in three directions depending on what you need:
260
269
261
270
-**Evaluation:**`rsigma-eval` compiles rules into optimized matchers (`compiler.rs`), runs stateless detection through `Engine`, and tracks stateful correlation (`correlation.rs`: sliding windows, group-by, chaining, suppression) across events. Processing pipelines handle field mapping, transformations, conditions, and finalizers before compilation. Events are accessed through a trait with implementations for JSON, key-value, and plain text.
262
271
263
-
-**Conversion:**`rsigma-convert` transforms rules into backend-native query strings through a pluggable `Backend` trait. A condition walker traverses the AST and delegates to the backend for each node. `TextQueryConfig` exposes ~90 configuration fields for text-based backends. The PostgreSQL/TimescaleDB backend is the primary concrete implementation, generating SQL for historical threat hunting.
272
+
-**Conversion:**`rsigma-convert` transforms rules into backend-native query strings through a pluggable `Backend` trait. A condition walker traverses the AST and delegates to the backend for each node. `TextQueryConfig` exposes ~90 configuration fields for text-based backends. Concrete implementations include PostgreSQL/TimescaleDB (SQL for historical threat hunting) and LynxDB (SPL2-compatible search queries for log analytics).
264
273
265
274
-**Editor support:**`rsigma-lsp` provides an LSP server over stdio (via `tower-lsp`) with real-time diagnostics (lint + parse + compile errors), completions, hover documentation, document symbols, and code actions. Works with VSCode, Neovim, Helix, Zed, and any LSP-capable editor.
266
275
@@ -320,8 +329,9 @@ Feature-gated items are marked with \* in the diagram.
Copy file name to clipboardExpand all lines: crates/rsigma-convert/README.md
+99-1Lines changed: 99 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,15 @@ The crate provides a generic conversion framework that any backend can plug into
17
17
-**Deferred expressions** through the `DeferredExpression` trait and `DeferredTextExpression` for backends that need post-query appendages (e.g. Splunk `| regex`, `| where`).
18
18
-**Test backend** with `TextQueryTestBackend` and `MandatoryPipelineTestBackend` for backend-neutral foundation testing.
19
19
-**PostgreSQL/TimescaleDB backend** with native `ILIKE`, regex (`~*`), CIDR (`inet`/`cidr`), full-text search (`tsvector`/`tsquery`), JSONB field access, correlation via CTEs and window functions, and TimescaleDB-specific output formats (continuous aggregates, `time_bucket` queries, view generation).
20
+
-**LynxDB backend** generating SPL2-compatible `FROM <index> | search ...` queries with glob wildcards, deferred `| where` clauses for regex and CIDR, `CASE()` case-sensitive matching, and correct parenthesization for LynxDB's non-standard boolean precedence (`NOT > OR > AND`).
20
21
21
22
## Backends
22
23
23
24
| Backend | Target names | Description |
24
25
|---------|-------------|-------------|
25
26
| Test |`test`| Backend-neutral text queries for foundation testing |
26
27
| PostgreSQL |`postgres`, `postgresql`, `pg`| Native PostgreSQL SQL with TimescaleDB support |
@@ -231,7 +288,7 @@ For text-based query backends (the vast majority), create a `TextQueryConfig` wi
231
288
3. Override specific methods for backend-specific behavior (e.g. deferred regex for Splunk, SQL-specific CIDR handling for PostgreSQL).
232
289
4. Register your backend in the CLI's `get_backend()` registry.
233
290
234
-
See `backends/test.rs` for a complete reference implementation and `backends/postgres.rs` for a production backend with SQL-specific overrides.
291
+
See `backends/test.rs` for a complete reference implementation, `backends/postgres.rs` for a production backend with SQL-specific overrides, and `backends/lynxdb/` for a `TextQueryConfig`-based backend with deferred expressions and custom precedence handling.
235
292
236
293
## PostgreSQL Backend Details
237
294
@@ -308,6 +365,47 @@ This matches the nested traversal behavior of the evaluation engine (`rsigma-eva
The LynxDB backend (`LynxDbBackend`) generates SPL2/Lynx Flow queries for the [LynxDB](https://github.com/proximax-storage/lynxdb) log analytics engine. It produces `FROM <index> | search <predicates>` queries with deferred `| where` clauses for operations that LynxDB's search syntax does not natively support.
371
+
372
+
| Sigma Modifier | LynxDB Query |
373
+
|----------------|-------------|
374
+
| `contains` | `field=*"value"*` |
375
+
| `startswith` | `field="value"*` |
376
+
| `endswith` | `field=*"value"` |
377
+
| `re` | `\| where field=~"pattern"` (deferred) |
378
+
| `cidr` | `\| where cidrmatch("cidr", field)` (deferred) |
379
+
| `cased` (exact) | `field=CASE("value")` |
380
+
| wildcards (`*`) | `field="va*lue"` (glob) |
381
+
| wildcards (`?`) | `\| where field=~"va.lue"` (deferred, converted to regex) |
382
+
| `exists` | `field=*` |
383
+
| `null` | `NOT field=*` |
384
+
| keywords | `"value"` (unbound search) |
385
+
386
+
### Boolean precedence
387
+
388
+
LynxDB's parser uses non-standard boolean operator precedence: `NOT > OR > AND`. This differs from most query languages where AND binds tighter than OR. The backend explicitly parenthesizes AND groups to preserve Sigma's intended logic:
389
+
390
+
```
391
+
Sigma: A AND B OR C (intended: (A AND B) OR C)
392
+
Query: (A AND B) OR C (explicit parens prevent misparse as A AND (B OR C))
393
+
```
394
+
395
+
### Deferred expressions
396
+
397
+
Regex patterns, CIDR matches, and single-character wildcard (`?`) patterns cannot be expressed in LynxDB's `search` syntax and are instead emitted as `| where` pipeline stages appended after the search clause:
398
+
399
+
```
400
+
FROM main | search status=500 | where Path=~"/api/.*"
401
+
```
402
+
403
+
When a detection contains only deferred expressions, the search clause uses `*` (match all) followed by the deferred stages:
404
+
405
+
```
406
+
FROM main | search * | where SourceIP=~"^10\.0\." | where cidrmatch("192.168.1.0/24", DestIP)
0 commit comments