Skip to content

Rule Conversion and Field Mapping

github-actions[bot] edited this page Nov 29, 2026 · 1 revision

Last reviewed: 2026-11-28 (commands below run offline with sigma-cli 4.0.1 and pySigma 2.1.2; no SIEM executed the output)

Prerequisites: Detection Engineering index ยท Rule lifecycle ยท Detection content validation.

๐ŸŽฏ Purpose

Sigma rules are converted into a SIEM query by a pySigma backend, and processing pipelines rename fields and add log-source conditions on the way. Most conversion bugs are field-mapping bugs that convert cleanly and then never match. This guide covers choosing backends and pipelines, the pitfalls, and how to check a converted query.

โš™๏ธ Function

Lists the pinned toolchain, shows how pipelines change output, demonstrates a custom mapping pipeline and a strict-mapping guard, and gives a verification checklist for converted queries.

๐Ÿ† Goal

Every converted query is pinned to a toolchain version, compared with a golden output, and checked against the field names the target actually ingests.

๐Ÿ“‹ When To Use

  • Converting a SigmaHQ or in-house rule for a SIEM.
  • Upgrading sigma-cli, pySigma, a backend or a pipeline.
  • A rule that passes sigma check but never fires.

๐Ÿงฐ Pinned Toolchain

Package Version Notes
sigma-cli 4.0.1 Requires Python >=3.11,<4.0 and pySigma >=2.0.0,<3.0.0
pySigma 2.1.2
pysigma-backend-splunk 3.0.1 Targets splunk and splunk_spl2; both require a processing pipeline
pysigma-pipeline-sysmon 3.0.0 Pipeline sysmon
pysigma-pipeline-windows 3.0.0 Pipelines windows-logsources and windows-audit

sigma list pipelines with this set also lists splunk_windows, splunk_sysmon_acceleration and splunk_cim from the Splunk backend. pySigma-backend-elasticsearch 2.1.1 requires pySigma <2.0.0, so it cannot be installed alongside this set. Install with exact pins, as in the lab's requirements-lab.txt, rather than sigma plugin install, which fetches a plugin directory from GitHub and calls pip install at run time.

๐Ÿ”€ How Pipelines Change The Output

The lab rule proc_creation_win_pnwc_lab_canary.yml checks Image|endswith and CommandLine|contains. These outputs were observed:

sigma convert -t splunk -p sysmon -p splunk_windows proc_creation_win_pnwc_lab_canary.yml
# source="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 Image="*\\pnwc-lab-canary.exe" CommandLine="*PNWC-LAB-CANARY-7F3A*"

sigma convert -t splunk proc_creation_win_pnwc_lab_canary.yml
# exit 2: "Processing pipeline required by backend!"

The sysmon pipeline adds the source and EventCode=1. Without a pipeline the Splunk backend refuses to convert. --without-pipeline overrides that refusal: the output was Image="*\\pnwc-lab-canary.exe" CommandLine="*PNWC-LAB-CANARY-7F3A*", with no source or EventCode condition and the Sigma field names unchanged.

๐Ÿ—บ๏ธ Custom Field Mapping

When the SIEM uses a different schema, map fields in a pipeline file. Transformation type names come from sigma/processing/transformations/__init__.py in pySigma 2.1.2.

name: Lab field mapping example (strict)
priority: 30
transformations:
  - id: lab_process_fields
    type: field_name_mapping
    mapping:
      Image: process.executable
      CommandLine: process.command_line
  - id: lab_unmapped_fields_fail
    type: strict_field_mapping_failure
sigma convert -t splunk -p lab_field_mapping_strict.yml proc_creation_win_pnwc_lab_canary.yml
# process.executable="*\\pnwc-lab-canary.exe" process.command_line="*PNWC-LAB-CANARY-7F3A*"

The strict_field_mapping_failure step makes conversion fail on any field the pipeline did not map. With a rule whose CommandLine was misspelled ComandLine, the strict pipeline exited 1 with The following fields are not mapped: ComandLine.

โš ๏ธ Field-Mapping Pitfalls

Pitfall What happened offline Guard
Misspelled or unknown field With -p sysmon -p splunk_windows, the ComandLine typo converted with exit 0 to ComandLine="*PNWC-LAB-CANARY-7F3A*". sigma check --fail-on-issues also passed it Strict mapping step; golden-output comparison; check the field exists in ingested events
Missing pipeline Splunk backend exits 2 Always pass -p; do not use --without-pipeline for production output
Pipeline order and priority The pySigma resolver applies pipelines lowest priority first (sysmon 5, windows-logsources and windows-audit 10, splunk_windows and splunk_cim 20, splunk_sysmon_acceleration 25) Pin the exact -p list in the golden test
Vendor schema versus ingested data The pipeline assumes source="WinEventLog:Microsoft-Windows-Sysmon/Operational"; your index or source name may differ Confirm with a real event from the target before deploying
Sigma field naming The Sigma specification says to use the mapped name where a mapping exists, and otherwise the field as it appears in the log source with spaces removed Review new fields against the spec's Field Usage rules
Meta filter semantics A filter's condition is added to the rule as written (see below) Inspect the converted output after applying any filter

The Sigma field rules are in the Sigma rules specification 2.1.0. This guide does not cover converting Sigma to Wazuh XML; Wazuh rules in this repository are written natively and tested through logtest.

Meta Filters

sigma convert --filter <file> applies a Sigma meta filter to the rules named in its filter.rules list. With pySigma 2.1.2, the filter's condition was appended to the rule as written:

sigma convert -t splunk -p sysmon -p splunk_windows --filter mf_lab_canary_service_account.yml proc_creation_win_pnwc_lab_canary.yml
# condition: not selection  โ†’  ... CommandLine="*PNWC-LAB-CANARY-7F3A*" NOT User="LAB\\svc_canary*"
# condition: selection      โ†’  ... CommandLine="*PNWC-LAB-CANARY-7F3A*" User="LAB\\svc_canary*"

The specification's example filter uses condition: selection for an exclusion. With this toolchain that narrows the rule to only the "excluded" events instead of removing them, so write not selection and check the output. The specification recommends the mf_ filename prefix. Filter files were written for this test only; none is committed.

๐Ÿ” Verifying A Converted Query

  1. Run sigma check --fail-on-issues on the rule. The default sigma check exits 0 even with validation issues.
  2. Convert with the exact pinned packages and -p list, and compare the output byte for byte with a committed golden string, as the lab's sigma-convert-splunk fixture does.
  3. Add a strict field-mapping step, or grep the output for every field and confirm each one exists in ingested events from the target.
  4. Run the query in a non-production SIEM against a positive and a near-miss negative event. The canary lab does not do this step, so its Sigma evidence stops at conversion.
  5. On any toolchain upgrade, re-run the golden comparison and treat a changed query as a rule change that needs review.

See also

Related Files


โฌ…๏ธ Detection Engineering index | Master Index | ๐ŸŽฏ Role Navigation | Legal Notice


๐Ÿ“„ Source: IncidentResponse/DetectionEngineering/rule-conversion-and-field-mapping.md | โœ๏ธ Suggest an edit | โฌ…๏ธ Back to Incident Response

Clone this wiki locally