Skip to main content

pySigma-backend-libsigma

pySigma backend that compiles Sigma YAML to a libsigma ruleset.

The matcher never parses YAML. This package writes two files:

File What it is
rules.sigmac One binary artifact for the whole collection. Format version 5, as specified in libsigma src/docs/SIGMAC_FORMAT.md.
rules.corr.json Correlation rules (event_count, value_count, temporal, temporal_ordered, the numeric aggregations, and the beaconing extension). Schema version 1, as loaded by libsigma corr_format.h.

License: LGPL-2.1-only, the same grant as pySigma (License-Expression: LGPL-2.1-only) and the SigmaHQ backends. This package subclasses sigma.conversion.base.Backend. libsigma stays Apache-2.0. The serializer is the reference emitter from libsigma (src/reference/sigmac/format.py); the copyright holder publishes this copy under LGPL-2.1-only with the backend. The copy in the libsigma repository stays Apache-2.0.

pip install pySigma-backend-libsigma
libsigma-sigmac rules/ -o rules.sigmac --corr rules.corr.json

From Python:

from sigma.collection import SigmaCollection
from sigma.backends.libsigma import LibsigmaBackend

backend = LibsigmaBackend()
collection = SigmaCollection.from_yaml(open("rule.yml").read())
open("rules.sigmac", "wb").write(backend.convert(collection, "sigmac"))
open("rules.corr.json", "w").write(backend.convert(collection, "corr"))

sigma convert -t libsigma calls the same convert(). The .sigmac result is bytes. Write it from libsigma-sigmac or from the snippet above. -f corr is text.

convert() keeps the full CompileResult on backend.last_result (errors, dropped, warnings, sidecar).

ECS rename

libsigma compares field names as strings. It does not know ECS, Sysmon, or Zeek. If the rule says Image and the event callback returns process.executable, the rule does not match.

SigmaHQ rules are written in the Sigma taxonomy. The field is Image, CommandLine, src_ip, QueryName, User. A collector that parsed the event into ECS has process.executable, process.command_line, source.ip, dns.question.name, user.name.

Those are two different steps, and only the first one lives here.

Rename. With ecs=True (the default), a rule whose taxonomy is sigma or absent is run through ecs_pipeline() before it is compiled. The pipeline is a logsource-gated table:

Rule logsource Sigma name Name written into .sigmac
category: process_creation Image process.executable
category: process_creation CommandLine process.command_line
category: firewall src_ip source.ip
category: dns or dns_query QueryName, query dns.question.name
service: sshd User user.name
category: file_event TargetFilename file.path
category: registry_set TargetObject registry.path
category: image_load ImageLoaded file.path
product: windows, service: security EventID event.code
product: aws, service: cloudtrail eventName event.action
product: linux, service: auditd exe process.executable

A rule marked taxonomy: ecs is already written with the names the callback returns, so the table is not applied. Image in an ecs rule stays Image. libsigma-sigmac --no-ecs (or LibsigmaBackend(ecs=False)) does the same for every rule: the name in the YAML is the name in the artifact.

The same tables are installed as the pySigma pipeline libsigma_ecs (sigma.pipelines.libsigma) for a caller that wants the rename without this backend.

After the rename. Every remaining name is compiled. A name with no table row is written as it appears (CustomVendorField stays CustomVendorField). Whether a deployment's parsers produce that field is a second decision, made by the caller. compile_rules(..., gate=...) can return a drop reason after the rename. convert() has no such gate: filter the collection first, or call compile_rules directly.

Correlations

Standard correlation documents are parsed by pySigma. Two shapes are peeled out of the YAML first, because pySigma rejects their condition objects, and then compiled into the same rules.corr.json:

  • correlation.type: beaconing with cv_permille and n_buckets
  • temporal / temporal_ordered whose condition is a boolean string (SEP #198)

A correlation whose base rule did not compile is listed in CompileResult.dropped with a reason.

Development

python3 -m pip install -e '.[dev]'
python3 -m pytest

Commits follow docs/COMMIT.md. Install the hook once:

git config core.hooksPath .githooks
git config commit.template .gitmessage

Metadata

Release files for pySigma-backend-libsigma 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pySigma-backend-libsigma 0.1.0
File Size Uploaded Provenance Actions
pysigma_backend_libsigma-0.1.0.tar.gz 58.0 kB With provenance Details for pysigma_backend_libsigma-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pySigma-backend-libsigma 0.1.0
File Interpreter ABI Platform Actions
pysigma_backend_libsigma-0.1.0-py3-none-any.whl Python 3 none any Details for pysigma_backend_libsigma-0.1.0-py3-none-any.whl

Total release size: 118.5 kB

Release files / pysigma_backend_libsigma-0.1.0.tar.gz

Download URL pysigma_backend_libsigma-0.1.0.tar.gz
Size 58.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6043e3b7e72027dc44a6a008e8662b2cc62358fec8b720bee5c887de677c6cc8
BLAKE2b-256 checksum
How to use checksums
edf99ca7c6cc37a967cb4c95b944d5d3211e1691ac922b7b0df46846d07924d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / pysigma_backend_libsigma-0.1.0-py3-none-any.whl

Download URL pysigma_backend_libsigma-0.1.0-py3-none-any.whl
Size 60.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c9710dc37f608d90b4641a6c17bb825db62f277aaefcc137024a838a97f1387
BLAKE2b-256 checksum
How to use checksums
0487e04eabd6bcfc9c8ea1f1ef8b3323f0f6a7168604f7a2d0c1566228b22fdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for pySigma-backend-libsigma 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pysigma_backend_libsigma-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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