# Sigma

> Match log events against Sigma detection rules, check that rules compile, and list the fields they use

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/sigma.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `sigma`. Release: [v0.5.0](https://github.com/Query-farm/vgi-sigma/releases/tag/v0.5.0). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-sigma) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=sigma). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

No service credentials are declared by this connector. Individual datasets, input files or deployments may have their own prerequisites.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### uvx

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

```sql
ATTACH 'sigma' AS sigma (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-sigma@v0.5.0 vgi-sigma-worker'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'sigma' AS sigma (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-sigma:0.5.0'
);
```

## Turn matching log events into security alerts

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
WITH logs(event_id, event) AS (VALUES (1, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "admin"}'), (2, '{"EventID": 4624, "LogonType": 3, "TargetUserName": "admin"}'), (3, '{"EventID": 4625, "LogonType": 3, "TargetUserName": "svc_backup"}')) SELECT l.event_id, i.title, i.level, i.tags FROM logs AS l CROSS JOIN sigma.main.sigma_rule_info('{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') AS i WHERE sigma.main.sigma_match(l.event, '{title: Failed Network Logon, level: medium, tags: [attack.credential_access, attack.t1110], logsource: {product: windows, service: security}, detection: {selection: {EventID: 4625, LogonType: 3}, condition: selection}}') ORDER BY l.event_id
```

- [sigma.main.sigma_rule_info — table_function](https://query.farm/products/orchard/connectors/sigma/objects/table_function.bWFpbg.c2lnbWFfcnVsZV9pbmZv.md): exact declaration for this example.
- [sigma.main.sigma_match — scalar_function](https://query.farm/products/orchard/connectors/sigma/objects/scalar_function.bWFpbg.c2lnbWFfbWF0Y2g.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T06:21:29+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.5.0",
  "sample": {
    "columns": [
      "event_id",
      "title",
      "level",
      "tags"
    ],
    "types": [
      "INTEGER",
      "VARCHAR",
      "VARCHAR",
      "VARCHAR[]"
    ],
    "rows": [
      [
        1,
        "Failed Network Logon",
        "medium",
        "[\"attack.credential_access\", \"attack.t1110\"]"
      ],
      [
        3,
        "Failed Network Logon",
        "medium",
        "[\"attack.credential_access\", \"attack.t1110\"]"
      ]
    ],
    "more": false
  }
}
```

## Connector reference

### Sigma Detection Rules in SQL

![Sigma logo](https://raw.githubusercontent.com/SigmaHQ/sigma/master/images/Sigma_0.3.png)

Run [Sigma](https://sigmahq.io) detection rules — the open, vendor-neutral standard for **detection-as-code** — directly over your log and event tables in SQL, powered by [pySigma](https://github.com/SigmaHQ/pySigma).

This extension brings SIEM-style threat detection and threat hunting into DuckDB. If you have events as rows (Windows Security logs, EDR telemetry, cloud audit trails, web/proxy logs, or any JSON records), you can take a Sigma rule and ask, per row, "does this event match?" — without exporting data to a separate SIEM. It is built for detection engineers, threat hunters, incident responders, and data engineers who want to test, triage, and measure detection coverage where the data already lives. It is a defensive security tool and part of Query Farm's cyber analytics cluster alongside YARA, IOC, CVE, PE, and X.509 workers.

Under the hood, each rule's YAML is parsed and compiled once by pySigma — the reference Sigma implementation maintained by [SigmaHQ](https://github.com/SigmaHQ/sigma) — into a boolean condition tree, then evaluated against every row. Compilation is cached by rule text, so a constant rule scanned across a whole log column compiles a single time and only the per-row match runs hot, keeping column scans cheap. The evaluator honors Sigma field modifiers (contains, startswith, endswith, regex, and the rest), wildcard string matching, numeric, boolean and null values, and the full selector grammar (`1 of selection_*`, `all of them`, and friends). Rules and their metadata, including [MITRE ATT&CK](https://attack.mitre.org) tags, are read straight from the rule text.

The workflow is deliberately simple: keep your events as rows, express detection logic as Sigma YAML, and evaluate one against the other as an ordinary SQL predicate. Because a constant rule compiles once and only the boolean match runs per row, applying a detection across a whole log column stays cheap enough to run interactively. Beyond matching, the catalog also lets you validate a rule library before you trust it, and introspect a rule's header metadata and referenced fields for triage, index planning, and coverage analysis — so a single attached worker covers the detect / validate / plan loop of detection engineering.

A typical hunt applies a matcher predicate per row over a log table (for example in a `WHERE` clause against `to_json(row)`), while separate helpers validate that a rule library compiles and introspect rule metadata and referenced fields for planning. A browsable discovery table lists the field modifiers the evaluator supports.

Learn more from the [Sigma documentation](https://sigmahq.io/docs/), the [pySigma reference docs](https://sigmahq-pysigma.readthedocs.io), and the [pySigma source repository](https://github.com/SigmaHQ/pySigma).

## Find the exact SQL object

[Browse 5 object declarations](https://query.farm/products/orchard/api/v1/connectors/sigma/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=sigma&q=sigma).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-sigma",
  "harvest": {
    "status": "ok",
    "method": "subprocess",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 4,
    "passed": 4,
    "failed": 0,
    "needs_credentials": 0,
    "location": "uvx --from git+https://github.com/Query-farm/vgi-sigma@v0.5.0 vgi-sigma-worker",
    "transport": "subprocess",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:17:58+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
