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
| Word | What it means |
|---|---|
| Coverage | the techniques your defences can see |
| Tested coverage | coverage proved by a test that ran |
| Staleness | how long since a result was checked |
| Heat map | a grid coloured by score |
| Layer | one set of scores laid over ATT&CK |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
3 questionsThe 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 result | Tested in 90 days? | Score | Colour |
|---|---|---|---|
| Alert | Yes | 2 | Green |
| Alert | No | 1 | Yellow |
| Telemetry, no alert | Either | 1 | Yellow |
| None, or never tested | Either | 0 | Red |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsMove into the lab's folder and make emu
cd ~/detect && mkdir -p emuShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the office's test history
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.csvShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the coverage scorer, part 1
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.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the coverage scorer, part 2
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.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Score coverage on 20 November
python3 emu/coverage.py 2026-11-20Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsA 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
head -n 12 emu/layer.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Count the techniques in the layer
grep -c techniqueID emu/layer.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsTry it: weight coverage by what matters
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.
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