Framework-free audit rules engine and enforcement policies
Project description
sec-audit-rules
Framework-free audit rules engine, enforcement policies, and SIEM integrations
for the sec-audit core.
This package is Django-free and shares the sec_audit namespace with its sibling
distributions.
Features
- Rules — pure, read-only detectors that evaluate an event and optionally return a
RuleMatch. All state (counters, history, clock, config) is injected viaRuleContext, so rules have no side effects. - Engine — filters events by type, isolates rule exceptions, and enforces safety flags
(
safe_for_enforcement) for pre-request blocking. - Enforcement — policies that turn matches into alert/block decisions with persistent block scopes.
- Integrations — Wazuh XML/YAML detection rules ship as package data (no runtime Wazuh import required).
Install
pip install sec-audit-rules
# with the Wazuh HTTP client extra:
pip install "sec-audit-rules[wazuh]"
Writing a rule
from sec_audit.rules import Rule, RuleMatch
class TooManyFailedLogins(Rule):
name = 'too_many_failed_logins'
event_types = {'auth.login.failed'}
severity = 8
safe_for_enforcement = True
def evaluate(self, event, ctx):
srcip = str(event.fields.get('srcip') or '')
count = ctx.counters.incr(f'login_fail:{srcip}', ttl=300)
if count < 5:
return None
return RuleMatch(
self.name, self.severity, ctx.now,
f'Too many failed logins from {srcip}',
metadata={'count': count, 'srcip': srcip},
)
Rules are pure detectors — no logging, DB writes, or external calls; RuleMatch.metadata
is immutable after creation.
License
MIT
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 sec_audit_rules-0.1.0a2.tar.gz.
File metadata
- Download URL: sec_audit_rules-0.1.0a2.tar.gz
- Upload date:
- Size: 33.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d38dc4de4b1588f49ded97081ca629f97a0f8d6c7baa36587d83634220c800e2
|
|
| MD5 |
8fe4028d09ed3512dc8f5a5ff0e92ebc
|
|
| BLAKE2b-256 |
487b8049efefd402d604d7e4f86b0c623b1b9f2f1f364394b9fb164bdc740c44
|
File details
Details for the file sec_audit_rules-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: sec_audit_rules-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ff5d4c5a8b03310d633850de8906d3ead4fcae510942174d0a9772838ad02e7
|
|
| MD5 |
a0c6f9062c45e6fc99bf3c755cda43d6
|
|
| BLAKE2b-256 |
d0b301a0b6d7158e8c6d3ffd853412f1a69c751444a7131950a52f2d7041a272
|