Skip to main content

sigma-rule-matcher

sigma-rule-matcher is a Python package for evaluating Sigma detection rules against structured event data. Built on top of pySigma, it parses and applies Sigma rule logic—including condition expressions and most common modifiers—to incoming events to determine whether they match.

So far, this project is primarily a learning tool, put together to better understand how Sigma rules operate under the hood.

Installation

Install the package from PyPI:

pip install sigma-rule-matcher

Requires Python 3.10 or later. This will install the library and its dependencies:

  • boolean.py (for boolean expression evaluation)
  • pySigma (for parsing Sigma rules)

Usage

Sigma rules can include multiple selectors, logical operators, and modifiers. For example:

from sigma.rule import SigmaRule
from sigma_rule_matcher import RuleMatcher

sigma_rule = '''
title: Suspicious activity
logsource:
  product: test
detection:
  sel1:
    src_ip:
      - 10.0.0.1
      - 10.0.0.2
  sel2:
    user:
      - root
  sel3:
    process_name:
      - 'malicious.exe'
  condition: (sel1 or sel2) and sel3
'''

rule = SigmaRule.from_yaml(sigma_rule)
matcher = RuleMatcher(rule)

# Test against an event
event = {
    'src_ip': '10.0.0.2',
    'user': 'guest',
    'process_name': 'malicious.exe'
}

assert matcher.match(event) is True

Running Tests

The library includes a comprehensive test suite. To run the tests:

pytest

License

This project is licensed under the MIT License.

It uses the pySigma library, which is licensed under the GNU Lesser General Public License v2.1 (LGPL-2.1). A copy of the LGPL-2.1 license is here.

We use pySigma without modification.

Metadata

Release files for sigma-rule-matcher 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 sigma-rule-matcher 0.1.0
File Size Uploaded Provenance Actions
sigma_rule_matcher-0.1.0.tar.gz 14.3 kB Without provenance Details for sigma_rule_matcher-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sigma-rule-matcher 0.1.0
File Interpreter ABI Platform Actions
sigma_rule_matcher-0.1.0-py3-none-any.whl Python 3 none any Details for sigma_rule_matcher-0.1.0-py3-none-any.whl

Total release size: 24.8 kB

Release files / sigma_rule_matcher-0.1.0.tar.gz

Download URL sigma_rule_matcher-0.1.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bfc099cbd09691602357a4d0adc35e11a647e6b13da55b50a6712bc10cba7677
BLAKE2b-256 checksum
How to use checksums
35c1181de632fa355f074fb6513f1a429ff7ac6ae1ee663bdc90b559718ada4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.2 cpython/3.13.9 HTTPX/0.28.1

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

Download URL sigma_rule_matcher-0.1.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
003f6d5482eb0790a2f0b21a4d01f59b51aebd9437cf3c12239ae1c0693a970f
BLAKE2b-256 checksum
How to use checksums
1e6804ddad69202753070355d1d99b5e2de44eecbde36162fb4c67338c73de08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.2 cpython/3.13.9 HTTPX/0.28.1

Security for sigma-rule-matcher 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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