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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sigma_rule_matcher-0.0.2.tar.gz.
File metadata
- Download URL: sigma_rule_matcher-0.0.2.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c28678348f7f4df1c388da449d0167d799a4ebcb91914913c748334971f59886
|
|
| MD5 |
b3af6a47d30f5b931292664bde208bf0
|
|
| BLAKE2b-256 |
295492e661eab854b985ba481d8126a483ab19e251864dcddd3565fd35e319c2
|
File details
Details for the file sigma_rule_matcher-0.0.2-py3-none-any.whl.
File metadata
- Download URL: sigma_rule_matcher-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
708eded5dc6283f77f7c211a83cba66c0bc6864193258b8c093080c62b7e20d5
|
|
| MD5 |
8b979ddcd15bdfed5a1684b476bdf6d6
|
|
| BLAKE2b-256 |
8740cb00d99cdc21933c5ab0fcf77ac60188a9fa7af1015bb342a43a3b23741f
|