Chapter 12 — Contained laboratory I
Lesson map
Lesson 12 published. Map, example, EX045.
flowchart TD
N0["Learning outcomes"]
N1["12.1 The lab setting"]
N2["12.2 The task"]
N3["Lab — advisory comparison"]
N4["12.3 Lab result"]
N5["12.4 Planning"]
N6["12.5 Lab habits"]
N7["Reading the lab"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6 --> N7
N7 --> EX["Worked example"]
EX --> Q["Exercise EX045"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["12.1 The lab setting"]
N2["12.2 The task"]
N3["Lab — advisory comparison"]
N4["12.3 Lab result"]
N5["12.4 Planning"]
N6["12.5 Lab habits"]
N7["Reading the lab"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6 --> N7 --> Q["EX045"]
[Learning outcomes]
|
v
[12.1 The lab setting]
|
v
[12.2 The task]
|
v
[Lab — advisory comparison]
|
v
[12.3 Lab result]
|
v
[12.4 Planning]
|
v
[12.5 Lab habits]
|
v
[Reading the lab]
|
v
[Worked example] --> [Exercise EX045]
Learning outcomes
You will (1) run an advisory comparison in a contained lab; (2) interpret results; (3) plan updates by severity; (4) practise safe lab habits.
12.1 The lab setting
The contained lab uses synthetic customer records only. No real sites are touched; results are discussed, not acted on, until the real process runs with tickets. This rule protects Pinecrest's customers from mistakes made while learning in the lab. A script under development might have a bug, and pointing it at a live site could produce wrong findings or, for a script that writes, real damage. Discussing results first and acting only through tickets keeps the lab a rehearsal rather than a change. Lab records are labelled as synthetic so they are never filed as real findings.
12.2 The task
Compare installed plugin versions for three synthetic sites with two advisories: resize-plugin fixed in 2.4.3 (high) and contact-form fixed in 5.1.0 (medium). The two advisories differ in severity, which is what makes the task useful for practising priorities. The three synthetic sites also include two installations that are already fixed, so the script must show that it can tell affected versions from safe ones rather than flagging every installation of a named plugin. The fixed versions and severities come from the synthetic advisories only.
Lab — advisory comparison
"""Compare installed synthetic plugin versions with advisory fixed versions (stdlib only)."""
def v(s): return tuple(int(x) for x in s.split("."))
advisories = {"resize-plugin": ("2.4.3", "high"), "contact-form": ("5.1.0", "medium")}
installed = {
"ferncroft-books": {"resize-plugin": "2.4.1", "contact-form": "5.2.0"},
"alder-dental": {"contact-form": "5.0.4"},
"quayside-gym": {"resize-plugin": "2.5.0", "contact-form": "4.9.9"},
}
count = {"high": 0, "medium": 0}
for site, plugins in installed.items():
for p, ver in plugins.items():
if p in advisories and v(ver) < v(advisories[p][0]):
fixed, sev = advisories[p]
count[sev] += 1
print(f"{site:16} {p:14} {ver:6} -> update to {fixed} ({sev})")
print("totals:", count)
Run with python3 lab_versions.py. Verified output:
ferncroft-books resize-plugin 2.4.1 -> update to 2.4.3 (high)
alder-dental contact-form 5.0.4 -> update to 5.1.0 (medium)
quayside-gym contact-form 4.9.9 -> update to 5.1.0 (medium)
totals: {'high': 1, 'medium': 2}
12.3 Lab result
ferncroft-books must update resize-plugin from 2.4.1 to 2.4.3 (high). alder-dental must update contact-form from 5.0.4 to 5.1.0 (medium), and quayside-gym contact-form from 4.9.9 to 5.1.0 (medium). Totals: high 1, medium 2. quayside-gym's resize-plugin 2.5.0 and ferncroft's contact-form 5.2.0 are already fixed. The totals depend on comparing number tuples, so 4.9.9 is correctly lower than 5.1.0. Changing alder-dental to 5.1.0 drops the medium count to 1. Tomás records both the original totals and the changed run, so the check of the script's behaviour is visible to Grace. The two already fixed installations show the script does not flag every copy of a named plugin.
12.4 Planning
High within 7 days, medium within 30. Customers are told before updates that could change how their site looks. For the lab results, that means ferncroft-books' resize-plugin update is due within 7 days, and the two contact-form updates within 30. Telling customers first matters for updates such as contact-form, where alder-dental's later update broke the form until a renamed setting was applied. The deadlines run from when the advisory arrives, not from when someone notices it. Customers who cannot accept an update in time are recorded with a reason and a new date.
12.5 Lab habits
Keep lab data synthetic, label outputs as lab results, and never point lab scripts at real systems. Labelling outputs as lab results prevents a synthetic finding, such as ferncroft-books needing resize-plugin 2.4.3, from being mistaken for a real ticket. Pointing scripts only at synthetic records keeps the contained lab contained. The same habits apply when Tomás later reuses the scripts in the rehearsal in Chapter 17. Lab scripts are stored apart from production tools so nobody runs them against live sites.
Reading the lab
The script converts versions to number tuples, compares each installed plugin with the fixed version, and counts results by severity. Tomás changes one input in the lab, setting alder-dental to 5.1.0, and confirms the medium count drops to 1, a quick way to check the script behaves as expected. He also notes that the lab's advisory list is tiny; the real process reads a feed with hundreds of entries, which is why matching must be automatic.
Lab record
Lab outputs are saved with the date and labelled as synthetic results.
Worked example
Tomás presents the lab plan to Grace: one high update today with a hash-verified official download, two medium updates in the weekly maintenance window. Grace asks what happens if an update breaks a site; Tomás adds a backup and rollback step to the plan.
Synthetic case. The lab is synthetic.
Errors and limits
A version comparison depends on accurate advisories; check the advisory text.
Exercises
- EX045 — Lab totals. What totals did the lab give? Rubric: 3 = high 1, medium 2; 2 = partial; 1 = vague; 0 = none.
- EX046 — Already fixed. Which installations were already fixed? Rubric: 3 = quayside resize 2.5.0; ferncroft contact-form 5.2.0; 2 = one; 1 = vague; 0 = none.
- EX047 — Due dates. What due dates apply? Rubric: 3 = high 7 days, medium 30; 2 = partial; 1 = vague; 0 = none.
- EX048 — Added step. What did Tomás add after Grace's question? Rubric: 3 = backup and rollback; 2 = partial; 1 = vague; 0 = none.
Synthesis
Practise in a contained lab before acting on real systems.
Continue studying — chapter 12 of 18
← Chapter 11 (draft) · Course chapter index · Chapter 13 (draft) →