Most detection rules begin life in a SIEM console. Someone writes a query, saves it, and moves on. Six months later nobody remembers why a threshold is 17, who changed the exclusion list, or whether the rule still fires after the last parser update.
Detection-as-code is the response: manage detection logic as files in version control, review changes like software, test them automatically, and deploy through a pipeline instead of by hand. MITRE’s ATT&CKcon 7.0 runs October 27-28, 2026 in McLean, Virginia and virtually, and its event page listed no session agenda when checked, so this piece does not rely on conference content. The practice is mature enough to adopt now.
What “as code” actually changes
The idea mirrors infrastructure as code. Engineers store rules as files, test them, and ship through automated pipelines rather than editing alerts in a SIEM interface. Four things improve at once.
History. Every change has an author, a diff and a reason. When an alert goes quiet, you can see what changed.
Review. A second engineer reads the logic before it reaches production. That catches overbroad exclusions and wrong field names.
Repeatability. The same rule set can be deployed to a test tenant, a staging SIEM and production.
Portability. If rules are in a neutral format, a platform migration is a conversion exercise rather than a rewrite.
Why Sigma is the usual starting point
Sigma is a vendor-neutral, YAML-based rule format. The tooling around it, pySigma and sigma-cli, converts rules into platform queries such as Splunk SPL or Microsoft KQL. A typical command is sigma convert -t splunk -p sysmon <rules directory>, with the backend plugin installed first. Backends handle condition conversion, while field naming and log-source handling live in processing pipelines, which is where your environment’s quirks belong.
One limit worth stating: Sigma is aimed at search-based detection, not real-time streaming logic. Detections that depend on stateful correlation or vendor-specific features may not translate and often stay as native queries stored in the same repository.
A pipeline that works
Sources describing detection-as-code pipelines converge on a similar sequence of quality gates:
- Lint and validate. Check the YAML structure, required metadata and naming conventions. Fail the build on malformed rules.
- Translate. Convert to your target query language. A rule that cannot compile is rejected here, not discovered in production.
- Unit test against sample events. Collect log events from past incidents or attack simulations and assert which should alert and which should not.
- Check false positives against history. Run the query over a window of real data and look at the volume.
- Emulate the adversary. Some teams run Atomic Red Team tests to confirm the rule fires on the technique it claims to cover.
- Deploy through the SIEM API after approval, from the main branch only.
The sources for this sequence are mostly practitioner write-ups and vendor blogs, so treat the exact tools as examples. The shape is what matters.
Metadata is half the value
Put ATT&CK mapping, data source, severity, owner and testing status into every rule’s metadata. That makes coverage reporting a query over the repository rather than a spreadsheet exercise. It also pays off when the framework changes. Our piece on ATT&CK v19’s Defense Evasion split describes a tactic retirement that is a find-and-update job when tactic IDs live in rule files, and a scavenger hunt when they live in console settings.
Regression testing is the underrated part
A rule that passed last quarter can break silently. A parser change, a SIEM upgrade or a new log source can alter field names so a query returns nothing. One vendor argues for automated regression tests on every commit; as a vendor it has an interest in saying so, but the failure mode is real and familiar to anyone who has run a SIEM. Scheduled tests that replay known-bad samples and alert when a rule stops matching catch it cheaply.
Where teams stumble
- Skill gaps. Not every security team has software engineering depth. A lighter version still pays: rules in Git, pull-request review, a lint step and manual deployment.
- Two sources of truth. If people keep editing in the console, the repository drifts. Make the pipeline the only route to production, and alert on console changes.
- Testing theater. A test with one positive sample proves little. Include benign look-alikes.
- Ownerless rules. Every rule needs a named owner and a review date, or the repository becomes a landfill.
Starting small
Treating a rule as a product with a lifecycle
A rule in a repository is not finished when it merges. It has a lifecycle: proposed, tested, deployed, tuned, and eventually retired. Encode that state in the metadata and let the pipeline enforce it. A rule marked experimental might deploy to a staging index or alert at low severity, while one marked production requires passing tests and a named reviewer.
Retirement is the step most teams skip. A rule that has not fired in a year may be silent because the behavior is rare, or because the log source it depends on stopped arriving. Both deserve a look, and the repository is the right place to attach that review date. Commit history makes the decision auditable: when someone asks why a detection was removed, the pull request holds the answer.
Pull requests also build a shared standard. When a junior analyst proposes a rule and a senior engineer comments on exclusions, field choice and test coverage, the team’s practice improves in a way that console-based editing never captures.
Pick ten of your noisiest or most important rules. Export them, convert to a neutral format where possible, commit them with owners and ATT&CK tags, and add a linting step. Run that before building the rest. Detection-as-code is not a tool purchase. It is a habit of treating detection logic as something that has to be reviewed, tested and remembered.
