A contract with a condition
A council wants Lantern Print to print its leaflets, with residents' names and addresses. The contract has a condition: the printer must hold Cyber Essentials.
Lantern Print has eight devices. Are they ready?
By the end of this lesson
Note
I can check a list of devices against the five Cyber Essentials areas.
Key words
| Word | What it means |
|---|---|
| Cyber Essentials | a UK scheme for basic technical security controls |
| Security update | a fix from a vendor for a weakness |
| CVSS | a 0 to 10 score of how severe a weakness is |
| Default password | the password a device ships with |
| Administrator account | an account that can change the system |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
3 questionsA small set of controls, checked
Cyber Essentials is backed by the UK government. The National Cyber Security Centre sets its technical requirements. Its aim is to stop the most common attacks from the internet.
There are two levels. Cyber Essentials is a set of questions answered by the firm and checked by a certification body. Cyber Essentials Plus adds hands-on tests by an assessor. Both are renewed every year.
The five areas
| Area | What it asks, in short |
|---|---|
| Firewalls | Every device is behind a firewall that is switched on |
| Secure configuration | Default passwords changed, unused software removed |
| Security updates | Supported software only; serious fixes within 14 days |
| User access | Accounts only for those who need them; admin rights used only for admin work |
| Malware protection | Anti-malware or only approved apps on each device |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsSerious updates within 14 days
Some updates fix a serious weakness: the vendor rates them high or critical, or the weakness scores 7 or more on CVSS. They must go on within 14 days of release. An update 10 days old is not late yet.
The code below checks four updates against that rule.
Try it: which updates are late?
patches = [(9.8, 10, False), (8.1, 20, False), (6.5, 30, False), (7.5, 30, True)]
for cvss, days, installed in patches:
late = cvss >= 7 and days > 14 and not installed
print(cvss, days, "days", "LATE" if late else "ok")
# Wait four more days: add 4 to every age and run again.
Make a free account to save your work and track your progress.
Check Lantern Print's devices
devices.py lists eight devices, from office PCs to the router and the till. ce.py checks each device against the five areas.
It prints the areas each one fails and whether the firm is ready to apply.
Write the device list, part 1
docker exec jupyter sh -c "mkdir -p steps && printf '%s\n' 'devices = [' ' {\"name\": \"office-pc-1\", \"supported\": True, \"firewall\": True, \"default_password\": False,' ' \"daily_admin\": False, \"malware\": True, \"patches\": [(8.8, 5, True)]},' ' {\"name\": \"office-pc-2\", \"supported\": True, \"firewall\": True, \"default_password\": False,' ' \"daily_admin\": False, \"malware\": True, \"patches\": [(8.1, 20, False)]},' ' {\"name\": \"design-mac\", \"supported\": True, \"firewall\": True, \"default_password\": False,' ' \"daily_admin\": False, \"malware\": True, \"patches\": [(9.8, 10, False)]},' ' {\"name\": \"old-laptop\", \"supported\": False, \"firewall\": True, \"default_password\": False,' ' \"daily_admin\": False, \"malware\": True, \"patches\": []},' ' {\"name\": \"router\", \"supported\": True, \"firewall\": True, \"default_password\": True,' ' \"daily_admin\": False, \"malware\": True, \"patches\": []},' > steps/devices.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the device list, part 2
docker exec jupyter sh -c "printf '%s\n' ' {\"name\": \"till-pc\", \"supported\": True, \"firewall\": True, \"default_password\": False,' ' \"daily_admin\": True, \"malware\": False, \"patches\": []},' ' {\"name\": \"print-server\", \"supported\": True, \"firewall\": False, \"default_password\": False,' ' \"daily_admin\": False, \"malware\": True, \"patches\": [(7.5, 30, True)]},' ' {\"name\": \"manager-phone\", \"supported\": True, \"firewall\": True, \"default_password\": False,' ' \"daily_admin\": False, \"malware\": True, \"patches\": [(6.5, 30, False)]},' ']' '' 'fixes = {' ' \"office-pc-2\": {\"patches\": [(8.1, 20, True)]},' ' \"old-laptop\": {\"supported\": True},' ' \"router\": {\"default_password\": False},' ' \"till-pc\": {\"malware\": True},' ' \"print-server\": {\"firewall\": True},' '}' >> steps/devices.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the five-area check, part 1
docker exec jupyter sh -c "mkdir -p steps && printf '%s\n' 'import sys' 'from devices import devices, fixes' '' '' 'def late(patches):' ' return [p for p in patches if p[0] >= 7 and p[1] > 14 and not p[2]]' '' '' 'def fails(d):' ' found = []' ' if not d[\"firewall\"]:' ' found.append(\"firewalls\")' ' if d[\"default_password\"]:' ' found.append(\"secure configuration\")' ' if not d[\"supported\"] or late(d[\"patches\"]):' ' found.append(\"security updates\")' ' if d[\"daily_admin\"]:' ' found.append(\"user access\")' ' if not d[\"malware\"]:' ' found.append(\"malware protection\")' ' return found' '' '' 'if \"after\" in sys.argv:' ' for d in devices:' ' d.update(fixes.get(d[\"name\"], {}))' 'failing = 0' 'for d in devices:' ' found = fails(d)' ' name = d[\"name\"]' ' failing += 1 if found else 0' ' print(f\"{name:<14}\", \", \".join(found) or \"pass\")' > steps/ce.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the five-area check, part 2
docker exec jupyter sh -c "printf '%s\n' 'print(\"devices that fail:\", failing, \"of\", len(devices))' 'print(\"ready to apply:\", \"yes\" if failing == 0 else \"no\")' >> steps/ce.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Check the devices
docker exec jupyter python3 steps/ce.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsFix, then check again
The owner installs the late update and replaces the old laptop. She changes the router password, adds anti-malware to the till and switches on the print server's firewall.
Run the check with after to apply those fixes.
Check after the fixes
docker exec jupyter python3 steps/ce.py afterShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think Cyber Essentials is about software you buy. The till still fails because the shop manager signs in as an administrator every day. The fix is a separate everyday account, which costs nothing. Most failures are habits and settings.
Assignment: are we ready?
Each device is a dictionary with "firewall", "default_password", "supported", "daily_admin", "malware" and "patches". A patch is (cvss, days since release, installed).
late_patches(patches) returns the late ones. fails(device) returns the failed areas in the order of the lesson's table. ready(devices) is True when nothing fails.
def late_patches(patches):
# Each patch is (cvss, days since release, installed). Return those rated 7 or more,
# released over 14 days ago and not installed.
return []
def fails(device):
# The areas this device fails, in this order: "firewalls", "secure configuration",
# "security updates", "user access", "malware protection".
return []
def ready(devices):
# True when no device fails any area.
return False
Make a free account to save your work and track your progress.
Exit quiz
Have a go