Stage 7 of 8 · about 8–12 hours · intermediate · checked 2026-11-26

Continuous validation

Authorised use only. Isolated lab only. Automate in the lab. Automation on real systems needs written approval, a change window and a kill switch. See Stage 1.

Goal. By the end you can re-run a set of tests on a schedule, compare the results with what you expect, and be told when a detection stops working.

Why it matters#

Detections rot. Log sources change, agents update, rules get tuned, schemas drift, and someone "tidies" an audit policy. A test that passed in March says nothing about November. Without regression tests you find the break during an incident, which is the worst time.

What you will learn#

The test ladder for detections#

Level What it checks Speed Needs
1. Static checks Syntax, required fields, and that the rule converts for your SIEM Seconds Rules in Git
2. Replay tests Recorded events run through the rule: it matches the bad ones and stays quiet on the good ones Seconds to minutes Saved events
3. Live lab emulation Real tests on lab hosts through the real pipeline, from log to alert Minutes The lab and a runner
4. Production validation Limited, approved tests, or a BAS platform, on real systems Scheduled Approval and deconfliction

Each level catches different failures. Levels 1 and 2 catch broken rules. Level 3 catches broken pipelines and configuration. Level 4 catches the differences between your lab and the real thing. For replay, save your own recordings from stage 4, or use public datasets such as Splunk's attack_data. Chainsaw and Hayabusa can apply Sigma-based rules to exported Windows event logs offline. Read each README for how it loads rules.

A regression-test manifest#

Each test is a record that lives in Git beside the rules: what to run, what to expect, and who owns it. This format is an invented example, not a standard:

YAML
- id: EMU-T1053-005-02
  technique: T1053.005
  atomic_guid: 42f53695-ad4a-4546-abb6-7d837f644a71
  platform: windows
  target_group: lab-win
  expect:
    telemetry: ["sysmon:1", "security:4698"]
    alert_rule: 5f1c8a3e-7d42-4b9e-9c0a-2e6b4a1d3f57
    max_minutes_to_alert: 5
  cleanup: automatic
  owner: detection-team
  last_result: pass

The alert_rule is the Sigma rule id from stage 4. A test without an expected alert and a time limit is a demonstration, not a regression test.

Automating the run#

  • Atomic Runner. Invoke-AtomicRedTeam includes an unattended runner. It works through a CSV schedule of atomic tests, by default once a week. Before each test it appends the test's GUID to the computer name, so an alert's host name tells you which test caused it. It runs the cleanup afterwards. It also renames the computer and reboots it between tests, so give it a dedicated lab machine. To stop it, add a file called stop to its folder, or remove its service or scheduled task. Read its wiki pages first.
  • Caldera. Build an adversary profile, run operations on a schedule, and read the results. Its plugins include the Atomic Red Team tests and the CTID plans.
  • Your own script. Run a test by GUID on a lab host, wait, query your SIEM's API for the expected alert, and write a pass or fail row.

Continuous integration#

Run the cheap levels often and the expensive ones less often. On every rule change, run static checks and replay tests. Nightly or weekly, run the live tests and compare. On any regression, open an issue or notify a person. This GitHub Actions skeleton shows the shape. The two scripts are yours to write in the exercise:

YAML
name: nightly-detection-validation
on:
  schedule:
    - cron: "17 2 * * *"
  workflow_dispatch:
jobs:
  validate:
    runs-on: [self-hosted, emulation-lab]
    steps:
      - uses: actions/checkout@v7
      - name: Static checks
        run: sigma check rules/
      - name: Run the live tests
        run: pwsh ./scripts/run-tests.ps1 -Manifest tests/manifest.yml
      - name: Compare results with expectations
        run: pwsh ./scripts/compare-results.ps1 -Results results.json

A self-hosted runner executes whatever the workflow tells it to. GitHub's own security guidance says self-hosted runners should almost never be used for public repositories, because anyone can open a pull request and run code on them. Keep the repository private, keep the runner on a dedicated machine inside the lab with no real credentials, and never run emulation from a public hosted runner against anything.

Breach-and-attack simulation platforms#

A BAS platform automates the running and the reporting: agents execute a library of safe tests on a schedule and map results to ATT&CK. Commercial examples include AttackIQ, Cymulate, Picus Security, SafeBreach and SCYTHE (a list, not a recommendation). Caldera and the Atomic Runner are free alternatives. A platform does not decide what matters, which is your plan, and it does not fix gaps. Before you adopt one, ask:

  • What exactly executes on my hosts? Can I see and approve each action?
  • Is each test safe by design, and is the cleanup automatic?
  • How finely is each test mapped to ATT&CK: one procedure, or many?
  • Does it cover identity and cloud, or only endpoints?
  • How do its results reach my SIEM and my ticketing system?
  • Can I add my own tests, and what does it cost over three years?

Metrics#

Metric Definition What it tells you
Visibility rate Tests that produced telemetry ÷ tests run Can we see it?
Detection rate Tests that alerted ÷ tests run Do we alert on it?
Prevention rate Tests that were blocked ÷ tests run Do controls stop it?
Time to alert Alert time minus execution time (median and worst) How fast?
Regressions Tests that passed last run and fail now What broke?
Freshness Days since each test last ran What have we stopped checking?
Gap closure Gaps closed within the agreed time ÷ gaps found Do we fix what we find?

Beware these traps. A "percentage of ATT&CK covered" is misleading, because one test covers one procedure of a technique. A 100% rate on easy tests is a floor, not proof. Counting tests run rewards volume over value. Alerts raised by tests should not bury real ones. Flaky tests need fixing or retiring. An average hides the slowest alert. Detection Engineering stage 8 (Coverage, health and metrics) covers coverage reporting in more depth.

Safety for automation#

Automate in the lab by default. Automation on real systems needs written approval, a change window, a kill switch, test IDs for deconfliction, rate limits, no destructive tests and a named owner. Use dedicated least-privilege accounts, and keep their secrets in your CI system's secret store, never in the repository.

Do this#

  1. Write a manifest of five tests (1 hour). Take them from your stage 2 plan and your stage 4 runs.
  2. Build a replay test (2–3 hours). Export the events from a stage 4 run, plus some benign ones. Show that the rule matches the bad events and stays quiet on the benign ones.
  3. Schedule the live run (3 hours). Use the Atomic Runner on a dedicated lab machine, after reading its wiki, or use your own script.
  4. Write the compare step (2–3 hours). Read the manifest and the SIEM results, write pass or fail per test, and notify on a failure.
  5. Cause a regression on purpose (1 hour). Disable a Sysmon event or the rule. Confirm the next run fails and you are told. Restore it and confirm a pass.
  6. Report the metrics (30 minutes). One table with the metrics above, for a few runs.

Resources#

Free first

Paid or needs an account

  • Commercial BAS platforms (paid). Use a trial and the questions above before you commit.

Checkpoint#

You are ready to move on when you can:

Go deeper (optional)#

  • Read the CTID's Summiting the Pyramid to judge how robust a detection is, not only whether it fires.
  • Add one identity or cloud test from stage 6 to your manifest, with its own sandbox account.

0 / 6 checkpoints ticked

View this page on GitHub

9 lines · 59 stages · 77 pages 0 of 59 stages done