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
Copy file name to clipboardExpand all lines: crates/rsigma-convert/README.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,14 +97,28 @@ for result in &output.queries {
97
97
|`view`|`CREATE OR REPLACE VIEW sigma_{id} AS SELECT ...`|
98
98
|`timescaledb`| Queries with `time_bucket()` for TimescaleDB optimization |
99
99
|`continuous_aggregate`|`CREATE MATERIALIZED VIEW ... WITH (timescaledb.continuous)`|
100
+
|`sliding_window`| Correlation queries using window functions for per-row sliding detection |
101
+
102
+
### SELECT column selection
103
+
104
+
When a Sigma rule specifies `fields:`, the backend emits `SELECT field1, field2, ...` instead of `SELECT *`. Function calls (e.g. `count(*)`) pass through unchanged, and `field as alias` is supported with both sides quoted independently.
105
+
106
+
### CLI backend options
107
+
108
+
Backend configuration can be set via `-O key=value` flags on the CLI, which are wired through to `PostgresBackend::from_options`. Recognized keys: `table`, `schema`, `database`, `timestamp_field`, `json_field`, `case_sensitive_re`.
@@ -235,6 +249,23 @@ The PostgreSQL backend (`PostgresBackend`) leverages native PostgreSQL features
235
249
236
250
Correlation rules are converted to SQL using `GROUP BY` / `HAVING` for aggregation types (`event_count`, `value_count`, `value_sum`, `value_avg`, `value_percentile`, `value_median`) and CTEs for temporal correlation. Multi-table temporal correlations automatically generate `UNION ALL` CTEs when referenced rules target different tables.
237
251
252
+
Non-temporal correlations support CTE-based pre-filtering: when the correlation references detection rules that were converted in the same collection, the backend wraps their queries in a `WITH combined_events AS (q1 UNION ALL q2 ...)` CTE so the aggregate only counts events matching the detection logic.
253
+
254
+
The `sliding_window` output format uses SQL window functions for `event_count` correlations, producing a per-row sliding window that emits every event crossing the threshold:
255
+
256
+
```sql
257
+
WITH combined_events AS (...),
258
+
event_counts AS (
259
+
SELECT *, COUNT(*) OVER (
260
+
PARTITION BY "User"
261
+
ORDER BY time
262
+
RANGE BETWEEN INTERVAL '300 seconds' PRECEDING AND CURRENT ROW
263
+
) AS correlation_event_count
264
+
FROM combined_events
265
+
)
266
+
SELECT * FROM event_counts WHERE correlation_event_count >= 5
0 commit comments