Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Measuring detection coverage you can trust

After this lesson: I can measure detection coverage from test results rather than from rule tags.

60 min lesson7 commandsDetection engineering lab: Suricata rules, Sigma rules and Zeek-style logs on one private Ubuntu VM

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Green on the wall

A security team shows its board a big ATT&CK map, mostly green. Each green square means a rule exists. Nobody mentions that half the rules were last tested a year ago.

In this lesson you build a map where green has to be earned by a test, from the results of your own lab copy.

By the end of this lesson

Note

I can measure detection coverage from test results rather than from rule tags.

Key words

WordWhat it means
Coveragethe techniques your defences can see
Tested coveragecoverage proved by a test that ran
Stalenesshow long since a result was checked
Heat mapa grid coloured by score
Layerone set of scores laid over ATT&CK

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

The one rule

Important

The results here come from tests in your own lab copy. Testing a real network to fill in a map needs the owner's written permission first. Unauthorised testing is an offence under the Computer Misuse Act 1990. The office and its history are made up.

A tag claims, a test proves

Modules 105 and 119 counted the techniques the lab's rules were tagged with. A tag says what a rule is meant to catch. Only a test says what it did catch.

Tested coverage scores each technique by its latest test, and by staleness: rules, logs and machines change, so an old pass is worth less.

Worked example: one score for each technique

Latest resultTested in 90 days?ScoreColour
AlertYes2Green
AlertNo1Yellow
Telemetry, no alertEither1Yellow
None, or never testedEither0Red

The cells students fill in are left blank in this preview.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Move into the lab's folder and make emu

Command
cd ~/detect && mkdir -p emu

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the office's test history

Command
printf '%s\n' 'date,tactic,technique,name,test,outcome' '2026-03-10,Execution,T1059.004,Unix Shell,X1,alert' '2026-03-10,Privilege Escalation,T1548.003,Sudo and Sudo Caching,X2,telemetry' '2026-03-10,Command and Control,T1071.001,Web Protocols,X3,alert' '2026-03-10,Command and Control,T1105,Ingress Tool Transfer,X4,none' '2026-11-16,Discovery,T1033,System Owner/User Discovery,A1,alert' '2026-11-16,Discovery,T1082,System Information Discovery,A2,alert' '2026-11-16,Persistence,T1053.003,Scheduled Task/Job: Cron,A3,alert' '2026-11-16,Collection,T1074.001,Local Data Staging,A4,alert' '2026-11-16,Defense Evasion,T1070.004,File Deletion,A5,telemetry' '2026-11-18,Command and Control,T1071.001,Web Protocols,A6,alert' '-,Exfiltration,T1048,Exfiltration Over Alternative Protocol,-,untested' > emu/history.csv

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the coverage scorer, part 1

Command
printf '%s\n' 'import csv, json, sys' 'from datetime import date' 'today = date.fromisoformat(sys.argv[1])' 'latest = {}' 'for row in csv.DictReader(open("emu/history.csv")):' '    if row["technique"] not in latest or row["date"] > latest[row["technique"]]["date"]:' '        latest[row["technique"]] = row' 'SCORE = {"untested": 0, "none": 0, "telemetry": 1, "alert": 2}' 'layer = []' 'print("technique  tactic               last        age  outcome    score")' 'for tid, row in sorted(latest.items(), key=lambda item: (item[1]["tactic"], item[0])):' '    age = (today - date.fromisoformat(row["date"])).days if row["date"] > "-" else 0' '    score = SCORE[row["outcome"]]' '    if age > 90 and score == 2:' '        score = 1' '    layer.append({"techniqueID": tid, "score": score, "comment": row["outcome"] + ", " + row["date"]})' '    print(tid.ljust(10), row["tactic"].ljust(20), row["date"].ljust(11), (str(age) if age else "-").rjust(4), "", row["outcome"].ljust(10), score)' > emu/coverage.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the coverage scorer, part 2

Command
printf '%s\n' 'rows = list(latest.values())' 'tested = [r for r in rows if not r["outcome"] == "untested"]' 'alerts = [r for r in rows if r["outcome"] == "alert"]' 'fresh = [t for t in layer if t["score"] == 2]' 'print("Planned:", len(rows), " Tested:", len(tested), " Alert:", len(alerts), " Alert, tested in 90 days:", len(fresh))' 'json.dump({"name": "Riverside purple team", "domain": "enterprise-attack", "techniques": layer,' '           "gradient": {"colors": ["#ff6666", "#ffe766", "#8ec843"], "minValue": 0, "maxValue": 2}},' '          open("emu/layer.json", "w"), indent=1)' 'print("wrote emu/layer.json")' >> emu/coverage.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Score coverage on 20 November

Command
python3 emu/coverage.py 2026-11-20

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

A common mistake

Warning

Many people think a technique with a rule is covered. A rule can be broken, too narrow or fed no data, as the lab's Windows rules were on Linux. Count a technique as covered only when a recent test made the rule fire.

A layer makes the map

MITRE's ATT&CK Navigator draws a heat map from a JSON file called a layer. A layer lists technique ids, each with a score and a comment. The scorer writes one shaped like it, from red at 0 to green at 2.

A layer is easy to share and to compare. Next month's layer beside this one shows what improved.

Read the start of the layer

Command
head -n 12 emu/layer.json

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Count the techniques in the layer

Command
grep -c techniqueID emu/layer.json

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Try it: weight coverage by what matters

Code: python
scores = {"T1033": 2, "T1053.003": 2, "T1105": 0, "T1048": 0}
weights = {"T1033": 1, "T1053.003": 3, "T1105": 3, "T1048": 3}

plain = sum(scores.values()) / (2 * len(scores))
weighted = sum(scores[t] * weights[t] for t in scores) / (2 * sum(weights.values()))
print("plain", round(plain, 2), "weighted", round(weighted, 2))
# Set the score of T1105 to 2, then press Run.

Make a free account to save your work and track your progress.

Assignment: score tested coverage

Each row is a dictionary with "date" (YYYY-MM-DD, or "-" for never tested), "technique" and "outcome" ("untested", "none", "telemetry" or "alert").

latest(rows) returns a dictionary from each technique to its row with the latest date.

score(row, today) returns 2 for an alert tested within 90 days of today (a YYYY-MM-DD string), 1 for an older alert or for telemetry, and 0 otherwise.

percent(rows, today) returns the share of techniques whose latest row scores 2, as a percentage rounded to 1 place, or 0 when there are no rows.

Code: python
from datetime import date

def latest(rows):
    return {}

def score(row, today):
    return 0

def percent(rows, today):
    return 0

Make a free account to save your work and track your progress.

Exit quiz

Have a go

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.