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

Free lesson

Reporting gaps so that they get fixed

After this lesson: I can write a purple team report that ranks each gap with a fix and an owner.

60 min lesson8 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

Forty pages, nothing changed

A team spends a week testing and writes forty careful pages. Six months later the same gaps are still open. Nobody knew which to fix first, or whose job it was.

A report is only worth what gets fixed because of it. In this lesson you turn the results of your own lab copy into one that gets acted on.

By the end of this lesson

Note

I can write a purple team report that ranks each gap with a fix and an owner.

Key words

WordWhat it means
Gapa technique you cannot yet detect
Priorityhow soon a gap should be fixed
Ownerthe person or team who fixes a gap
Retest datewhen a fix will be tested again
Executive summarythe short part written for leaders

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

Report only on tests you were allowed to run, in your own lab copy here. A real report describes a real network, so it is shared only with the people the owner names. The tests themselves need written permission under the Computer Misuse Act 1990.

Each kind of gap has its own fix

A gap is not one thing. Never tested means nobody knows. No telemetry means the data is missing, a job for whoever runs the sensors. No detection means the data is there and no rule reads it.

A pass that has gone stale needs a retest. Naming the kind tells you the fix and the owner.

Worked example: gap, fix and usual owner

GapFixUsual owner
Not testedWrite an atomic testThe red side
No telemetryCollect the data sourcePlatform or IT team
No detectionWrite and test a ruleDetection engineers
Retest dueRun the test againThe purple team

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 report maker, part 1

Command
printf '%s\n' 'import csv, sys' 'from datetime import date' 'today = date.fromisoformat(sys.argv[1])' 'TACTIC = {"Command and Control": 3, "Exfiltration": 3, "Persistence": 3, "Privilege Escalation": 3,' '          "Execution": 2, "Defense Evasion": 2, "Collection": 2, "Discovery": 1}' 'GAP = {"no telemetry": 3, "not tested": 2, "no detection": 2, "retest due": 1}' 'FIX = {"no telemetry": "collect the data source", "not tested": "write an atomic test",' '       "no detection": "write and test a rule", "retest due": "run the test again"}' 'OWNER = {"no telemetry": "platform team", "not tested": "red side",' '         "no detection": "detection engineers", "retest due": "purple team"}' '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' 'gaps = []' 'for tid, row in latest.items():' > emu/report.py

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

Write the report maker, part 2

Command
printf '%s\n' '    old = row["date"] > "-" and (today - date.fromisoformat(row["date"])).days > 90' '    kind = {"untested": "not tested", "none": "no telemetry", "telemetry": "no detection"}.get(row["outcome"])' '    if row["outcome"] == "alert" and old:' '        kind = "retest due"' '    if kind:' '        score = TACTIC.get(row["tactic"], 1) + GAP[kind]' '        gaps.append((-score, tid, row["tactic"], kind, "high" if score >= 5 else "medium" if score == 4 else "low"))' 'out = open("emu/report.md", "w")' 'out.write("# Purple team report, Riverside office, " + sys.argv[1] + chr(10) + chr(10))' 'out.write("Techniques in the plan: " + str(len(latest)) + ". Gaps: " + str(len(gaps)) + "." + chr(10) + chr(10))' 'out.write("| Priority | Technique | Tactic | Gap | Fix | Owner | Retest by |" + chr(10) + "|---|---|---|---|---|---|---|" + chr(10))' 'for score, tid, tactic, kind, level in sorted(gaps):' >> emu/report.py

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

Write the report maker, part 3

Command
printf '%s\n' '    out.write("| " + " | ".join([level, tid, tactic, kind, FIX[kind], OWNER[kind], "2027-01-15"]) + " |" + chr(10))' 'out.close()' 'print("wrote emu/report.md with", len(gaps), "gaps")' >> emu/report.py

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

Make the report for 20 November

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

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

Read the report

Command
cat emu/report.md

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 fair report lists every finding the same way, in the order found. Readers then fix the easy ones and stop. Rank gaps by what they would let an attacker do here, and give each one a fix, an owner and a date.

Write for two readers

Leaders read the executive summary: a few plain sentences on what was tested, what was seen and the three things to fix first. Engineers read the table and the evidence behind each line.

Say what went well too, and blame nobody. A team that is blamed stops asking for tests.

Count the high-priority gaps

Command
grep -c "| high |" emu/report.md

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

The report starts the next loop

Every line ends with a retest date. On that date the purple team runs the test again, and the result goes into the history.

Coverage then moves because something was fixed, not because a map was coloured in. That is the whole module in one loop.

Try it: rank two gaps

Code: python
TACTIC = {"Command and Control": 3, "Discovery": 1}
GAP = {"no telemetry": 3, "no detection": 2, "retest due": 1}

gaps = [("T1105", "Command and Control", "no telemetry"), ("T1033", "Discovery", "retest due")]
for tid, tactic, kind in gaps:
    score = TACTIC[tactic] + GAP[kind]
    print(tid, score, "high" if score >= 5 else "medium" if score == 4 else "low")
# Add ("T1070.004", "Discovery", "no detection"), then press Run.

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

Assignment: name and rank the gaps

kind(outcome, age) returns the kind of gap for a technique's latest result: "not tested" for "untested", "no telemetry" for "none", "no detection" for "telemetry", "retest due" for an "alert" more than 90 days old, and None for a fresher alert.

priority(tactic, gap, weights) adds weights[tactic] (1 when the tactic is missing) to the gap's own weight: 3 for no telemetry, 2 for not tested or no detection, 1 for retest due. Return "high" for 5 or more, "medium" for 4 and "low" below.

ranked(gaps, weights) takes a list of (technique, tactic, gap) and returns (level, technique) pairs, highest total first, then by technique.

Code: python
def kind(outcome, age):
    return None

def priority(tactic, gap, weights):
    return "low"

def ranked(gaps, weights):
    return []

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.