A deadline for every fix
A patch SLA is a promise of how many days a team has to fix a vulnerability, set by how serious it is. Without one, the easy fixes get done and the urgent ones wait.
With one, everybody can see what is due, what is late and who decided to wait.
By the end of this lesson
Note
I can set a due date for each finding from a patch policy.
Key words
| Word | What it means |
|---|---|
| Patch | an update that fixes a flaw |
| SLA | service level agreement: a promised time to do something |
| Remediation | removing a vulnerability, usually by patching |
| Exception | a recorded, dated decision to fix later |
| Compensating control | another defence used while a fix waits |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsA policy turns priority into days
A patch policy gives each kind of finding a number of days. In the UK, the Cyber Essentials scheme asks for high and critical updates within 14 days of their release. CISA gives each KEV entry a due date.
This lesson's college uses its own policy: KEV 7 days, critical 15, high 30, medium 90 and low 180. The clock starts on the day the scan finds it.
Try it: due dates from one policy
import datetime
DAYS = {"KEV": 7, "CRITICAL": 15, "HIGH": 30, "MEDIUM": 90, "LOW": 180}
found = datetime.date(2026, 11, 23)
for rule in DAYS:
due = found + datetime.timedelta(days=DAYS[rule])
print(rule, "due", due.isoformat())
# Change found to the day the scan ran in your own lab. What moves?
Make a free account to save your work and track your progress.
Check
Have a go
Check
3 questionsWrite the helper that reads reports, part 1
docker exec tools sh -c "printf '%s\n' 'import csv' 'import gzip' 'import json' '' 'EPSS_FILE = \"/work/snapshot/epss-2026-11-20.csv.gz\"' 'KEV_FILE = \"/work/snapshot/kev-2026-11-20.json\"' '' 'def findings(name):' ' with open(\"/work/reports/\" + name + \".json\") as f:' ' report = json.load(f)' ' rows = []' ' for result in report.get(\"Results\", []):' ' rows = rows + (result.get(\"Vulnerabilities\") or [])' ' return rows' '' 'def cve_list(rows):' ' cves = []' ' for v in rows:' ' if v[\"VulnerabilityID\"] not in cves:' ' cves.append(v[\"VulnerabilityID\"])' > steps/snap.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the helper that reads reports, part 2
docker exec tools sh -c "printf '%s\n' ' return cves' '' 'def epss(wanted):' ' scores = {}' ' with gzip.open(EPSS_FILE, \"rt\") as f:' ' for row in csv.reader(f):' ' if row[0] in wanted:' ' scores[row[0]] = [float(row[1]), float(row[2])]' ' return scores' '' 'def kev():' ' with open(KEV_FILE) as f:' ' catalogue = json.load(f)' ' return {v[\"cveID\"]: v for v in catalogue[\"vulnerabilities\"]}' '' 'def nvd(v):' ' return v.get(\"CVSS\", {}).get(\"nvd\", {}).get(\"V3Score\")' >> steps/snap.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Scan the old image to JSON
docker exec scanner trivy image --input /targets/web-1.25.3.tar --format json -o /work/reports/web.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Scan the Java service to JSON
docker exec scanner trivy fs /targets/reports --format json -o /work/reports/reports.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the script that sets due dates
docker exec tools sh -c "printf '%s\n' 'import datetime' 'import snap' '' 'FOUND = datetime.date(2026, 11, 23)' 'DAYS = {\"KEV\": 7, \"CRITICAL\": 15, \"HIGH\": 30}' 'catalogue = snap.kev()' 'due = {}' 'for name in [\"web\", \"reports\"]:' ' for v in snap.findings(name):' ' cve = v[\"VulnerabilityID\"]' ' rule = \"KEV\" if cve in catalogue else v[\"Severity\"]' ' if rule in DAYS:' ' day = FOUND + datetime.timedelta(days=DAYS[rule])' ' due[cve] = [day.isoformat(), cve, rule, name]' 'for row in sorted(due.values())[:5]:' ' print(row[0], row[1], row[2], row[3])' 'for rule in DAYS:' ' print(rule, len([r for r in due.values() if r[2] == rule]))' > steps/due.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Give every finding a due date
docker exec tools python3 steps/due.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
What due.py printed
| Due | CVE | Rule | Where |
|---|---|---|---|
| 2026-11-30 | CVE-2021-44228 | KEV | reports |
| 2026-11-30 | CVE-2021-45046 | KEV | reports |
| 2026-12-08 | CVE-2024-45491 | CRITICAL | web |
| 2026-12-08 | CVE-2024-45492 | CRITICAL | web |
| 2026-12-08 | CVE-2024-56171 | CRITICAL | web |
| Counted | KEV 2, CRITICAL 3, HIGH 22 |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think the deadline starts when someone gets round to looking. It starts when the policy says, here the day of the scan. A clock that starts late hides exactly the findings nobody looked at.
One upgrade can close many findings
Patching an image usually means rebuilding it on a newer base, not fixing packages one by one. Moving the web server from nginx 1.25.3 to 1.31.9 also moves Alpine from 3.18 to 3.24.
Compare the two scans to see what the upgrade closes, what it leaves and what it brings.
Scan the new image to JSON
docker exec scanner trivy image --input /targets/web-1.31.9.tar --format json -o /work/reports/web-new.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the script that compares two scans
docker exec tools sh -c "printf '%s\n' 'import snap' '' 'old = snap.cve_list(snap.findings(\"web\"))' 'new = snap.cve_list(snap.findings(\"web-new\"))' 'closed = [c for c in old if c not in new]' 'still = [c for c in old if c in new]' 'added = [c for c in new if c not in old]' 'print(\"1.25.3:\", len(old), \"CVE.\", \"1.31.9:\", len(new), \"CVE.\")' 'print(\"Closed by the upgrade:\", len(closed), \"still open:\", len(still), \"new:\", len(added))' > steps/diff.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Compare the old and new images
docker exec tools python3 steps/diff.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsWhen a fix cannot meet its date
Sometimes a fix would break something, or the supplier has none yet. Then the team records an exception: who decided, why, which compensating control limits the risk meanwhile, and the date it expires.
Two measures show whether a policy works: the share of findings fixed by their due date, and the mean time to remediate.
Assignment: due dates and lateness
Apply the lesson's patch policy. DAYS gives the days for KEV and for each severity. Dates are ISO strings such as "2026-11-23".
days_allowed(severity, in_kev) returns the KEV days for anything in KEV, otherwise the severity's days. due_date(found, severity, in_kev) returns the due date as an ISO string. days_late(found, severity, in_kev, fixed_on) returns how many days after the due date the fix came, and 0 if it was on time.
import datetime
DAYS = {"KEV": 7, "CRITICAL": 15, "HIGH": 30, "MEDIUM": 90, "LOW": 180}
def days_allowed(severity, in_kev):
return 0
def due_date(found, severity, in_kev):
return ""
def days_late(found, severity, in_kev, fixed_on):
return 0
Make a free account to save your work and track your progress.
Exit quiz
Have a go