Detection Engineering
Updated 14 min read

SIEM Detection Library Version Control: Detection as Code at Scale

72%
SOCs with no rule version control
18mo
Median age of stale rules
Faster rule rollback with GitOps
85%
Sigma coverage of ATT&CK techniques

SponsoredRetool

Retool's new app builder is where AI-generated code ships safely

Building apps with AI is easy. Getting them to production safely is another story.

Start building for free today

Most enterprise SIEM detection libraries are managed the same way they were in 2010: an engineer logs into the console, writes a query, clicks save, and moves on. There is no peer review, no test data, no deployment record, and frequently no documentation explaining what the rule is supposed to catch. Over five years the library accumulates hundreds of rules of unknown provenance and questionable quality. When a senior detection engineer leaves, institutional knowledge about half the library leaves with them.

Detection as code treats SIEM rules the way modern engineering treats application code: stored in Git, peer reviewed via pull requests, validated by CI, deployed by automation, and measured against explicit quality metrics. The reference implementation centers on Sigma as a vendor-neutral detection format, pySigma as the conversion layer to your specific SIEM, and a CI pipeline that enforces syntax, test coverage, and performance constraints before a rule reaches production.

This guide walks the entire lifecycle: repository structure, Sigma rule anatomy, CI quality gates, lifecycle states from draft to retired, ATT&CK coverage reporting, and how detection as code transforms schema drift from an invisible failure into a reviewable pull request.

Why Console-Driven Rule Management Fails

The pathologies of ad-hoc SIEM rule management compound silently. Rules created directly in the console have no commit history, so when a rule starts misfiring at 3 a.m. nobody can identify what changed or who changed it. There is no diff between the version that worked yesterday and the version that doesn't work today. Duplicate rules proliferate because there is no searchable index: the same brute-force detection ends up implemented three times by three engineers with slight variations in threshold. Rules that have not fired in eighteen months sit in production because deleting them is risky and nobody owns the decision. False positive tuning happens in place, with no record of why a particular IP range was excluded or who approved the exception. Performance degrades as expensive queries accumulate because nobody profiled them before deployment. The SOC manager has no way to answer the simple question 'what is our detection coverage for credential access on Windows endpoints?' because there is no machine-readable mapping from rules to ATT&CK techniques. Each of these problems is solvable individually with discipline, but collectively they require a system, and that system is detection as code.

Sigma as the Lingua Franca

Sigma is a YAML-based detection format designed to be portable across SIEMs. A Sigma rule has a defined anatomy: title, id (UUID), status (experimental, test, stable, deprecated), description, references, author, date, modified, tags (commonly MITRE ATT&CK technique IDs), logsource (product, service, category), detection (selection criteria and condition logic), falsepositives (documented known FP sources), and level (informational through critical). The detection block uses selection blocks and a condition expression that combines them with boolean logic and aggregation functions. pySigma is the conversion library that translates Sigma rules into the query language of your specific platform: Splunk SPL, Microsoft Sentinel KQL, Elastic ES Query DSL, CrowdStrike LogScale, Sumo Logic, Chronicle YARA-L, and others. The SigmaHQ repository contains roughly three thousand community-maintained rules covering most ATT&CK techniques, providing a substantial starting library. SOC Prime extends this with curated and commercial content. Writing in Sigma rather than native query language preserves portability when you change SIEM vendors and forces the engineer to think in terms of log sources and selection logic rather than vendor-specific syntax tricks.

Free daily briefing

Briefings like this, every morning before 9am.

Threat intel, active CVEs, and campaign alerts, distilled for practitioners. 50,000+ subscribers. No noise.

Repository Structure and Rule Lifecycle

A working detection-as-code repository typically splits rules by source platform under directories like rules/windows, rules/linux, rules/cloud/aws, rules/network, and rules/application. Each rule has a sibling tests directory containing at least one true-positive log sample and at least one documented false-positive scenario. A separate directory holds custom field mappings, log source schemas, and conversion overrides for your environment. Lifecycle state is tracked via the Sigma status field combined with branch and tag conventions: a new rule starts on a feature branch with status experimental, moves to test when merged to a staging branch and deployed to a non-production SIEM workspace, moves to stable when promoted to production after a defined soak period, and moves to deprecated when scheduled for retirement. The retire-don't-delete principle keeps deprecated rules in the repository with a tombstone tag, preventing accidental recreation and preserving the historical context for incident investigations that reference old alerts. Promotion to stable requires a CODEOWNERS approval from a senior detection engineer, and only the CI deployment service account has write access to the production SIEM API.

CI Quality Gates That Actually Catch Problems

The CI pipeline is where detection as code earns its keep. Stage one runs sigma-cli or the equivalent linter to validate YAML syntax and Sigma schema conformance. Stage two converts every changed rule via pySigma to the target SIEM dialect, catching conversion failures and unsupported constructs early. Stage three runs the rule against the bundled true-positive log samples, asserting that the rule fires; this requires a small test harness, often built on the SIEM vendor's local engine or a Sigma evaluation library. Stage four runs the rule against the documented false-positive samples and against a corpus of benign baseline logs, asserting that the rule does not fire on known-good activity. Stage five estimates query cost: for Splunk this means dispatching against a small index and capturing scan_count and run_duration; for Sentinel it means a getschema query plus a small-window execution; rules above a threshold trigger mandatory performance review. Stage six validates that every rule has at least one ATT&CK technique tag in the tags field and that the technique exists in the current ATT&CK matrix. Stage seven enforces documentation: description must exceed 50 characters and falsepositives must not be empty. Pull requests that fail any gate are blocked from merge.

ATT&CK Coverage Reporting as a Product

Once every rule is tagged with the ATT&CK techniques it detects, coverage reporting becomes a query rather than a project. A nightly job parses every Sigma file, extracts tags, and produces a coverage matrix joined against the ATT&CK STIX bundle. The output is a heatmap published to a Confluence page or internal dashboard showing every technique colored by detection count and rule maturity. Techniques with zero rules become the prioritized backlog for the detection engineering team. Techniques with only experimental rules become candidates for promotion testing. The same data feeds a monthly report to the CISO showing trend over time: techniques covered, rules promoted to stable, rules retired, mean time from threat intel to deployed detection. This visibility transforms the detection team from a reactive ticket-driven function into a measurable product team with a published roadmap. It also makes capability claims defensible during board reporting and during sales-engineering conversations with customers in regulated industries who ask 'what is your detection coverage for ransomware techniques?'

Handling Schema Drift and Vendor Updates

Log source schemas change. Windows Security event field names occasionally shift between OS versions. Microsoft 365 unified audit log renames properties roughly once per quarter. AWS CloudTrail introduces new event names as services launch. Detection as code makes this drift visible. The repository includes a daily job that runs a sample of every production rule against current log data; if a rule's selection criteria no longer match the underlying schema, the job opens a GitHub issue with the offending rule, the failed selection, and a suggested fix from the diff between the cached old schema and the current schema. Schema files live in the repository under schemas/ and are themselves versioned, so a schema update is a reviewable pull request. SIEM vendor query language updates follow the same pattern: pySigma backend updates land as dependency bumps with a CI run that re-converts the entire library, surfacing any rules that fail to compile against the new backend version. The result is that the detection library degrades gracefully under change rather than silently breaking, which is the difference between a SOC that knows its detection posture and one that thinks it does.

The bottom line

Detection as code is not a tooling change, it is an operating model change. The repository becomes the single source of truth, the SIEM becomes a runtime deployment target, and detection engineering becomes a discipline measurable against the same standards as software engineering. The cost is real: initial migration of a legacy library takes weeks, and engineers accustomed to console editing resist the friction of pull requests at first.

The payoff is durable. Rules are reviewable, testable, and reversible. Coverage is measurable and reportable. Schema drift becomes a visible event rather than a silent failure. New detection engineers onboard against documented patterns rather than tribal knowledge. When the next ransomware campaign breaks Friday afternoon, you ship a tested detection on Saturday morning rather than guessing at console syntax under pressure.

Frequently asked questions

Should we rewrite our entire existing rule library in Sigma?

No, migrate incrementally. Start by capturing all new rules in Sigma and ratifying the CI pipeline. Then migrate the highest-value existing rules (high-fidelity production detections covering critical ATT&CK techniques) over six to twelve months. Retire low-value legacy rules rather than migrating them.

What if pySigma does not support a specific construct in our SIEM?

Use a custom pipeline transformation or fall back to a native rule with a Sigma metadata wrapper. The Sigma project accepts contributions for missing constructs, and most major SIEM backends have active maintainers responsive to issues.

How do we deploy rules from Git to the SIEM?

Two patterns work: pull-based GitOps where a controller polls the repository and reconciles SIEM state, or push-based CI deployment where the merge pipeline calls the SIEM API directly. GitOps is more resilient but requires a controller component; CI push is simpler to bootstrap.

Who owns rule retirement decisions?

A rule that has not fired in twelve months and is not tagged as a low-volume high-severity backstop enters a deprecation review. The detection engineering lead reviews monthly, marks for deprecation with a thirty-day notice, and retires with the tombstone tag. Document the rationale in the deprecation PR.

How do we handle environment-specific tuning like IP allowlists?

Keep tuning out of the rule itself. Use a separate filters/ directory with environment-specific exclusion logic that is layered onto rules at conversion time via pySigma pipelines. This keeps the core rule portable and makes exceptions auditable and reviewable separately.

Sources & references

  1. SigmaHQ Detection Rules
  2. pySigma Converter
  3. MITRE ATT&CK Framework
  4. Palantir Alerting and Detection Strategy Framework

Free resources

25
Free download

Critical CVE Reference Card 2025–2026

25 actively exploited vulnerabilities with CVSS scores, exploit status, and patch availability. Print it, pin it, share it with your SOC team.

No spam. Unsubscribe anytime.

Free download

Ransomware Incident Response Playbook

Step-by-step 24-hour IR checklist covering detection, containment, eradication, and recovery. Built for SOC teams, IR leads, and CISOs.

No spam. Unsubscribe anytime.

Free newsletter

Get threat intel before your inbox does.

50,000+ security professionals read Decryption Digest for early warnings on zero-days, ransomware, and nation-state campaigns. Free, daily, no spam.

Unsubscribe anytime. We never sell your data.

Eric Bang
Author

Founder & Cybersecurity Evangelist, Decryption Digest

Cybersecurity professional with expertise in threat intelligence, vulnerability research, and enterprise security. Covers zero-days, ransomware, and nation-state operations for 50,000+ security professionals every morning.

Black Hat Giveaway

Win a $2,495 Black Hat pass.

Full-access to Black Hat USA 2026 in Las Vegas. Subscribe free to enter.

Joins Decryption Digest daily briefing. Unsubscribe anytime.

Giveaway: Black Hat USA 2026 Full-Access Pass ($2,495 value)

Details →
Daily Briefing

Subscribe to enter the giveaway

Every subscriber is automatically entered. You also get daily threat intel every morning: zero-days, ransomware, and nation-state campaigns. Free. No spam.

Already subscribed? You're already entered.

Giveaway

Win a $2,495 Black Hat USA 2026 pass.