sigmux 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sigmux-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kyle Main
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
sigmux-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: sigmux
3
+ Version: 0.3.0
4
+ Summary: Convert Sigma detection rules into multiple SIEM query languages (Splunk SPL, Elasticsearch Query DSL, Microsoft Sentinel KQL, CrowdStrike Falcon LogScale, IBM QRadar AQL, Google Chronicle YARA-L, Sumo Logic).
5
+ Author: Kyle Main
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/kylemain/sigmux
8
+ Project-URL: Repository, https://github.com/kylemain/sigmux
9
+ Project-URL: Issues, https://github.com/kylemain/sigmux/issues
10
+ Keywords: sigma,siem,detection-engineering,splunk,elasticsearch,sentinel,kql,crowdstrike,logscale,qradar,chronicle,yara-l,sumologic,security,detectl
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Information Technology
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Security
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: PyYAML>=6.0
25
+ Requires-Dist: click>=8.0
26
+ Requires-Dist: rich>=13.0
27
+ Requires-Dist: Pygments>=2.16
28
+ Dynamic: license-file
29
+
30
+ # sigmux
31
+
32
+ [![CI](https://github.com/kylemain/sigmux/actions/workflows/ci.yml/badge.svg)](https://github.com/kylemain/sigmux/actions/workflows/ci.yml)
33
+ [![coverage](coverage.svg)](#testing)
34
+
35
+ Convert [Sigma](https://github.com/SigmaHQ/sigma) detection rules into **seven** SIEM/XDR query languages from a single command: **Splunk SPL**, **Elasticsearch Query DSL**, **Microsoft Sentinel (KQL)**, **CrowdStrike Falcon LogScale (LQL)**, **IBM QRadar (AQL)**, **Google Chronicle (YARA-L 2.0)**, and **Sumo Logic**.
36
+
37
+ This mirrors real multi-SIEM detection engineering work -- writing detection logic once and deploying it consistently across platforms instead of hand-porting query syntax every time a team adds a new SIEM. It pairs directly with [detectl](https://github.com/kylemain/detectl), which takes sigmux's output the rest of the way and actually pushes it to a live platform -- see [Pairs well with detectl](#pairs-well-with-detectl) below.
38
+
39
+ ![sigmux and detectl demo](demo.gif)
40
+
41
+ ```
42
+ $ sigmux convert examples/mimikatz_execution.yml --target splunk --target sentinel --target elastic
43
+
44
+ ╭─ Mimikatz Process Execution :: splunk (Splunk SPL) ──────────────────────────╮
45
+ │ Image=*\mimikatz.exe OR (CommandLine=*sekurlsa::* OR CommandLine=*lsadump::* │
46
+ │ OR CommandLine=*privilege::debug*) │
47
+ ╰──────────────────────────────────────────────────────────────────────────────╯
48
+ ╭─ Mimikatz Process Execution :: sentinel (Microsoft Sentinel (KQL)) ──────────╮
49
+ │ DeviceProcessEvents │
50
+ │ | where Image endswith "\mimikatz.exe" or (CommandLine has "sekurlsa::" or │
51
+ │ CommandLine has "lsadump::" or CommandLine has "privilege::debug") │
52
+ ╰──────────────────────────────────────────────────────────────────────────────╯
53
+ ╭─ Mimikatz Process Execution :: elastic (Elasticsearch Query DSL) ────────────╮
54
+ │ { "query": { "bool": { "should": [ ... ], "minimum_should_match": 1 } } } │
55
+ ╰──────────────────────────────────────────────────────────────────────────────╯
56
+ 3 conversion(s) across 1 rule(s), 0 error(s)
57
+ ```
58
+
59
+ Each target gets its own colored, syntax-highlighted panel in the terminal (JSON, SQL, and YARA-L output get real Pygments highlighting via [rich](https://github.com/Textualize/rich)); `sigmux targets` prints a table of every supported target, its query language, and its output file extension.
60
+
61
+ ## Why
62
+
63
+ Detection engineering across more than one SIEM/EDR platform means writing (and maintaining) the same detection logic in several different query languages. Sigma exists to describe detection logic once, vendor-neutrally — `sigmux` is a small, from-scratch implementation of the parts of the Sigma spec that come up constantly in real rules (field matching with `contains`/`startswith`/`endswith`/wildcards, `and`/`or`/`not`, and the `1 of x*` / `all of them` aggregate forms), plus renderers that turn that into query text you can actually paste into your platform of choice.
64
+
65
+ It's a generalized, from-scratch build — not a wrapper around an existing rule-conversion library — written to be small enough to read end to end in one sitting.
66
+
67
+ ## Install
68
+
69
+ Not published to PyPI yet -- `pyproject.toml` and `.github/workflows/publish.yml` are set up for it (PyPI Trusted Publishing, triggered on a version tag), but that needs a one-time manual step on pypi.org's side first. Until then, install from source:
70
+
71
+ ```bash
72
+ git clone https://github.com/kylemain/sigmux
73
+ cd sigmux
74
+ python3 -m venv .venv
75
+ source .venv/bin/activate
76
+ pip install -e .
77
+ ```
78
+
79
+ ## Usage
80
+
81
+ ```bash
82
+ # Convert a single rule to every supported target
83
+ sigmux convert examples/mimikatz_execution.yml
84
+
85
+ # Convert to specific target(s) only
86
+ sigmux convert examples/mimikatz_execution.yml --target splunk --target crowdstrike
87
+
88
+ # Convert every rule in a directory, writing output files instead of stdout
89
+ sigmux convert examples/ --target elastic --out out/
90
+
91
+ # List supported targets, their query language, and output extension
92
+ sigmux targets
93
+ ```
94
+
95
+ ```
96
+ sigmux conversion targets
97
+ ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
98
+ ┃ Target ┃ Query language ┃ Output ext ┃
99
+ ┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
100
+ │ chronicle │ Google Chronicle (YARA-L 2.0) │ .yaral │
101
+ │ crowdstrike │ CrowdStrike Falcon LogScale (LQL) │ .lql │
102
+ │ elastic │ Elasticsearch Query DSL │ .json │
103
+ │ qradar │ IBM QRadar (AQL) │ .aql │
104
+ │ sentinel │ Microsoft Sentinel (KQL) │ .kql │
105
+ │ splunk │ Splunk SPL │ .spl │
106
+ │ sumologic │ Sumo Logic search query │ .sumo │
107
+ └─────────────┴───────────────────────────────────┴────────────┘
108
+ ```
109
+
110
+ ## Pairs well with [detectl](https://github.com/kylemain/detectl)
111
+
112
+ sigmux's target names match detectl's platform names 1:1 on purpose (`elastic`, `crowdstrike`, `sentinel`, `splunk`, `qradar`, `sumologic`, `chronicle`) -- the conversion target and the platform you push it to are never something you have to look up a mapping for.
113
+
114
+ detectl imports sigmux as a library to collapse the two-step "convert, then paste the output into a create command" workflow into one:
115
+
116
+ ```bash
117
+ detectl -p elastic rules create-from-sigma my_rule.yml
118
+ ```
119
+
120
+ That single command parses the Sigma rule, converts it with sigmux using the exact target that matches `--platform`, and creates it as a live detection rule -- with a `--dry-run` flag that shows the full converted query and rule metadata (Terraform-plan style) before anything is actually created. This isn't just a documented pairing either: a separate `integration` CI job in detectl spins up a real Elasticsearch and runs this exact pipeline against it end to end (see detectl's `scripts/integration_test_elastic.py`), so the two projects staying compatible is something CI actually checks, not just a README claim.
121
+
122
+ ## Architecture
123
+
124
+ ```
125
+ Sigma YAML → rule.py (parse) → tiny AST → backend.render(rule) → query text
126
+ (ast_nodes.py) (backends/*.py)
127
+ ```
128
+
129
+ - **`rule.py`** parses a rule's `detection` block into per-selection AST nodes (field matches, ANDed within a selection, ORed across list values), then **`condition_parser.py`** parses the `condition:` string (`and`/`or`/`not`, parentheses, `1 of sel_*`, `all of them`, ...) into a single tree referencing those selections.
130
+ - **`ast_nodes.py`** defines the whole tree with four node types: `FieldMatch`, `And`, `Or`, `Not`.
131
+ - **`backends/`** each implement one `render(rule) -> str` method that walks the same AST and emits target-specific syntax. Adding a new SIEM target means writing one new backend file and registering it in `backends/__init__.py`'s `REGISTRY` — nothing else in the conversion pipeline changes:
132
+
133
+ ```python
134
+ class MyBackend(Backend):
135
+ name = "my_siem"
136
+
137
+ def render(self, rule: SigmaRule) -> str:
138
+ return _render(rule.ast, top=True)
139
+ ```
140
+
141
+ The CLI's `_TARGET_INFO` dict in `cli.py` adds a display label/color/syntax-highlighting lexer per target for `targets` and `convert`'s panels, but it's cosmetic only — a target missing from it still converts and writes files correctly with a plain fallback label/extension.
142
+ - **`cli.py`** wires it all together with [Click](https://click.palletsprojects.com/) for argument parsing and [rich](https://github.com/Textualize/rich) for colored tables, bordered per-target panels, and Pygments-backed syntax highlighting of the rendered query text.
143
+
144
+ ## Known limitations
145
+
146
+ This is a deliberately-scoped implementation of Sigma's *field matching and boolean logic*, not the full spec:
147
+
148
+ - Supported field modifiers: exact match (with automatic wildcard inference), `contains`, `startswith`, `endswith`, `re`. `base64`, `base64offset`, `cidr`, and field-to-field comparisons aren't supported -- rather than rejecting the whole rule, an unsupported modifier degrades to a plain exact-match on the raw field value, so the rule still converts (just not perfectly; don't rely on it decoding base64 or matching a CIDR range for you).
149
+ - Supported condition forms: `and` / `or` / `not`, parentheses, `1 of <glob>`, `all of <glob>`, `1 of them`, `all of them`. Not supported: aggregation/timeframe rules (`count() by ... > N`) and the newer multi-rule `correlation:` type.
150
+ - The Sentinel backend's logsource → table mapping, and the Chronicle backend's logsource → UDM `event_type` mapping, cover the common Sigma categories/products out of the box; anything more specific should be overridden per deployment.
151
+ - The `re` modifier's Splunk and Sumo Logic rendering is a best-effort placeholder — neither SPL nor Sumo's search syntax has an inline regex match operator, so the emitted term is flagged with a comment showing the equivalent pipe stage (`| regex` / `| where ... matches`).
152
+ - The QRadar backend emits raw Sigma field names, not real AQL property names or a QID map, and doesn't add a `LAST <n> <unit>` time-window clause — both are deployment-specific.
153
+ - The Chronicle backend emits raw Sigma field names under the event variable (`$e.Image`) rather than mapping them onto Chronicle's UDM schema (`$e.target.process.file.full_path`, ...) — that mapping is log-source-specific and out of scope here.
154
+
155
+ ## SigmaHQ compatibility
156
+
157
+ The 9 example rules in this repo prove the mechanics work; they don't prove much about coverage. `scripts/benchmark_sigmahq.py` runs every rule in the real, actively-maintained [SigmaHQ/sigma](https://github.com/SigmaHQ/sigma) `rules/` corpus (rules this project doesn't own or control) through every sigmux backend and reports how many convert cleanly:
158
+
159
+ ```bash
160
+ python scripts/benchmark_sigmahq.py
161
+ ```
162
+
163
+ As of this writing, against the current `rules/` corpus:
164
+
165
+ ```
166
+ 3141/3141 rules converted cleanly to all 7 targets (100.0%)
167
+ ```
168
+
169
+ Read that number for what it actually measures, not more: it means every rule parsed and every backend rendered *something* without raising -- it doesn't mean every rendered query is semantically perfect. 28 of those 3,141 rules use `base64`/`cidr` modifiers, which (per Known limitations above) sigmux intentionally degrades to a plain exact-match rather than rejecting; this snapshot of the corpus also happens to contain zero aggregation/`correlation:` rules, which remain genuinely unsupported and would fail if present. This job runs weekly in CI (informational only, not a merge gate, since it depends on an external repo's content) -- see the `sigmahq-benchmark` job in `.github/workflows/ci.yml`.
170
+
171
+ ## Testing
172
+
173
+ ```bash
174
+ python -m unittest discover -v
175
+ ```
176
+
177
+ 36 tests covering field-modifier parsing, the condition-language parser, all seven backends, and the CLI.
178
+
179
+ ## License
180
+
181
+ MIT — see [LICENSE](LICENSE).
sigmux-0.3.0/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # sigmux
2
+
3
+ [![CI](https://github.com/kylemain/sigmux/actions/workflows/ci.yml/badge.svg)](https://github.com/kylemain/sigmux/actions/workflows/ci.yml)
4
+ [![coverage](coverage.svg)](#testing)
5
+
6
+ Convert [Sigma](https://github.com/SigmaHQ/sigma) detection rules into **seven** SIEM/XDR query languages from a single command: **Splunk SPL**, **Elasticsearch Query DSL**, **Microsoft Sentinel (KQL)**, **CrowdStrike Falcon LogScale (LQL)**, **IBM QRadar (AQL)**, **Google Chronicle (YARA-L 2.0)**, and **Sumo Logic**.
7
+
8
+ This mirrors real multi-SIEM detection engineering work -- writing detection logic once and deploying it consistently across platforms instead of hand-porting query syntax every time a team adds a new SIEM. It pairs directly with [detectl](https://github.com/kylemain/detectl), which takes sigmux's output the rest of the way and actually pushes it to a live platform -- see [Pairs well with detectl](#pairs-well-with-detectl) below.
9
+
10
+ ![sigmux and detectl demo](demo.gif)
11
+
12
+ ```
13
+ $ sigmux convert examples/mimikatz_execution.yml --target splunk --target sentinel --target elastic
14
+
15
+ ╭─ Mimikatz Process Execution :: splunk (Splunk SPL) ──────────────────────────╮
16
+ │ Image=*\mimikatz.exe OR (CommandLine=*sekurlsa::* OR CommandLine=*lsadump::* │
17
+ │ OR CommandLine=*privilege::debug*) │
18
+ ╰──────────────────────────────────────────────────────────────────────────────╯
19
+ ╭─ Mimikatz Process Execution :: sentinel (Microsoft Sentinel (KQL)) ──────────╮
20
+ │ DeviceProcessEvents │
21
+ │ | where Image endswith "\mimikatz.exe" or (CommandLine has "sekurlsa::" or │
22
+ │ CommandLine has "lsadump::" or CommandLine has "privilege::debug") │
23
+ ╰──────────────────────────────────────────────────────────────────────────────╯
24
+ ╭─ Mimikatz Process Execution :: elastic (Elasticsearch Query DSL) ────────────╮
25
+ │ { "query": { "bool": { "should": [ ... ], "minimum_should_match": 1 } } } │
26
+ ╰──────────────────────────────────────────────────────────────────────────────╯
27
+ 3 conversion(s) across 1 rule(s), 0 error(s)
28
+ ```
29
+
30
+ Each target gets its own colored, syntax-highlighted panel in the terminal (JSON, SQL, and YARA-L output get real Pygments highlighting via [rich](https://github.com/Textualize/rich)); `sigmux targets` prints a table of every supported target, its query language, and its output file extension.
31
+
32
+ ## Why
33
+
34
+ Detection engineering across more than one SIEM/EDR platform means writing (and maintaining) the same detection logic in several different query languages. Sigma exists to describe detection logic once, vendor-neutrally — `sigmux` is a small, from-scratch implementation of the parts of the Sigma spec that come up constantly in real rules (field matching with `contains`/`startswith`/`endswith`/wildcards, `and`/`or`/`not`, and the `1 of x*` / `all of them` aggregate forms), plus renderers that turn that into query text you can actually paste into your platform of choice.
35
+
36
+ It's a generalized, from-scratch build — not a wrapper around an existing rule-conversion library — written to be small enough to read end to end in one sitting.
37
+
38
+ ## Install
39
+
40
+ Not published to PyPI yet -- `pyproject.toml` and `.github/workflows/publish.yml` are set up for it (PyPI Trusted Publishing, triggered on a version tag), but that needs a one-time manual step on pypi.org's side first. Until then, install from source:
41
+
42
+ ```bash
43
+ git clone https://github.com/kylemain/sigmux
44
+ cd sigmux
45
+ python3 -m venv .venv
46
+ source .venv/bin/activate
47
+ pip install -e .
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ ```bash
53
+ # Convert a single rule to every supported target
54
+ sigmux convert examples/mimikatz_execution.yml
55
+
56
+ # Convert to specific target(s) only
57
+ sigmux convert examples/mimikatz_execution.yml --target splunk --target crowdstrike
58
+
59
+ # Convert every rule in a directory, writing output files instead of stdout
60
+ sigmux convert examples/ --target elastic --out out/
61
+
62
+ # List supported targets, their query language, and output extension
63
+ sigmux targets
64
+ ```
65
+
66
+ ```
67
+ sigmux conversion targets
68
+ ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
69
+ ┃ Target ┃ Query language ┃ Output ext ┃
70
+ ┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
71
+ │ chronicle │ Google Chronicle (YARA-L 2.0) │ .yaral │
72
+ │ crowdstrike │ CrowdStrike Falcon LogScale (LQL) │ .lql │
73
+ │ elastic │ Elasticsearch Query DSL │ .json │
74
+ │ qradar │ IBM QRadar (AQL) │ .aql │
75
+ │ sentinel │ Microsoft Sentinel (KQL) │ .kql │
76
+ │ splunk │ Splunk SPL │ .spl │
77
+ │ sumologic │ Sumo Logic search query │ .sumo │
78
+ └─────────────┴───────────────────────────────────┴────────────┘
79
+ ```
80
+
81
+ ## Pairs well with [detectl](https://github.com/kylemain/detectl)
82
+
83
+ sigmux's target names match detectl's platform names 1:1 on purpose (`elastic`, `crowdstrike`, `sentinel`, `splunk`, `qradar`, `sumologic`, `chronicle`) -- the conversion target and the platform you push it to are never something you have to look up a mapping for.
84
+
85
+ detectl imports sigmux as a library to collapse the two-step "convert, then paste the output into a create command" workflow into one:
86
+
87
+ ```bash
88
+ detectl -p elastic rules create-from-sigma my_rule.yml
89
+ ```
90
+
91
+ That single command parses the Sigma rule, converts it with sigmux using the exact target that matches `--platform`, and creates it as a live detection rule -- with a `--dry-run` flag that shows the full converted query and rule metadata (Terraform-plan style) before anything is actually created. This isn't just a documented pairing either: a separate `integration` CI job in detectl spins up a real Elasticsearch and runs this exact pipeline against it end to end (see detectl's `scripts/integration_test_elastic.py`), so the two projects staying compatible is something CI actually checks, not just a README claim.
92
+
93
+ ## Architecture
94
+
95
+ ```
96
+ Sigma YAML → rule.py (parse) → tiny AST → backend.render(rule) → query text
97
+ (ast_nodes.py) (backends/*.py)
98
+ ```
99
+
100
+ - **`rule.py`** parses a rule's `detection` block into per-selection AST nodes (field matches, ANDed within a selection, ORed across list values), then **`condition_parser.py`** parses the `condition:` string (`and`/`or`/`not`, parentheses, `1 of sel_*`, `all of them`, ...) into a single tree referencing those selections.
101
+ - **`ast_nodes.py`** defines the whole tree with four node types: `FieldMatch`, `And`, `Or`, `Not`.
102
+ - **`backends/`** each implement one `render(rule) -> str` method that walks the same AST and emits target-specific syntax. Adding a new SIEM target means writing one new backend file and registering it in `backends/__init__.py`'s `REGISTRY` — nothing else in the conversion pipeline changes:
103
+
104
+ ```python
105
+ class MyBackend(Backend):
106
+ name = "my_siem"
107
+
108
+ def render(self, rule: SigmaRule) -> str:
109
+ return _render(rule.ast, top=True)
110
+ ```
111
+
112
+ The CLI's `_TARGET_INFO` dict in `cli.py` adds a display label/color/syntax-highlighting lexer per target for `targets` and `convert`'s panels, but it's cosmetic only — a target missing from it still converts and writes files correctly with a plain fallback label/extension.
113
+ - **`cli.py`** wires it all together with [Click](https://click.palletsprojects.com/) for argument parsing and [rich](https://github.com/Textualize/rich) for colored tables, bordered per-target panels, and Pygments-backed syntax highlighting of the rendered query text.
114
+
115
+ ## Known limitations
116
+
117
+ This is a deliberately-scoped implementation of Sigma's *field matching and boolean logic*, not the full spec:
118
+
119
+ - Supported field modifiers: exact match (with automatic wildcard inference), `contains`, `startswith`, `endswith`, `re`. `base64`, `base64offset`, `cidr`, and field-to-field comparisons aren't supported -- rather than rejecting the whole rule, an unsupported modifier degrades to a plain exact-match on the raw field value, so the rule still converts (just not perfectly; don't rely on it decoding base64 or matching a CIDR range for you).
120
+ - Supported condition forms: `and` / `or` / `not`, parentheses, `1 of <glob>`, `all of <glob>`, `1 of them`, `all of them`. Not supported: aggregation/timeframe rules (`count() by ... > N`) and the newer multi-rule `correlation:` type.
121
+ - The Sentinel backend's logsource → table mapping, and the Chronicle backend's logsource → UDM `event_type` mapping, cover the common Sigma categories/products out of the box; anything more specific should be overridden per deployment.
122
+ - The `re` modifier's Splunk and Sumo Logic rendering is a best-effort placeholder — neither SPL nor Sumo's search syntax has an inline regex match operator, so the emitted term is flagged with a comment showing the equivalent pipe stage (`| regex` / `| where ... matches`).
123
+ - The QRadar backend emits raw Sigma field names, not real AQL property names or a QID map, and doesn't add a `LAST <n> <unit>` time-window clause — both are deployment-specific.
124
+ - The Chronicle backend emits raw Sigma field names under the event variable (`$e.Image`) rather than mapping them onto Chronicle's UDM schema (`$e.target.process.file.full_path`, ...) — that mapping is log-source-specific and out of scope here.
125
+
126
+ ## SigmaHQ compatibility
127
+
128
+ The 9 example rules in this repo prove the mechanics work; they don't prove much about coverage. `scripts/benchmark_sigmahq.py` runs every rule in the real, actively-maintained [SigmaHQ/sigma](https://github.com/SigmaHQ/sigma) `rules/` corpus (rules this project doesn't own or control) through every sigmux backend and reports how many convert cleanly:
129
+
130
+ ```bash
131
+ python scripts/benchmark_sigmahq.py
132
+ ```
133
+
134
+ As of this writing, against the current `rules/` corpus:
135
+
136
+ ```
137
+ 3141/3141 rules converted cleanly to all 7 targets (100.0%)
138
+ ```
139
+
140
+ Read that number for what it actually measures, not more: it means every rule parsed and every backend rendered *something* without raising -- it doesn't mean every rendered query is semantically perfect. 28 of those 3,141 rules use `base64`/`cidr` modifiers, which (per Known limitations above) sigmux intentionally degrades to a plain exact-match rather than rejecting; this snapshot of the corpus also happens to contain zero aggregation/`correlation:` rules, which remain genuinely unsupported and would fail if present. This job runs weekly in CI (informational only, not a merge gate, since it depends on an external repo's content) -- see the `sigmahq-benchmark` job in `.github/workflows/ci.yml`.
141
+
142
+ ## Testing
143
+
144
+ ```bash
145
+ python -m unittest discover -v
146
+ ```
147
+
148
+ 36 tests covering field-modifier parsing, the condition-language parser, all seven backends, and the CLI.
149
+
150
+ ## License
151
+
152
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sigmux"
7
+ version = "0.3.0"
8
+ description = "Convert Sigma detection rules into multiple SIEM query languages (Splunk SPL, Elasticsearch Query DSL, Microsoft Sentinel KQL, CrowdStrike Falcon LogScale, IBM QRadar AQL, Google Chronicle YARA-L, Sumo Logic)."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = {text = "MIT"}
12
+ authors = [{name = "Kyle Main"}]
13
+ keywords = ["sigma", "siem", "detection-engineering", "splunk", "elasticsearch", "sentinel", "kql", "crowdstrike", "logscale", "qradar", "chronicle", "yara-l", "sumologic", "security", "detectl"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Information Technology",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Security",
25
+ ]
26
+ dependencies = [
27
+ "PyYAML>=6.0",
28
+ "click>=8.0",
29
+ "rich>=13.0",
30
+ "Pygments>=2.16",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/kylemain/sigmux"
35
+ Repository = "https://github.com/kylemain/sigmux"
36
+ Issues = "https://github.com/kylemain/sigmux/issues"
37
+
38
+ [project.scripts]
39
+ sigmux = "sigmux.cli:main"
40
+
41
+ [tool.setuptools.packages.find]
42
+ include = ["sigmux*"]
sigmux-0.3.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """sigmux — convert Sigma detection rules into multiple SIEM query languages."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,36 @@
1
+ """AST node types for a parsed Sigma detection condition.
2
+
3
+ The tree is intentionally tiny: everything Sigma's detection language can
4
+ express reduces to four shapes once selections have been resolved into
5
+ their component field matches.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass, field
10
+ from typing import List
11
+
12
+
13
+ class Node:
14
+ """Base class for all AST nodes."""
15
+
16
+
17
+ @dataclass
18
+ class FieldMatch(Node):
19
+ field: str
20
+ modifier: str # one of: eq, contains, startswith, endswith, re
21
+ value: str
22
+
23
+
24
+ @dataclass
25
+ class And(Node):
26
+ children: List[Node] = field(default_factory=list)
27
+
28
+
29
+ @dataclass
30
+ class Or(Node):
31
+ children: List[Node] = field(default_factory=list)
32
+
33
+
34
+ @dataclass
35
+ class Not(Node):
36
+ child: Node
@@ -0,0 +1,38 @@
1
+ """Backend registry: maps a target name to its converter implementation.
2
+
3
+ Target names match detectl's platform names 1:1 (elastic, crowdstrike,
4
+ sentinel, splunk, qradar, sumologic, chronicle) -- deliberately, so a
5
+ sigmux target and the detectl platform you'd push its output to are always
6
+ the same name. See "Pairs well with detectl" in the README.
7
+ """
8
+ from .base import Backend
9
+ from .chronicle import ChronicleBackend
10
+ from .crowdstrike import CrowdStrikeBackend
11
+ from .elastic import ElasticBackend
12
+ from .qradar import QRadarBackend
13
+ from .sentinel import SentinelBackend
14
+ from .splunk import SplunkBackend
15
+ from .sumologic import SumoLogicBackend
16
+
17
+ REGISTRY = {
18
+ "splunk": SplunkBackend(),
19
+ "elastic": ElasticBackend(),
20
+ "sentinel": SentinelBackend(),
21
+ "crowdstrike": CrowdStrikeBackend(),
22
+ "qradar": QRadarBackend(),
23
+ "chronicle": ChronicleBackend(),
24
+ "sumologic": SumoLogicBackend(),
25
+ }
26
+
27
+
28
+ def get_backend(name: str) -> Backend:
29
+ try:
30
+ return REGISTRY[name]
31
+ except KeyError as exc:
32
+ available = ", ".join(sorted(REGISTRY))
33
+ raise ValueError(
34
+ f"Unknown target '{name}'. Available targets: {available}"
35
+ ) from exc
36
+
37
+
38
+ __all__ = ["Backend", "REGISTRY", "get_backend"]
@@ -0,0 +1,18 @@
1
+ """Shared interface for query-language backends."""
2
+ from __future__ import annotations
3
+
4
+ from abc import ABC, abstractmethod
5
+ from typing import TYPE_CHECKING
6
+
7
+ if TYPE_CHECKING:
8
+ from ..rule import SigmaRule
9
+
10
+
11
+ class Backend(ABC):
12
+ """Turns a parsed Sigma rule's AST into a target query string."""
13
+
14
+ name: str
15
+
16
+ @abstractmethod
17
+ def render(self, rule: "SigmaRule") -> str:
18
+ ...
@@ -0,0 +1,110 @@
1
+ """Google Security Operations (Chronicle) YARA-L 2.0 backend.
2
+
3
+ Unlike the other backends, this doesn't render a bare query expression --
4
+ YARA-L rules are a small structured language of their own (`meta` /
5
+ `events` / `condition` blocks), so this backend builds the whole rule
6
+ skeleton around the same field-match/boolean AST every other backend walks.
7
+
8
+ Two things are deliberately best-effort, in the same spirit as the Sentinel
9
+ backend's logsource->table map:
10
+ - `metadata.event_type` is guessed from the Sigma logsource the same way
11
+ Sentinel guesses its table, defaulting to `GENERIC_EVENT`.
12
+ - Field names are emitted as the raw Sigma field name under the event
13
+ variable (`$e.Image`, ...) rather than mapped onto Chronicle's real UDM
14
+ schema (`$e.target.process.file.full_path`, ...) -- that mapping is
15
+ product/log-source-specific and out of scope here.
16
+ """
17
+ from __future__ import annotations
18
+
19
+ import re as _re
20
+ from typing import TYPE_CHECKING, Dict, Optional, Tuple
21
+
22
+ from ..ast_nodes import And, FieldMatch, Node, Not, Or
23
+ from .base import Backend
24
+
25
+ if TYPE_CHECKING:
26
+ from ..rule import SigmaRule
27
+
28
+ _EVENT_TYPE_MAP: Dict[Tuple[Optional[str], Optional[str]], str] = {
29
+ ("process_creation", None): "PROCESS_LAUNCH",
30
+ ("network_connection", None): "NETWORK_CONNECTION",
31
+ ("file_event", None): "FILE_CREATION",
32
+ ("file_change", None): "FILE_MODIFICATION",
33
+ ("registry_event", None): "REGISTRY_MODIFICATION",
34
+ ("registry_add", None): "REGISTRY_CREATION",
35
+ }
36
+ _DEFAULT_EVENT_TYPE = "GENERIC_EVENT"
37
+
38
+
39
+ def _event_type_for(logsource: Dict[str, str]) -> str:
40
+ category = logsource.get("category")
41
+ return _EVENT_TYPE_MAP.get((category, None), _DEFAULT_EVENT_TYPE)
42
+
43
+
44
+ def _quote(value: str) -> str:
45
+ return '"' + value.replace("\\", "\\\\").replace('"', '\\"') + '"'
46
+
47
+
48
+ def _rule_name(title: str) -> str:
49
+ name = _re.sub(r"[^A-Za-z0-9_]", "_", title).strip("_")
50
+ if not name:
51
+ name = "sigma_rule"
52
+ if name[0].isdigit():
53
+ name = f"rule_{name}"
54
+ return name
55
+
56
+
57
+ def _match(fm: FieldMatch) -> str:
58
+ if fm.modifier == "eq":
59
+ return f"$e.{fm.field} = {_quote(fm.value)}"
60
+ if fm.modifier == "contains":
61
+ return f"$e.{fm.field} contains {_quote(fm.value)}"
62
+ if fm.modifier == "startswith":
63
+ return f're.regex($e.{fm.field}, {_quote("^" + _re.escape(fm.value))})'
64
+ if fm.modifier == "endswith":
65
+ return f're.regex($e.{fm.field}, {_quote(_re.escape(fm.value) + "$")})'
66
+ if fm.modifier == "re":
67
+ return f"re.regex($e.{fm.field}, {_quote(fm.value)})"
68
+ raise ValueError(f"Unsupported modifier: {fm.modifier}")
69
+
70
+
71
+ def _render(node: Node, top: bool = False) -> str:
72
+ if isinstance(node, FieldMatch):
73
+ return _match(node)
74
+ if isinstance(node, And):
75
+ joined = " and ".join(_render(c) for c in node.children)
76
+ return joined if top else f"({joined})"
77
+ if isinstance(node, Or):
78
+ joined = " or ".join(_render(c) for c in node.children)
79
+ return joined if top else f"({joined})"
80
+ if isinstance(node, Not):
81
+ return f"not ({_render(node.child, top=True)})"
82
+ raise TypeError(f"Unknown node type: {type(node)!r}")
83
+
84
+
85
+ class ChronicleBackend(Backend):
86
+ name = "chronicle"
87
+
88
+ def render(self, rule: "SigmaRule") -> str:
89
+ event_type = _event_type_for(rule.logsource)
90
+ expr = _render(rule.ast, top=True)
91
+
92
+ meta_lines = ['author = "sigmux"']
93
+ if rule.description:
94
+ meta_lines.append(f"description = {_quote(rule.description)}")
95
+ if rule.level:
96
+ meta_lines.append(f'severity = "{rule.level.upper()}"')
97
+ if rule.id:
98
+ meta_lines.append(f'reference = "{rule.id}"')
99
+ meta_block = "\n".join(f" {line}" for line in meta_lines)
100
+
101
+ return (
102
+ f"rule {_rule_name(rule.title)} {{\n"
103
+ f" meta:\n{meta_block}\n\n"
104
+ f" events:\n"
105
+ f' $e.metadata.event_type = "{event_type}"\n'
106
+ f" {expr}\n\n"
107
+ f" condition:\n"
108
+ f" $e\n"
109
+ f"}}"
110
+ )