Skip to main content

Tests Coverage Badge Status

pySigma SQLite Backend

This is the SQLite backend for pySigma. It provides the package sigma.backends.sqlite with the sqliteBackend class.

This backend also aims to be compatible with Zircolite which uses pure SQLite queries to perform SIGMA-based detection on EVTX, Auditd, Sysmon for linux, XML or JSONL/NDJSON Logs.

It supports the following output formats:

  • default: plain SQLite queries
  • zircolite : SQLite queries in JSON format for Zircolite

This backend is currently maintained by:

Requirements

  • Python 3.10 or later
  • pySigma >= 1.0.2, < 2.0 (tested with 1.4.0)

Supported Features

Sigma Modifiers

Modifier Description SQLite Implementation
contains Substring matching LIKE '%value%'
startswith Prefix matching LIKE 'value%'
endswith Suffix matching LIKE '%value'
all All values must match Multiple AND conditions
re Regular expressions REGEXP
cidr CIDR network matching Expanded to LIKE patterns
cased Case-sensitive matching GLOB
fieldref Compare two fields field1=field2 or with LIKE for startswith/endswith/contains
exists Field existence check field = field
gt, gte, lt, lte Numeric comparisons >, >=, <, <=
neq Not equal NOT field='value'
hour, minute, day, week, month, year Timestamp part extraction strftime()

Note on cased: SQLite's GLOB is a native 2-argument operator with no ESCAPE clause, so queries are emitted as field GLOB 'pattern' and backslashes are kept literal (e.g. Windows paths match as-is). Because GLOB has no escape mechanism, a literal *, ? or [ inside a cased value is still interpreted as a glob metacharacter; escaping such literals ([*]) is not currently supported.

Correlation Rules

The backend supports Sigma correlation rules with the following types:

Correlation Type Description
event_count Count events matching conditions
value_count Count distinct field values
temporal Events from multiple rules occurring within a timespan
temporal_ordered Events occurring in a specific order within a timespan
value_sum Sum of field values
value_avg Average of field values
value_percentile Percentile of field values
value_median Median of field values

The following correlation types are not supported: temporal_extended, temporal_ordered_extended.

Correlation rules support group-by for grouping results and timespan for temporal constraints.

SQLite Requirements for Correlation

For correlation rules to work properly, your SQLite database must meet the following requirements:

Requirement Description
Timestamp field Required for temporal correlations. Must be in a format compatible with SQLite's julianday() function (ISO8601, Julian day number, or Unix timestamp)

Configurable Parameters:

The backend provides configurable parameters for correlation queries:

Parameter Default Description
timestamp_field timestamp Field name containing the event timestamp

Example usage with custom parameters:

backend = sqliteBackend(correlation_methods=["default"])
backend.timestamp_field = "event_time"

Notes:

  • The timestamp field is used with julianday() for time difference calculations in temporal correlations
  • For multi-rule correlations (temporal, temporal_ordered), the backend automatically adds a sigma_rule_id column to identify which rule matched each event
  • Timespan values are converted to seconds internally for comparison

Other Features

  • NULL value handling: field: nullfield IS NULL
  • Boolean values: true/false support
  • Field name quoting: Special characters in field names are quoted with backticks
  • Wildcard escaping: Proper escaping of % and _ characters in values

Known issues/limitations

  • Full text search support will need some work and is not a priority since it needs virtual tables on SQLite side

Quick Start

Example script (default output) with sysmon pipeline

Add pipelines

poetry add pysigma-pipeline-sysmon
poetry add pysigma-pipeline-windows

Convert a rule

from sigma.collection import SigmaCollection
from sigma.backends.sqlite import sqliteBackend
from sigma.pipelines.sysmon import sysmon_pipeline
from sigma.pipelines.windows import windows_logsource_pipeline

# Combine pipelines to map both Channel and EventID:
# 1. sysmon_pipeline: maps category (e.g., process_creation) -> EventID (e.g., 1)
#                     and changes logsource to service=sysmon
# 2. windows_logsource_pipeline: maps service=sysmon -> Channel
#
# For process_creation/windows, this produces:
#   Channel='Microsoft-Windows-Sysmon/Operational' AND EventID=1
combined_pipeline = sysmon_pipeline() + windows_logsource_pipeline()
sqlite_backend = sqliteBackend(combined_pipeline)
# Set the table name for the generated SQL queries
sqlite_backend.table = "logs"


rule = SigmaCollection.from_yaml(
r"""
    title: Test
    status: test
    logsource:
        category: test_category
        product: test_product
    detection:
        sel:
            fieldA: valueA
            fieldB: valueB
        condition: sel
""")

print(sqlite_backend.convert(rule)[0])

Running

poetry run python3 example.py

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysigma_backend_sqlite-1.2.2.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysigma_backend_sqlite-1.2.2-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file pysigma_backend_sqlite-1.2.2.tar.gz.

File metadata

  • Download URL: pysigma_backend_sqlite-1.2.2.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pysigma_backend_sqlite-1.2.2.tar.gz
Algorithm Hash digest
SHA256 3970518045192d5aeb93f444221dce4661388e7b5b1aab289568930dacbfd247
MD5 e5412fbe4aa6f32d4787f2f1caad9d79
BLAKE2b-256 45494589f6b9d87133bfdaab39a8b49ed05a84c07ea4946e8b1e7b8551c02476

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysigma_backend_sqlite-1.2.2.tar.gz:

Publisher: release.yml on SigmaHQ/pySigma-backend-sqlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysigma_backend_sqlite-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pysigma_backend_sqlite-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db553c8af13aa4290a5769f4e3754ecd8970a33254b8d00a65df48039cdc0e76
MD5 582c1e131d40451ae7bfee58c4732a43
BLAKE2b-256 9fdfa13244cb211ea88f6214ab8598f3304c1942d02744a2cbf6b9708203e8af

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysigma_backend_sqlite-1.2.2-py3-none-any.whl:

Publisher: release.yml on SigmaHQ/pySigma-backend-sqlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.2.4

2 files

This release

1.2.2 This release

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page