Detection Engineering

Detection-as-Code: Tested Sigma Rules

16 Sigma detection rules mapped to MITRE ATT&CK, each tested automatically against attack and benign log events.

Personal projectSigmapySigmaMITRE ATT&CKPythonSplunk SPLElasticGitHub Actions
Detection-as-Code: Tested Sigma Rules
16
detection rules
15
ATT&CK techniques
119
test events
100%
tests passing
S

Situation

SOC teams depend on detection rules, but rules written straight into a SIEM are hard to review, often go untested and can break silently when someone edits them. I wanted a project that shows how detections are built and maintained in a modern SOC, not just how alerts are read.

T

Task

Build a version-controlled library of rules for common attacker behaviour on Windows, Linux and web servers. Prove that each rule fires on realistic attacks without firing on normal activity, and make the rules usable in more than one SIEM.

A

Action

  • Wrote 16 rules in Sigma, the vendor-neutral detection format, covering encoded PowerShell, Office macros launching a shell, LSASS credential dumping, ransomware deleting shadow copies, brute force, path traversal and SQL injection.
  • Tagged every rule with its MITRE ATT&CK techniques, a severity level and documented false positives.
  • Built two brute-force correlation rules (10+ failed logons from one IP within 5 minutes) for Windows and Linux.
  • Wrote a Python test harness with pySigma. Each rule is converted to SQL and run against its own attack events, which must all alert, and benign look-alikes, which must not.
  • Generated Splunk and Elastic queries and an ATT&CK Navigator coverage layer, and set up GitHub Actions to run the tests on every commit.
R

Result

  • All 16 rules pass against 119 test events, covering 15 ATT&CK techniques across 8 tactics.
  • The tests caught a real gap. My first LSASS rule missed the comsvcs.dll MiniDump technique because attackers pass a process ID, not the process name. I fixed it and added a regression test.
  • Deliberately breaking rules confirmed that the test suite catches regressions.
  • Next step: replace the hand-written sample events with real events captured in my home SOC lab.

Theme Colors