Stage 6 of 10 · about 10–16 hours · intermediate · checked 2026-11-22

Test, tune, deploy

Goal. By the end you can prove that a detection fires, show that it stays quiet on harmless lookalikes, reduce its noise without going blind, and roll it out in steps instead of all at once.

Why it matters#

A rule you have not tested is a guess. A rule that fires all day teaches the SOC to ignore it, and the day it catches something real, nobody looks. Testing and tuning are where a detection becomes something people can trust, and they are the stages teams most often rush. A staged rollout is what stops one bad rule from flooding the queue.

What you will learn#

Four kinds of test#

  1. Positive test. A known malicious or emulated event must trigger the detection.
  2. Negative test. A harmless lookalike must not. For the Office rule, that could be an add-in you know is legitimate.
  3. Regression test. When you change a rule, every earlier test must still pass.
  4. Cost test. The search must finish in reasonable time and return a reasonable volume.

Test three layers, not one: the logic (does the query match the event), the data (does the event reach the SIEM with the fields you need) and the alert (does a hit become an alert that someone sees). Many "working" detections fail at the second or third.

Getting test events#

  • Replay recorded events. Public sample sets let you test without running anything: EVTX-ATTACK-SAMPLES, OTRF Security-Datasets and Splunk's attack_data repository (links below). Safe and repeatable.

  • Generate events with a small, well-known test. Atomic Red Team is an open-source library of small tests mapped to ATT&CK techniques. Run them only on a lab machine you can revert to a snapshot. A careful routine looks like this:

    PowerShell
    Invoke-AtomicTest T1053.005 -ShowDetailsBrief   # read what each test does first
    Invoke-AtomicTest T1053.005 -CheckPrereqs       # check what the test needs
    Invoke-AtomicTest T1053.005 -TestNumbers 1      # run one test (the number comes from the listing)
    Invoke-AtomicTest T1053.005 -TestNumbers 1 -Cleanup

    Follow the project's own installation guide (linked below), read any script before you run it, and check the wiki for the current syntax. Revert the snapshot when you finish.

  • Write your own harmless lookalike. An administrator creating a scheduled task for a backup, a signed add-in starting a script. The negative test is just as important as the positive one.

Whatever you use, keep evidence with the rule: which test, when, on which host, what you expected, what happened, and a link or screenshot of the alert. "Fired on test 1 for T1053.005 at 14:02 on lab-win10" is the level of detail to aim for.

Timing traps#

Data does not arrive instantly. If a search looks at the last five minutes of event time but the data is ten minutes late (you measured this in stage 3), it will never see anything. Make the lookback window longer than your slowest normal delay, and use throttling so that overlapping runs do not raise the same alert twice. This is a classic reason a rule passes a lab test and then misses in production.

Tuning#

Tuning means reducing noise without reducing what you can catch. Work in this order:

  1. Measure first. Count the hits, then group them by the fields that vary (user, host, parent process, command line). A few values usually account for most of the noise.
  2. Make the logic more specific. Often the best fix is a tighter match on the invariant, not an exclusion.
  3. Exclude narrowly. Exclude a specific verified-benign pattern, for example one signed parent running one script from one folder, rather than a whole folder or a whole tool. Attackers use excluded paths and tool names.
  4. Add context. Enrich with asset importance or account type, so the same hit rates higher on a server than a test machine.
  5. Change what a hit means. A rule that stays noisy may belong as a hunting lead or as a risk contribution rather than an alert that pages someone.

Keep exclusions in a maintained list (a lookup, a watchlist, a reference table) rather than in the query, and give every entry an owner, a reason and a review date. Every exclusion is a blind spot you have chosen, so you should be able to say who chose it and why.

A grouping query for step 1, in both languages:

SPL
source="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 Image="*\\schtasks.exe" CommandLine="* /create *"
| stats count BY ParentImage, user
| sort - count
KQL
DeviceProcessEvents
| where FolderPath endswith "\\schtasks.exe" and ProcessCommandLine contains " /create "
| summarize hits = count() by InitiatingProcessFolderPath, AccountName
| sort by hits desc

Illustrative: test it in your lab before relying on it. Each lists which parents and accounts create the most tasks, which is where the noise to investigate lives.

Another tuning idea is risk-based alerting: instead of alerting on every weak signal, each detection adds points to the user or host involved, and an alert fires only when the total crosses a threshold or when signals from several different tactics appear on the same entity. Several SIEMs offer this; look for your platform's version once you have a handful of lower-confidence detections.

Deploy in steps#

Never go from "it works in the lab" straight to "it pages someone".

Step What happens How long, roughly
Develop Runs on lab or test data only Until the tests pass
Shadow Runs in production and writes results to a dashboard or index, with no ticket One to two weeks
Low visibility Raises low-severity alerts or risk, which analysts can see but are not paged by One to two weeks
Live Raises a real alert, with the response steps from the detection card Ongoing

At each step watch the volume and ask the SOC what they would want changed. Before each move, check:

Measuring alert quality#

Ask analysts to record an outcome when they close each alert: a true positive (real malicious activity), a benign true positive (the behaviour was real but harmless), a false positive (the logic matched something it should not have) or a duplicate. Then the share of alerts that were worth an analyst's time is a number you can track. Agree a target with the SOC and revisit it. A rule that is mostly noise should be tuned, demoted or retired, not kept because someone wrote it.

Do this#

  1. Run three positive tests (3 to 4 hours). For three of your stage 5 detections, take a lab snapshot, run a matching test (list its details first, then run it, then clean up), and save the evidence. Revert the snapshot afterwards.
  2. Write the negative tests (2 hours). For each detection, produce a harmless lookalike and show the rule stays quiet. If it does not, you have found your first tuning job.
  3. Tune one noisy rule (3 to 4 hours). Measure the hits, find the top contributors, make one change at a time, and record the numbers before and after. Write a short note on what you changed and the blind spot it introduces.
  4. Practise a rollout (2 hours). Take one rule through develop, shadow, low visibility and live in your lab, writing the checklist result at each step. Add a rollback note.

Resources#

Free first

Paid or needs an account

  • None needed for this stage.

Checkpoint#

You are ready to move on when you can:

Go deeper (optional)#

  • Replay a sample set through one of your rules and compare the hits with what the dataset's description says should happen.
  • Read how your SIEM implements throttling and risk-based alerting, and write one paragraph on when you would use each.
  • Threat Emulation stage 4 walks one test from running it to a validated detection.

0 / 12 checkpoints ticked

View this page on GitHub

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