Skip to main content

No project description provided

Project description

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.

Project details


Download files

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

Source Distribution

sigma_rule_matcher-0.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

sigma_rule_matcher-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file sigma_rule_matcher-0.1.0.tar.gz.

File metadata

  • Download URL: sigma_rule_matcher-0.1.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.13.9 HTTPX/0.28.1

File hashes

Hashes for sigma_rule_matcher-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bfc099cbd09691602357a4d0adc35e11a647e6b13da55b50a6712bc10cba7677
MD5 bb07ece0d3c6b73468ef9fedc8a43a60
BLAKE2b-256 35c1181de632fa355f074fb6513f1a429ff7ac6ae1ee663bdc90b559718ada4b

See more details on using hashes here.

File details

Details for the file sigma_rule_matcher-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sigma_rule_matcher-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 003f6d5482eb0790a2f0b21a4d01f59b51aebd9437cf3c12239ae1c0693a970f
MD5 a5435c8ad06ea977beea099504fef87b
BLAKE2b-256 1e6804ddad69202753070355d1d99b5e2de44eecbde36162fb4c67338c73de08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page