lesson_guard_data.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. # SPDX-License-Identifier: Apache-2.0
  2. """Data for tests/test_lesson_guards.py (issue #525): the shared defaults, then one entry per lesson page.
  3. An entry is {"config": {...}, "rows": [...]}. Both are optional: a page with no entry gets the defaults only.
  4. config keys (all optional):
  5. status_words EXACT list of words a claims register status cell may contain. It replaces the shared
  6. vocabulary, so use it where the old per-lesson file had a narrower set.
  7. status_extra words added to the shared vocabulary for one page (a status the page really uses).
  8. addresses_allow EXACT list of address regexes the page may contain. It replaces the shared defaults.
  9. addresses_extra address-shaped strings added to the shared defaults (a version number, a documented lab net).
  10. addresses_require addresses that must appear (so the address guard cannot go vacuous).
  11. min_register_rows, min_links, min_glossary_rows thresholds; 0 glossary rows means the page has no glossary terms.
  12. nav_contains text the page's _nav.yaml line must carry (its status and subgroup).
  13. nav_places_skip navigation files that do not list the page, with the reason in a comment.
  14. unrun_marks_extra extra words that count as the page's mark for what was not run (the page names its own).
  15. must_link, must_link_prefix pages (or page-name prefixes) the lesson must link, as links, never as plain text.
  16. A row is {"id", ...assertions}; the assertion keys are documented on `check_row` in test_lesson_guards.py. A row with
  17. "start"/"end" looks only at the text between those two strings.
  18. """
  19. DEFAULTS = {
  20. "status_words": ("Read", "Observed", "Run", "General knowledge", "**est.**", "Not read", "Not run", "Not verified", "Constructed", "Secondary", "Page read", "Search summary"),
  21. # documented placeholder ranges (RFC 5737), loopback, the unspecified address and the cloud metadata address
  22. "addresses_default": (r"192\.0\.2\.\d+", r"198\.51\.100\.\d+", r"203\.0\.113\.\d+", r"127\.\d+\.\d+\.\d+", r"0\.0\.0\.0", r"169\.254\.169\.254"),
  23. "min_register_rows": 1,
  24. "min_links": 1,
  25. "min_glossary_rows": 1,
  26. }
  27. # Pages whose _nav.yaml entry carries a `status` but that have no `## Claims register`: the cloud-provider pages, the
  28. # telemetry pages and a few runbooks. They are not lessons of this form, so the discovery rule leaves them out. The
  29. # list is explicit so that a lesson which LOSES its register is a named failure and not a silent drop from the suite.
  30. NO_REGISTER = (
  31. "Build-Your-Own-Mini-SOC",
  32. "Cloud-Telemetry-What-and-Why",
  33. "DMZ-Hardening-Checklist",
  34. "Detection-and-Monitoring-Wazuh-and-the-Landscape",
  35. "Multiple-Sites-and-Identity",
  36. "Provider-AWS-Account-Preparation",
  37. "Provider-AWS-Cost-Lesson",
  38. "Provider-AWS-The-Same-Four-Pieces",
  39. "Provider-Azure-Account-Preparation",
  40. "Provider-Azure-Cost-Lesson",
  41. "Provider-Azure-The-Same-Four-Pieces",
  42. "Provider-GCP-Account-Preparation",
  43. "Provider-GCP-Cost-Lesson",
  44. "Provider-GCP-The-Same-Four-Pieces",
  45. "Reading-a-Dashboard-as-an-Operator",
  46. "Stage-2-Home-Side-Runbook",
  47. "Telemetry-Crosses-the-Trust-Boundary",
  48. "Why-Not-Private-Droplets-Yet",
  49. "Why-the-Clouds-Differ",
  50. )
  51. VM = "Virtual-Machines-Hypervisors-Desktop-and-Datacenter-Options"
  52. CRON = "Cron-Systemd-Timers-and-Init-Scripts-vs-Systemd"
  53. ANSIBLE = "Ansible-Configuration-Management-Versus-Provisioning"
  54. DFIR = "DFIR-Toolkits-and-Live-Triage-SIFT-Velociraptor-KAPE-and-the-Incident-Response-Workflow"
  55. DISK_ENC = "Disk-and-File-Encryption-VeraCrypt-TrueCrypt-History-BitLocker-FileVault-and-LUKS"
  56. DISK_FOR = "Disk-Forensics-with-Autopsy-and-The-Sleuth-Kit"
  57. HSM = "Hardware-Security-Modules-What-They-Are-and-Building-Your-Own-with-pico2hsm"
  58. MEMORY = "Memory-Forensics-Acquiring-RAM-and-Analyzing-It-with-Volatility-3"
  59. NETLOG = "Network-Log-and-Timeline-Forensics-Packet-Captures-Logs-and-Plaso"
  60. FIRMWARE = "Open-Firmware-and-Trustworthy-Hardware-coreboot-Heads-Nitrokey-and-Vendors-That-Ship-the-Intel-ME-Disabled"
  61. DRAFT = 'status: "draft"'
  62. FORENSICS = 'subgroup: "Digital forensics"'
  63. BRIDGE_FORBID = r"-(nic|netdev|net)\s+(bridge|tap)|\bbridge=|--network\s+bridged|nic\d?\s+bridged"
  64. PAGES: dict[str, dict] = {
  65. # ---- pages that have no per-lesson file: the generic checks, plus the statuses they really use ----------------
  66. "Attack-Surface-List-Shrink-Measure": {"config": {"status_extra": ("Searched", "est."), "unrun_marks_extra": ("est.",), "min_glossary_rows": 0}},
  67. "Attack-Surface-Map-Layer-by-Layer": {"config": {"unrun_marks_extra": ("not tested on a real droplet",), "status_extra": ("Carried over",), "min_glossary_rows": 0}},
  68. "Cryptography-Fundamentals-Symmetric-Asymmetric-Hashing-Certificates-and-Keys": {"config": {"status_extra": ("Listing read", "Title and header read")}},
  69. "Deception-and-Honeypots-Cloud-Cowrie-Weekend": {"config": {"status_extra": ("The ISC's claim",), "min_glossary_rows": 0}},
  70. # the Reading-Order page lists the cloud-sensor path of the deception lessons, not this introduction
  71. "Deception-and-Honeypots-What-Deception-Is": {"config": {"nav_places_skip": ("Reading-Order.md",)}},
  72. "Environments-and-Promotion-Dev-Staging-Production": {"config": {"status_extra": ("**Not designed**",)}},
  73. "Grafana-Basics-From-a-Blank-Page": {"config": {"status_extra": ("Written from reading",)}},
  74. "Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV": {"config": {"status_extra": ("My opinion",)}},
  75. "Kubernetes-for-Beginners-What-It-Adds-Over-Docker-and-Compose": {"config": {"status_extra": ("Quoted from", "Repeated from")}},
  76. "Linux-for-Enterprise-Beginners": {"config": {"status_extra": ("Matches the vendor pages", "Not re-verified")}},
  77. "Privacy-vs-Security-Blinds-and-Locks-Physical-Security-and-Monero": {"config": {"status_extra": ("Nothing run",)}},
  78. "Radio-Off-Grid-Communication-LoRa-Meshtastic-Reticulum-Ham-and-SIGINT": {"config": {"status_extra": ("Stated by the maintainer",)}},
  79. "Static-vs-Dynamic-Sites-Hugo-and-WordPress-and-Recon": {"config": {"status_extra": ("**Est.**", "His words", "**Unverified.**")}},
  80. "The-DMZ-and-Hardening-a-Host-That-Faces-the-Internet": {"config": {"unrun_marks_extra": ("**unverified**",), "status_extra": ("Recommendation", "Interpretation")}},
  81. "Wazuh-SIEM-and-Data-Pipelines": {"config": {"status_extra": ("**UNVERIFIED**",)}},
  82. # version numbers and lab networks that look like addresses
  83. "Hands-On-Whonix-and-Qubes-OS-Gateway-Split-Compartments-Disposables-and-Policy-Prompts": {"config": {"addresses_extra": (r"10\.152\.152\.\d+", r"18\.2\.4\.2", r"255\.255\.192\.0")}},
  84. "How-I2P-Works-Tunnels-Garlic-Routing-and-the-Network-Database": {"config": {"addresses_extra": (r"0\.9\.7\.1",)}},
  85. "Lab-Publish-a-Web-Server-as-a-Tor-Onion-Service-and-an-I2P-Site-Time-Boxed-and-Defensive": {"config": {"addresses_extra": (r"0\.4\.8\.10", r"0\.4\.9\.14")}},
  86. "Wallets-and-Key-Custody-Hot-and-Cold-Hardware-Wallets-Recovery-Shamir-and-Multisig": {"config": {"addresses_extra": (r"1\.14\.1\.0",)}},
  87. # ---- Ansible ------------------------------------------------------------------------------------------------
  88. ANSIBLE: {
  89. "config": {
  90. "status_words": ("Read", "Observed", "**est.**"),
  91. "addresses_allow": (r"127\.0\.0\.1",),
  92. "min_register_rows": 20,
  93. "min_links": 8,
  94. "min_glossary_rows": 5,
  95. "nav_contains": (DRAFT,),
  96. },
  97. "rows": [
  98. {"id": "banner", "startswith": "# Ansible: configuration management versus provisioning", "contains": ["Status: unverified draft", "2026-11-07", "**Not run:**", "ansible-core 2.22.0"]},
  99. {
  100. "id": "lab-commands-stay-on-the-local-machine",
  101. "code": {
  102. "tags": ["bash", "ini"],
  103. "require": ["ansible_connection=local", "ansible-playbook"],
  104. "forbid": r"\bansible_host=|\bansible_ssh_|\bssh\s+\S+@",
  105. "bite_bad": ["web ansible_host=203.0.113.9", "ssh admin@box"],
  106. "bite_good": ["localhost ansible_connection=local"],
  107. },
  108. },
  109. {"id": "check-mode-before-the-real-repair-run", "start": "### Exercise 4", "end": "### Exercise 5", "order_before_last": [("--check --diff", "ansible-playbook -i inventory.ini site.yml\n")]},
  110. {"id": "unverified-claims-are-marked-in-the-body", "count_at_least": {"est.": 10}},
  111. # test_ansible_playbook_is_idempotent_and_the_bad_task_is_not (needs ansible-playbook) stays code in the suite
  112. ],
  113. },
  114. # ---- Cron, timers, init scripts -----------------------------------------------------------------------------------
  115. CRON: {
  116. "config": {
  117. "status_words": ("Read", "Run", "Observed", "**est.**", "Statement of opinion"),
  118. "addresses_allow": (),
  119. "min_register_rows": 15,
  120. "min_links": 5,
  121. "min_glossary_rows": 7,
  122. "nav_contains": (DRAFT,),
  123. },
  124. "rows": [
  125. {"id": "banner", "startswith": "# Cron, systemd timers, and init scripts versus systemd", "contains": ["Status: unverified draft", "I did not start a timer", "did not edit a crontab", "2026-11-07", "Not verified, plainly"]},
  126. {"id": "lessons-that-mention-cron-link-this-one", "inbound_all": ["Terminal-and-Your-First-Script", "Linux-for-Enterprise-Beginners", "First-Hour-on-a-New-System-Updates-and-Baseline"]},
  127. {
  128. "id": "translation-table-weekly-and-the-day-rule",
  129. "contains": ["`weekly` means Monday at midnight in systemd", "`@weekly` | `Sun *-*-* 00:00`"],
  130. "contains_any": ["the 1st and 15th **or** Fridays", "the 1st and 15th **and** on every Friday"],
  131. },
  132. {
  133. "id": "distro-table-dated-and-unread-edges-marked",
  134. "start": "## Is cron still installed? What I checked",
  135. "end": "## Init scripts versus systemd",
  136. "contains": ["2026-11-07", "Debian", "Ubuntu", "Rocky", "Fedora", "Arch", "openSUSE"],
  137. "count_at_least": {"**est.**": 4},
  138. },
  139. {
  140. "id": "exercises-never-use-crontab-r",
  141. "contains": ["crontab -r"], # the warning about it must stay in the page
  142. "code": {"tags": ["bash"], "require": ["crontab"], "forbid": r"crontab -r", "bite_bad": ["crontab -r"], "bite_good": ["crontab -l"]},
  143. },
  144. ],
  145. },
  146. # ---- DFIR toolkits ----------------------------------------------------------------------------------------------
  147. DFIR: {
  148. "config": {
  149. "status_words": ("Read", "Run", "Page read", "**est.**"),
  150. "addresses_allow": (),
  151. "min_register_rows": 20,
  152. "min_links": 8,
  153. "min_glossary_rows": 5,
  154. "nav_contains": (DRAFT, FORENSICS),
  155. "must_link": ("Build-Your-Own-Mini-SOC", "Logs-SIEM-and-Detection-Basics", "Backups-Recovery-and-Patching", "Careers-Roles-and-What-to-Learn-Next"),
  156. },
  157. "rows": [
  158. {"id": "banner", "startswith": "# DFIR toolkits and live triage", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
  159. {
  160. "id": "toolkit-table-names-every-tool-and-closed-ones-are-marked",
  161. "start": "## The toolkits at a glance",
  162. "end": "## Live triage and dead-box imaging",
  163. "contains": ["SIFT Workstation", "CAINE", "Velociraptor", "KAPE", "FTK Imager", "plaso", "AGPL-3.0", "Apache-2.0", "2026-11-07"],
  164. "count_at_least": {"**not open source**": 2},
  165. },
  166. {
  167. "id": "nist-account-names-both-revisions",
  168. "start": "## An incident response workflow, and where forensics fits",
  169. "end": "## Mobile and cloud forensics",
  170. "contains_ci": ["Revision 2", "Revision 3", "April 2025", "Govern", "lessons learned"],
  171. },
  172. {
  173. "id": "certifications-carry-no-prices-and-no-affiliate-links",
  174. "start": "## Training and certifications",
  175. "end": "## Free exercise",
  176. "regex_absent": [r"[$€£]\s?\d|\bUSD\b"],
  177. "absent": ["http", "ref="],
  178. "contains": ["GCFE", "GCFA"],
  179. },
  180. {
  181. "id": "exercise-collects-only-into-the-learners-folder",
  182. "code": {
  183. "tags": ["bash"],
  184. "require": ["collect.sh", "sha256sum -c", "mkdir -p ~/triage-lab"],
  185. "forbid": r"crontab -r|sudo rm|>\s*/(etc|usr|var|bin)/",
  186. "bite_bad": ["crontab -r", "sudo rm -rf x", "echo x > /etc/passwd"],
  187. "bite_good": ["echo x > ~/triage-lab/out"],
  188. },
  189. },
  190. ],
  191. },
  192. # ---- Disk and file encryption --------------------------------------------------------------------------------------
  193. DISK_ENC: {
  194. "config": {
  195. "status_words": ("Read", "Observed", "**est.**"),
  196. "addresses_allow": (),
  197. "min_register_rows": 20,
  198. "min_links": 8,
  199. "min_glossary_rows": 10,
  200. "nav_contains": (DRAFT,),
  201. },
  202. "rows": [
  203. {"id": "banner", "startswith": "# Disk and file encryption", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
  204. {"id": "not-run-list-names-the-untried-features", "start": "**Not run:**", "end": "Vendor and project statements", "contains": ["a hidden volume", "a keyfile", "BitLocker", "FileVault"]},
  205. {"id": "no-unfinished-placeholder", "absent": ["RESULTS_", "TODO", "@@"]},
  206. {
  207. "id": "every-password-in-a-command-is-a-labeled-placeholder",
  208. "contains": ["Never type a password you use anywhere real"],
  209. "code": {
  210. "tags": ["bash"],
  211. # a literal password handed to the tool (-p 'x', --new-password='x', PW='x') that is not marked PLACEHOLDER
  212. "forbid": r"(?:\s-p\s+|--new-password=|\bPW=)'(?![^']*PLACEHOLDER)[^']*'",
  213. "count_at_least": {r"(?:\s-p\s+|--new-password=|\bPW=)'[^']*'": 4},
  214. "bite_bad": ["veracrypt -C x -p 'hunter2'"],
  215. "bite_good": ["veracrypt -C x -p 'Wrong-PLACEHOLDER-2'"],
  216. },
  217. },
  218. {
  219. "id": "truecrypt-history-dated-and-quotes-the-notice",
  220. "start": "## From TrueCrypt to VeraCrypt: a dated history",
  221. "end": "## Where it fits",
  222. "contains": [
  223. "2014-04-14", "2014-05-28", "2014-09-04", "2014-12-30", "2015-04-02", "2015-08-05", "2016-10-17", "2023-10-01", "2026-06-09",
  224. "WARNING: Using TrueCrypt is not secure as it may contain unfixed security issues",
  225. "two High, none Medium, one Low, one Undetermined",
  226. "8 critical, 3 medium and 15 low",
  227. "(secondary)",
  228. ],
  229. },
  230. {
  231. "id": "hidden-volumes-with-their-honest-limits",
  232. "start": "### Hidden volumes and plausible deniability, with the limits",
  233. "end": "### Use across",
  234. "contains": ["several points over time", "wear-leveling", "TRIM", "1.18a", "must recreate both the outer and hidden volumes", "legal"],
  235. },
  236. {"id": "platform-tools-and-comparison", "start": "## Full-disk encryption by platform", "end": "## Three layers", "contains": ["BitLocker", "FileVault", "LUKS", "XTS", "recovery key", "TPM"]},
  237. {"id": "defaults-quoted-match-the-documentation", "contains": ["500,000 iterations", "200,000", "416 MiB", "6 passes"]},
  238. ],
  239. },
  240. # ---- Disk forensics ---------------------------------------------------------------------------------------------
  241. DISK_FOR: {
  242. "config": {
  243. "status_words": ("Read", "Observed", "Search summary only", "**est.**"),
  244. "addresses_allow": (),
  245. "min_register_rows": 25,
  246. "min_glossary_rows": 4,
  247. "nav_contains": (DRAFT, FORENSICS),
  248. "must_link": ("Hashing-Encryption-and-Keys", VM, "Terminal-and-Your-First-Script"),
  249. # the siblings are on main: each is a link to a page that exists (it was plain text before)
  250. "must_link_prefix": ("Digital-Forensics-Foundations", "Memory-Forensics", "Network-Log-and-Timeline-Forensics", "DFIR-Toolkits"),
  251. },
  252. "rows": [
  253. {"id": "banner", "startswith": "# Disk forensics with Autopsy and The Sleuth Kit", "contains": ["Status: unverified draft", "Autopsy itself was not installed or started", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
  254. {
  255. "id": "authorization-rule-is-stated-up-front",
  256. "order": [("Examine only your own devices or data you are explicitly authorized to examine", "## What you will be able to do")],
  257. "contains": ["not legal advice"],
  258. },
  259. {
  260. "id": "hash-step-before-the-examination-commands",
  261. "order": [("sha256sum lab.dd > lab.dd.sha256", "mmls lab.dd\n fsstat")],
  262. "regex_present": [r"`[0-9a-f]{64}`|[0-9a-f]{64} lab\.dd"],
  263. },
  264. {"id": "versions-and-licenses-are-dated", "contains": ["4.23.1", "4.15.0", "2026-05-07", "2026-04-15", "Apache License", "Common Public License", "October 2023"]},
  265. ],
  266. },
  267. # ---- Hardware security modules ----------------------------------------------------------------------------------------
  268. HSM: {
  269. "config": {
  270. "status_words": ("Read", "Observed", "General knowledge", "**est.**"),
  271. "min_register_rows": 20,
  272. "min_links": 6,
  273. "min_glossary_rows": 5,
  274. "nav_contains": (DRAFT,),
  275. },
  276. "rows": [
  277. {"id": "banner", "startswith": "# Hardware security modules", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "no Pico 2 was available"]},
  278. {"id": "part-b-is-marked-untested", "contains": ["Part B: the same on a Pico 2 (UNTESTED)", "**Untested.**"]},
  279. {"id": "maintainer-checks-exist", "start": "## For the maintainer: checks to run when you build it", "end": "## Checkpoint", "numbered_items_min": 10},
  280. # the three values the project's own docs publish as sample PINs
  281. {"id": "no-published-sample-pins", "absent": ["648219", "3537363231383830", "57621880"]},
  282. {"id": "projects-own-limits-are-quoted", "contains": ["not a certified secure element", "Never deploy either: the development storage key is public.", "A4", "RP2350-E24"]},
  283. # test_hsm_part_a_signs_verifies_and_fails_on_a_changed_message (needs openssl) stays code in the suite
  284. ],
  285. },
  286. # ---- Memory forensics ------------------------------------------------------------------------------------------------
  287. MEMORY: {
  288. "config": {
  289. "status_words": ("Read", "Observed", "General knowledge", "**est.**"),
  290. "addresses_allow": (r"127\.0\.0\.1",),
  291. "addresses_require": ("127.0.0.1",),
  292. "min_register_rows": 20,
  293. "min_links": 4,
  294. "min_glossary_rows": 4,
  295. "nav_contains": (DRAFT, FORENSICS),
  296. # the siblings are on main now: each is a link to a page that exists (they were plain text before)
  297. "must_link_prefix": ("Digital-Forensics-Foundations", "Disk-Forensics", "Network-Log-and-Timeline-Forensics", "DFIR-Toolkits", "Device-Firmware-Security", "Open-Firmware"),
  298. },
  299. "rows": [
  300. {"id": "banner", "startswith": "# Memory forensics: acquiring RAM", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Volatility 3 2.28.2"]},
  301. {"id": "callsign-and-machine-names-are-placeholders", "contains": ["N0TST", r"local-hostname: lab\n"]},
  302. {
  303. "id": "guest-never-bridged-onto-a-real-network",
  304. "code": {
  305. "tags": ["bash"],
  306. "require": ["-nic user", "hostfwd=tcp:127.0.0.1"],
  307. "forbid": r"-(nic|netdev|net)\s+(bridge|tap)|\bbridge=",
  308. "bite_bad": ["qemu-system-x86_64 -nic bridge,br=br0"],
  309. "bite_good": ["qemu-system-x86_64 -nic user,model=virtio-net-pci"],
  310. },
  311. },
  312. {"id": "checksum-before-first-boot", "order": [("sha512sum -c sums", "qemu-system-x86_64 -accel kvm")], "contains": ["do not boot the image"]},
  313. {"id": "license-and-version-dated", "contains": ["Volatility Software License, Version 1.0", "2.28.2", "2026-09-17"]},
  314. {"id": "plugins-it-ran", "contains": ["linux.pslist.PsList", "linux.psscan.PsScan", "linux.sockstat.Sockstat", "linux.malware.malfind.Malfind", "windows.psscan.PsScan", "windows.netscan.NetScan"]},
  315. ],
  316. },
  317. # ---- Network, log and timeline forensics -------------------------------------------------------------------------------
  318. NETLOG: {
  319. "config": {
  320. "status_words": ("Read", "Run", "Observed", "**est.**"),
  321. "addresses_allow": (r"10\.89\.0\.\d{1,3}", r"0\.0\.0\.0"), # the lab container network
  322. "min_register_rows": 15,
  323. "min_links": 6,
  324. "min_glossary_rows": 5,
  325. "nav_contains": (DRAFT, FORENSICS),
  326. },
  327. "rows": [
  328. {"id": "banner", "startswith": "# Network, log and timeline forensics", "contains": ["Status: unverified draft", "2026-11-07", "Not verified, plainly", "What I ran and what failed"]},
  329. {"id": "in-page-anchors-were-collected", "regex_count_at_least": {r"\]\(#[a-z0-9-]+\)": 1}},
  330. {"id": "invented-lab-password-is-marked-invented", "contains": ["hunter2-lab", "invented"]},
  331. {"id": "time-zone-lesson-names-both-runs-and-the-offset", "contains": ["--timezone America/New_York", "2026-11-07T10:49:52+00:00", "2026-11-07T15:49:52+00:00", "7 minutes 2 seconds"]},
  332. {"id": "plaso-facts-dated-with-real-parser-names", "contains": ["20261027", "Apache-2.0", "text/apache_access", "text/syslog_traditional"]},
  333. {"id": "law-section-and-own-network-only", "contains": ["not legal advice"], "contains_any": ["own computer", "container network you create"]},
  334. ],
  335. },
  336. # ---- Open firmware -------------------------------------------------------------------------------------------------
  337. FIRMWARE: {
  338. "config": {
  339. "status_words": ("Read", "Observed", "General knowledge", "**est.**", "**not verified**"),
  340. "addresses_allow": (),
  341. "min_register_rows": 35,
  342. "min_links": 5,
  343. "min_glossary_rows": 6,
  344. "nav_contains": (DRAFT,),
  345. },
  346. "rows": [
  347. {"id": "banner", "startswith": "# Open firmware and trustworthy hardware", "contains": ["> **Status: unverified draft.", "Nothing was flashed", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
  348. {"id": "no-en-dash", "absent": ["–"]},
  349. {"id": "no-affiliate-links", "urls_min": 20, "url_forbid": r"[?&](ref|aff|affiliate|utm_[a-z]+|tag|partner)="},
  350. {
  351. "id": "no-flashing-or-write-commands-in-any-code-block",
  352. "code": {
  353. "require": ["curl", "fwupdmgr"],
  354. "forbid": r"\bsudo\b|\bflashrom\b|\bifdtool\b|\bme_cleaner\b|\bnvramtool\b|\bdd\b|\bchmod\b|>\s*/(?:sys|dev|boot)",
  355. "ignorecase": True,
  356. "bite_bad": ["sudo flashrom -p internal -w rom.bin", "python me_cleaner.py -S image.bin", "echo 1 > /sys/class/x"],
  357. "bite_good": ["cat /sys/class/tpm/tpm0/tpm_version_major"],
  358. },
  359. },
  360. {
  361. "id": "each-vendor-has-a-firmware-and-an-me-line",
  362. "vendor_sections": {
  363. "Novacustom": ["Firmware", "ME"],
  364. "System76": ["Firmware", "ME"],
  365. "Purism": ["Firmware", "ME"],
  366. "Tuxedo": ["ME"],
  367. "Tuxedo Computers": ["I could not verify a claim"],
  368. },
  369. },
  370. {"id": "me-words-and-dasharo-modes-are-named", "contains": ["**Absent**", "**Neutralized**", "**Soft-disabled**", "**HAP-disabled**", "Enabled", "Disabled (Soft)", "Disabled (HAP)"]},
  371. {"id": "register-is-dated", "count_at_least": {"2026-11-07": 8}},
  372. {"id": "register-names-every-vendor", "start": "## Claims register", "contains": ["Novacustom", "System76", "Purism", "Tuxedo"]},
  373. {"id": "heads-key-table-matches-the-prerequisites-wording", "contains": ["Heads does NOT support FIDO2 or U2F", "OpenPGP only", "YubiKey 5 Series", "Nitrokey Pro 2", "Nitrokey Storage 2", "Nitrokey 3", "Librem Key"]},
  374. {
  375. "id": "page-ends-by-linking-the-firmware-and-hardware-keys-lessons",
  376. "start": "## Where this goes next",
  377. "links_in_scope": ["Device-Firmware-Security-Intel-ME-AMD-PSP-MINIX-and-Kernel-Design", "Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV"],
  378. "absent": ["no link"],
  379. },
  380. {"id": "no-unwritten-page-wording", "absent": ["not written yet"], "contains": ["Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV.md"]},
  381. {
  382. "id": "tuxedo-is-a-dated-user-selectable-option-on-one-model",
  383. "vendor_sections": {"Tuxedo Computers": ["2018-03-14", "InfinityBook Pro 13", "TUXEDO-disables-Intels-Management-Engine.tuxedo"]},
  384. },
  385. {
  386. "id": "tuxedo-wording-pin",
  387. "absent": ["Ask Tuxedo in writing"],
  388. "absent_except": [("ships with the ME disabled", 'not "ships with the ME disabled"')],
  389. "register_row": {"select": ["press release", "Tuxedo"], "first_has": ["2018-03-14"], "second_has": ["TUXEDO-disables"]},
  390. },
  391. ],
  392. },
  393. # ---- Virtual machines and hypervisors -------------------------------------------------------------------------------------
  394. VM: {
  395. "config": {
  396. "status_words": ("Read", "Observed", "Page read", "General knowledge", "**est.**"),
  397. "addresses_allow": (r"127\.0\.0\.1",),
  398. "addresses_require": ("127.0.0.1",),
  399. "min_register_rows": 25,
  400. "min_links": 8,
  401. "min_glossary_rows": 5,
  402. "nav_contains": (DRAFT,),
  403. },
  404. "rows": [
  405. {"id": "banner", "startswith": "# Virtual machines for beginners", "contains": ["Status: unverified draft", "no hypervisor was installed and no guest was booted", "**Not run:**", "2026-10-31", "Not verified, plainly"]},
  406. {"id": "pages-that-assume-a-vm-link-the-lesson", "inbound_min": 4},
  407. {
  408. "id": "lab-commands-never-bridge-the-guest-onto-a-real-network",
  409. "code": {
  410. "tags": ["bash"],
  411. "require": ["qemu-system-x86_64", "-nic user"],
  412. "forbid": BRIDGE_FORBID,
  413. "bite_bad": ["qemu-system-x86_64 -nic bridge,br=br0", "qemu-system-x86_64 -netdev tap,id=n0"],
  414. "bite_good": ["qemu-system-x86_64 -nic user,model=virtio-net-pci"],
  415. },
  416. },
  417. {
  418. "id": "safety-rule-names-the-three-core-steps",
  419. "start": "## The safety rule for malware and recon labs",
  420. "end": "## Free path",
  421. "contains": ["Isolate the network first", "Snapshot a clean state first", "Never bridge a hostile VM onto your home LAN"],
  422. },
  423. {"id": "checksum-before-first-boot", "order": [("sha256sum -c", "qemu-system-x86_64 -accel kvm")], "contains": ["do not boot an image that fails its check"], "regex_present": [r"`[0-9a-f]{64}`"]},
  424. {
  425. "id": "vmware-account-dated-with-vendor-and-news-sources",
  426. "start": "## VMware after Broadcom: a dated account",
  427. "end": "## The bigger options",
  428. "contains": ["2023-11-22", "2023-12-11", "May 2024", "2024-11-11", "2025-03-10", "2025-04-10", "BBC News", "Ars Technica", "release notes", "**est.**", "Read"],
  429. "contains_ci": ["not verified"],
  430. },
  431. {"id": "apple-options-from-apples-own-pages", "contains": ["Virtualization framework", "macOS 11.0", "`container`", "macOS 26"]},
  432. # test_vm_exercise_3_runs_and_the_snapshot_round_trips (needs qemu-img) stays code in the suite
  433. ],
  434. },
  435. }