Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Lesson 13 · 35 minutes

Report honest metrics to management on one page

After this lesson you can
  • Choose a small set of measures that come from records and support a decision
  • Compute patch age, review completion, overdue actions and restore test age with a program
  • Write a one-page report that shows the worst item and says what the numbers hide
Lab files of this lesson (70)

The lab folder as it stands after this lesson. Unzip it in ~/krlab.

More

The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.

Scenario

The management review of Brindle Books is this afternoon. Last quarter Carys brought a slide that said "security status: green". Asha asked what green meant, and nobody could say. This time Asha asks for one page with a few numbers that she can follow from quarter to quarter, and for each number the thing behind it. You compute the numbers from the files that the earlier lessons made, so that nobody types a figure by hand, and you write the page with a program.

Recall

Lesson 12: why does each row of a framework mapping carry a strength?

A bare mapping reads as "we do this", and most rows are only partly true. The strength says how much of the item the control covers, and a loose row must say what is missing.

Lesson 11: when is a corrective action overdue?

When the finding is a nonconformity, its status is still open, and its due date is before the date of the check. The function overdue of findings_check.py returns those findings.

The idea

A metric is a measure that you report again and again, so that somebody can decide something. Clause 9 of ISO/IEC 27001 asks the organisation to monitor and measure, and asks top management to review the system at planned intervals. That meeting is the management review. The metrics are its input, next to the audit findings and the risk register.

A number earns its place on the page when it passes five tests.

TestGoodBad
It comes from a recordComputed from the patch report"We feel well patched"
It shows both parts6 of 8 devices75%
It has a target, set before95% or more"Higher is better"
It names the worst itemscanner-1, 164 daysAn average
It cannot improve by doing lessFindings decided, of findings foundNumber of findings

The last test needs care. "Number of audit findings" falls when you stop auditing. "Number of blocked attacks" rises when you count differently. A measure that rewards looking away will be gamed, often with no bad intent.

This lesson uses four measures. Each one watches a control that you built.

MeasureFromTarget here
Devices patched within 30 daysevidence/patch-state.csv (lesson 6)95% or more
Access review findings decidedThe review of lesson 7All
Corrective actions overduefindings.csv (lesson 11)0
Age of the last restore testrestore_test.json (lesson 10)90 days or less
From records to a decision
RecordsMeasureTargetReportManagement reviewa program counts, nobody typesset before the countvalue, target, worst itemdecide, assign, dateRecordsMeasureTargetReportManagement review1234
  1. Records → Measure: a program counts, nobody types
  2. Measure → Target: set before the count
  3. Target → Report: value, target, worst item
  4. Report → Management review: decide, assign, date

The targets are choices of this course. An organisation sets its own, and the person who sets them is the one who must act when they are missed.

Worked example

Work in ~/krlab/security-governance.

1. Write the metrics program

The program imports the modules of lessons 7 and 11 and reads the files of lessons 6 and 10. ages is a dictionary from each host to the days since its last patch. max(ages, key=ages.get) gives the key with the largest value: the host that was patched longest ago. // divides and drops the part after the point. Each measure is a group of five values: name, value, target, whether the target is met, and a detail. If a file is missing, Python raises FileNotFoundError; the last lines catch it and stop with one line that names the file.

metrics.py

"""metrics.py: compute four measures from the records of a folder and write a one-page report.

    python3 metrics.py FOLDER       (prints the report and writes FOLDER/report.md)
"""
import json
import sys
from pathlib import Path

import access_review
import findings_check
from grc import TODAY, day, load


def measures(folder):
    """Return a list of (name, value, target, met, detail)."""
    folder = Path(folder)
    ages = {h["host"]: (TODAY - day(h["last_patched"])).days for h in load(folder / "evidence" / "patch-state.csv")}
    fresh = sum(age <= 30 for age in ages.values())
    worst = max(ages, key=ages.get)
    found = access_review.findings(folder)
    decided = {(d["account"], d["system"]) for d in load(folder / "access_decisions.csv") if d["decision"]}
    done = sum((f["account"], f["system"]) in decided for f in found)
    late = findings_check.overdue(folder / "findings.csv")
    test_age = (TODAY - day(json.loads((folder / "restore_test.json").read_text())["tested_on"])).days
    return [
        ("Devices patched within 30 days", f"{fresh} of {len(ages)} ({100 * fresh // len(ages)}%)", "95% or more",
         fresh >= 0.95 * len(ages), f"oldest: {worst}, {ages[worst]} days"),
        ("Access review findings decided", f"{done} of {len(found)}", "all",
         done == len(found), f"{len(found) - done} without a decision"),
        ("Corrective actions overdue", str(len(late)), "0",
         not late, " ".join(f["id"] for f in late) or "none"),
        ("Age of the last restore test", f"{test_age} days", "90 days or less",
         test_age <= 90, "tested on " + json.loads((folder / "restore_test.json").read_text())["tested_on"]),
    ]


def report(folder):
    rows = measures(folder)
    lines = [f"# Security report to management, {TODAY}", "",
             "| Measure | Value | Target | Status | Detail |", "|---|---|---|---|---|"]
    lines += [f"| {name} | {value} | {target} | {'on target' if met else 'OFF TARGET'} | {detail} |"
              for name, value, target, met, detail in rows]
    lines += ["", f"Measures off target: {sum(not met for _, _, _, met, _ in rows)} of {len(rows)}", "",
              "Every value is computed from the records in this folder on the date above.",
              "The numbers show whether four controls ran. They do not show whether the controls are enough."]
    return "\n".join(lines) + "\n"


if __name__ == "__main__":
    try:
        text = report(sys.argv[1])
    except FileNotFoundError as error:
        sys.exit(f"missing file: {error.filename}. Make that record first (for the folder evidence, run python3 evidence.py collect, lesson 6).")
    (Path(sys.argv[1]) / "report.md").write_text(text)
    print(text, end="")

2. Run it

python3 metrics.py .
# Security report to management, 2026-11-21

| Measure | Value | Target | Status | Detail |
|---|---|---|---|---|
| Devices patched within 30 days | 6 of 8 (75%) | 95% or more | OFF TARGET | oldest: scanner-1, 164 days |
| Access review findings decided | 5 of 5 | all | on target | 0 without a decision |
| Corrective actions overdue | 0 | 0 | on target | none |
| Age of the last restore test | 0 days | 90 days or less | on target | tested on 2026-11-21 |

Measures off target: 1 of 4

Every value is computed from the records in this folder on the date above.
The numbers show whether four controls ran. They do not show whether the controls are enough.

Three measures are on target and one is not. A slide would have said "green". The page says where to look.

Look at the last row too. It measures the age of the restore test and not its result, so a failed test made today would also read "on target". That row fails the fifth test of the table above. Lesson 17 returns to it.

3. Look behind the number that is off target

Six of eight devices is 75%. Which two are late, and why? sort -t, -k3 sorts lines by their third field, with a comma as the separator: the oldest date comes first. The header line starts its third field with a letter, so it sorts to the end.

sort -t, -k3 evidence/patch-state.csv
grep "^R6" risks.csv | cut -d, -f1,3,6,13
scanner-1,Hal,2026-06-10,9
laptop-efe,Ben,2026-09-30,5
scanner-2,Hal,2026-10-25,1
laptop-carys,Ben,2026-10-28,2
laptop-asha,Ben,2026-11-03,1
db-1,Ben,2026-11-12,0
web-1,Dev,2026-11-12,0
laptop-ben,Ben,2026-11-15,0
host,owner,last_patched,pending_security
R6,Old scanner software is attacked,accept,Hal

The program computed an age for each device. Count the days from each date above to 2026-11-21: the drawing shows the result for all eight, and the target is 30 days or fewer.

Days since the last patch, on 2026-11-21 (target: 30 or fewer)
scanner-1164laptop-efe52scanner-227laptop-carys24laptop-asha18web-19db-19laptop-ben6scanner-1164laptop-efe52scanner-227laptop-carys24laptop-asha18web-19db-19laptop-ben6

The two late devices are different stories. scanner-1 has not been patched for 164 days, and the register explains it: risk R6, old scanner software, accepted by Hal. laptop-efe is 52 days behind with no such record. So the report hides two facts that Asha needs: one late device is a known, accepted risk, and the other is a plain miss that Ben can fix this week.

4. Ask what the target can mean

With 8 devices, each device is 12.5 points. A target of 95% can be met only when all 8 are patched. So the honest question for the review is not "why are we at 75%?". It is "do we accept that the scanner stays unpatched?". If yes, the measure should say so: count the devices in scope of the patch rule, and list the accepted exceptions next to it. A target that can never be met teaches people to ignore the page.

Check the arithmetic with one line of Python. python3 -c runs the code that follows.

python3 -c "print([f'{100 * n // 8}%' for n in (6, 7, 8)])"
['75%', '87%', '100%']

5. See the progress in the map

The report is one of the records that the map of lesson 2 named for clause 9. If you started from the zip, run python3 evidence.py collect and python3 evidence.py seal first, or the line about the manifest also shows. Run the strict check again.

python3 isms_check.py isms_map.csv . strict
 4 Context of the organisation  1 of 1 on file
 5 Leadership                   1 of 1 on file
 6 Planning                     3 of 3 on file
 7 Support                      1 of 3 on file
 8 Operation                    6 of 6 on file
 9 Performance evaluation       2 of 4 on file
10 Improvement                  1 of 1 on file
PROBLEM Competence needs of each role: not on file: competence_needs.csv
PROBLEM Competence and awareness records: not on file: competence.csv
PROBLEM Record of the management review: not on file: management_review.json
PROBLEM Actions of the management review: not on file: review_actions.csv
problems: 4

Four records are still missing: the competence and awareness records of clause 7, and the management review of clause 9, which is where this report goes. Lessons 14 and 15 build them. Lesson 16 checks whether all the records agree with each other.

Your turn

Compute the same four measures for Marlow Physio. The folder marlow has the review of lesson 7, the findings of lesson 11 and the restore test of lesson 10. It lacks a patch report: save the one below, then run your program on the folder. There are no steps.

marlow/evidence/patch-state.csv

host,owner,last_patched,pending_security
reception-1,Omar,2026-11-08,0
reception-2,Omar,2026-11-08,0
reception-3,Omar,2026-08-19,6
tablet-1,Omar,2026-10-30,1
tablet-2,Omar,2026-09-02,4
billing-old,Omar,2025-12-01,31

Then write the three sentences that you would put under Nadia's table: the one thing to do this week, the one decision that only she can take, and the one number that you do not trust yet.

Check yourself

Why does the report show "6 of 8" and not only "75%"?

A percentage hides the size of the group. 75% of 8 devices is two late devices, which a person can name and fix. 75% of 4,000 is a programme of work. The two parts also let a reader see when the group itself shrinks, which is one way to make a percentage look better.

What is wrong with "number of audit findings" as a measure of security?

It improves when you do less: fewer audits and smaller samples give fewer findings. It also punishes the auditor who looks hard. Measure what happens to findings instead: how many corrective actions are overdue, and how many closed findings were verified.

The access review measure says "5 of 5 decided". What does it not tell you?

Whether the decisions were good, and whether Ben applied them in the systems. "Decided" counts rows with a decision. A second measure could count the removals that the next export confirms. Until then, the internal audit samples the decisions.

Why must the target be set before the count?

A target that is chosen after the count can always be met. Setting it first makes the organisation say what "good enough" means while it does not yet know the answer, and that is the moment when the choice is honest.

Field notes

  • Show the trend. One value says little, and four quarters of the same measure show a direction. Keep each report in version control, so that the old values cannot be rewritten.
  • Give each measure an owner and a rule for what happens off target: who is told, and by when a plan is due. A red number that leads to no action trains people to ignore red.
  • Keep the set small. Four to eight measures that management understands are better than forty that nobody reads. Drop a measure that has never led to a decision.
  • Say on the page what is not measured. This report watches four controls of twelve. Silence about the others is not a result.
  • The management review produces decisions, and they need the same care as findings: an owner, a date and a follow-up. Record them where the next review will read them. Lesson 15 builds that record.