lesson_guard_data.py 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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 docs/wiki/_nav/ 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 docs/wiki/_nav/ 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. "Choosing-a-Container-Engine-Docker-Podman-Kubernetes-Portainer-Cockpit": {"config": {"status_extra": ("Stated by the maintainer",)}},
  77. "Self-Hosting-AI-Ollama-FrankenLLM-vLLM-and-the-GPU-Stack-PyTorch-CUDA-ROCm-and-Intel": {"config": {"status_extra": ("Repeated from",), "min_glossary_rows": 8}},
  78. "Linux-for-Enterprise-Beginners": {"config": {"status_extra": ("Matches the vendor pages", "Not re-verified")}},
  79. "Privacy-vs-Security-Blinds-and-Locks-Physical-Security-and-Monero": {"config": {"status_extra": ("Nothing run",)}},
  80. "Radio-Off-Grid-Communication-LoRa-Meshtastic-Reticulum-Ham-and-SIGINT": {"config": {"status_extra": ("Stated by the maintainer",)}},
  81. "Static-vs-Dynamic-Sites-Hugo-and-WordPress-and-Recon": {"config": {"status_extra": ("**Est.**", "His words", "**Unverified.**")}},
  82. "The-DMZ-and-Hardening-a-Host-That-Faces-the-Internet": {"config": {"unrun_marks_extra": ("**unverified**",), "status_extra": ("Recommendation", "Interpretation")}},
  83. "Wazuh-SIEM-and-Data-Pipelines": {"config": {"status_extra": ("**UNVERIFIED**",)}},
  84. # version numbers and lab networks that look like addresses
  85. "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")}},
  86. "How-I2P-Works-Tunnels-Garlic-Routing-and-the-Network-Database": {"config": {"addresses_extra": (r"0\.9\.7\.1",)}},
  87. "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")}},
  88. "Wallets-and-Key-Custody-Hot-and-Cold-Hardware-Wallets-Recovery-Shamir-and-Multisig": {"config": {"addresses_extra": (r"1\.14\.1\.0",)}},
  89. # ---- Ansible ------------------------------------------------------------------------------------------------
  90. ANSIBLE: {
  91. "config": {
  92. "status_words": ("Read", "Observed", "**est.**"),
  93. "addresses_allow": (r"127\.0\.0\.1",),
  94. "min_register_rows": 20,
  95. "min_links": 8,
  96. "min_glossary_rows": 5,
  97. "nav_contains": (DRAFT,),
  98. },
  99. "rows": [
  100. {"id": "banner", "startswith": "# Ansible: configuration management versus provisioning", "contains": ["Status: unverified draft", "2026-11-07", "**Not run:**", "ansible-core 2.22.0"]},
  101. {
  102. "id": "lab-commands-stay-on-the-local-machine",
  103. "code": {
  104. "tags": ["bash", "ini"],
  105. "require": ["ansible_connection=local", "ansible-playbook"],
  106. "forbid": r"\bansible_host=|\bansible_ssh_|\bssh\s+\S+@",
  107. "bite_bad": ["web ansible_host=203.0.113.9", "ssh admin@box"],
  108. "bite_good": ["localhost ansible_connection=local"],
  109. },
  110. },
  111. {"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")]},
  112. {"id": "unverified-claims-are-marked-in-the-body", "count_at_least": {"est.": 10}},
  113. # test_ansible_playbook_is_idempotent_and_the_bad_task_is_not (needs ansible-playbook) stays code in the suite
  114. ],
  115. },
  116. # ---- Cron, timers, init scripts -----------------------------------------------------------------------------------
  117. CRON: {
  118. "config": {
  119. "status_words": ("Read", "Run", "Observed", "**est.**", "Statement of opinion"),
  120. "addresses_allow": (),
  121. "min_register_rows": 15,
  122. "min_links": 5,
  123. "min_glossary_rows": 7,
  124. "nav_contains": (DRAFT,),
  125. },
  126. "rows": [
  127. {"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"]},
  128. {"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"]},
  129. {
  130. "id": "translation-table-weekly-and-the-day-rule",
  131. "contains": ["`weekly` means Monday at midnight in systemd", "`@weekly` | `Sun *-*-* 00:00`"],
  132. "contains_any": ["the 1st and 15th **or** Fridays", "the 1st and 15th **and** on every Friday"],
  133. },
  134. {
  135. "id": "distro-table-dated-and-unread-edges-marked",
  136. "start": "## Is cron still installed? What I checked",
  137. "end": "## Init scripts versus systemd",
  138. "contains": ["2026-11-07", "Debian", "Ubuntu", "Rocky", "Fedora", "Arch", "openSUSE"],
  139. "count_at_least": {"**est.**": 4},
  140. },
  141. {
  142. "id": "exercises-never-use-crontab-r",
  143. "contains": ["crontab -r"], # the warning about it must stay in the page
  144. "code": {"tags": ["bash"], "require": ["crontab"], "forbid": r"crontab -r", "bite_bad": ["crontab -r"], "bite_good": ["crontab -l"]},
  145. },
  146. ],
  147. },
  148. # ---- DFIR toolkits ----------------------------------------------------------------------------------------------
  149. DFIR: {
  150. "config": {
  151. "status_words": ("Read", "Run", "Page read", "**est.**"),
  152. "addresses_allow": (),
  153. "min_register_rows": 20,
  154. "min_links": 8,
  155. "min_glossary_rows": 5,
  156. "nav_contains": (DRAFT, FORENSICS),
  157. "must_link": ("Build-Your-Own-Mini-SOC", "Logs-SIEM-and-Detection-Basics", "Backups-Recovery-and-Patching", "Careers-Roles-and-What-to-Learn-Next"),
  158. },
  159. "rows": [
  160. {"id": "banner", "startswith": "# DFIR toolkits and live triage", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
  161. {
  162. "id": "toolkit-table-names-every-tool-and-closed-ones-are-marked",
  163. "start": "## The toolkits at a glance",
  164. "end": "## Live triage and dead-box imaging",
  165. "contains": ["SIFT Workstation", "CAINE", "Velociraptor", "KAPE", "FTK Imager", "plaso", "AGPL-3.0", "Apache-2.0", "2026-11-07"],
  166. "count_at_least": {"**not open source**": 2},
  167. },
  168. {
  169. "id": "nist-account-names-both-revisions",
  170. "start": "## An incident response workflow, and where forensics fits",
  171. "end": "## Mobile and cloud forensics",
  172. "contains_ci": ["Revision 2", "Revision 3", "April 2025", "Govern", "lessons learned"],
  173. },
  174. {
  175. "id": "certifications-carry-no-prices-and-no-affiliate-links",
  176. "start": "## Training and certifications",
  177. "end": "## Free exercise",
  178. "regex_absent": [r"[$€£]\s?\d|\bUSD\b"],
  179. "absent": ["http", "ref="],
  180. "contains": ["GCFE", "GCFA"],
  181. },
  182. {
  183. "id": "exercise-collects-only-into-the-learners-folder",
  184. "code": {
  185. "tags": ["bash"],
  186. "require": ["collect.sh", "sha256sum -c", "mkdir -p ~/triage-lab"],
  187. "forbid": r"crontab -r|sudo rm|>\s*/(etc|usr|var|bin)/",
  188. "bite_bad": ["crontab -r", "sudo rm -rf x", "echo x > /etc/passwd"],
  189. "bite_good": ["echo x > ~/triage-lab/out"],
  190. },
  191. },
  192. ],
  193. },
  194. # ---- Disk and file encryption --------------------------------------------------------------------------------------
  195. DISK_ENC: {
  196. "config": {
  197. "status_words": ("Read", "Observed", "**est.**"),
  198. "addresses_allow": (),
  199. "min_register_rows": 20,
  200. "min_links": 8,
  201. "min_glossary_rows": 10,
  202. "nav_contains": (DRAFT,),
  203. },
  204. "rows": [
  205. {"id": "banner", "startswith": "# Disk and file encryption", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
  206. {"id": "not-run-list-names-the-untried-features", "start": "**Not run:**", "end": "Vendor and project statements", "contains": ["a hidden volume", "a keyfile", "BitLocker", "FileVault"]},
  207. {"id": "no-unfinished-placeholder", "absent": ["RESULTS_", "TODO", "@@"]},
  208. {
  209. "id": "every-password-in-a-command-is-a-labeled-placeholder",
  210. "contains": ["Never type a password you use anywhere real"],
  211. "code": {
  212. "tags": ["bash"],
  213. # a literal password handed to the tool (-p 'x', --new-password='x', PW='x') that is not marked PLACEHOLDER
  214. "forbid": r"(?:\s-p\s+|--new-password=|\bPW=)'(?![^']*PLACEHOLDER)[^']*'",
  215. "count_at_least": {r"(?:\s-p\s+|--new-password=|\bPW=)'[^']*'": 4},
  216. "bite_bad": ["veracrypt -C x -p 'hunter2'"],
  217. "bite_good": ["veracrypt -C x -p 'Wrong-PLACEHOLDER-2'"],
  218. },
  219. },
  220. {
  221. "id": "truecrypt-history-dated-and-quotes-the-notice",
  222. "start": "## From TrueCrypt to VeraCrypt: a dated history",
  223. "end": "## Where it fits",
  224. "contains": [
  225. "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",
  226. "WARNING: Using TrueCrypt is not secure as it may contain unfixed security issues",
  227. "two High, none Medium, one Low, one Undetermined",
  228. "8 critical, 3 medium and 15 low",
  229. "(secondary)",
  230. ],
  231. },
  232. {
  233. "id": "hidden-volumes-with-their-honest-limits",
  234. "start": "### Hidden volumes and plausible deniability, with the limits",
  235. "end": "### Use across",
  236. "contains": ["several points over time", "wear-leveling", "TRIM", "1.18a", "must recreate both the outer and hidden volumes", "legal"],
  237. },
  238. {"id": "platform-tools-and-comparison", "start": "## Full-disk encryption by platform", "end": "## Three layers", "contains": ["BitLocker", "FileVault", "LUKS", "XTS", "recovery key", "TPM"]},
  239. {"id": "defaults-quoted-match-the-documentation", "contains": ["500,000 iterations", "200,000", "416 MiB", "6 passes"]},
  240. ],
  241. },
  242. # ---- Disk forensics ---------------------------------------------------------------------------------------------
  243. DISK_FOR: {
  244. "config": {
  245. "status_words": ("Read", "Observed", "Search summary only", "**est.**"),
  246. "addresses_allow": (),
  247. "min_register_rows": 25,
  248. "min_glossary_rows": 4,
  249. "nav_contains": (DRAFT, FORENSICS),
  250. "must_link": ("Hashing-Encryption-and-Keys", VM, "Terminal-and-Your-First-Script"),
  251. # the siblings are on main: each is a link to a page that exists (it was plain text before)
  252. "must_link_prefix": ("Digital-Forensics-Foundations", "Memory-Forensics", "Network-Log-and-Timeline-Forensics", "DFIR-Toolkits"),
  253. },
  254. "rows": [
  255. {"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"]},
  256. {
  257. "id": "authorization-rule-is-stated-up-front",
  258. "order": [("Examine only your own devices or data you are explicitly authorized to examine", "## What you will be able to do")],
  259. "contains": ["not legal advice"],
  260. },
  261. {
  262. "id": "hash-step-before-the-examination-commands",
  263. "order": [("sha256sum lab.dd > lab.dd.sha256", "mmls lab.dd\n fsstat")],
  264. "regex_present": [r"`[0-9a-f]{64}`|[0-9a-f]{64} lab\.dd"],
  265. },
  266. {"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"]},
  267. ],
  268. },
  269. # ---- Hardware security modules ----------------------------------------------------------------------------------------
  270. HSM: {
  271. "config": {
  272. "status_words": ("Read", "Observed", "General knowledge", "**est.**"),
  273. "min_register_rows": 20,
  274. "min_links": 6,
  275. "min_glossary_rows": 5,
  276. "nav_contains": (DRAFT,),
  277. },
  278. "rows": [
  279. {"id": "banner", "startswith": "# Hardware security modules", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "no Pico 2 was available"]},
  280. {"id": "part-b-is-marked-untested", "contains": ["Part B: the same on a Pico 2 (UNTESTED)", "**Untested.**"]},
  281. {"id": "maintainer-checks-exist", "start": "## For the maintainer: checks to run when you build it", "end": "## Checkpoint", "numbered_items_min": 10},
  282. # the three values the project's own docs publish as sample PINs
  283. {"id": "no-published-sample-pins", "absent": ["648219", "3537363231383830", "57621880"]},
  284. {"id": "projects-own-limits-are-quoted", "contains": ["not a certified secure element", "Never deploy either: the development storage key is public.", "A4", "RP2350-E24"]},
  285. # test_hsm_part_a_signs_verifies_and_fails_on_a_changed_message (needs openssl) stays code in the suite
  286. ],
  287. },
  288. # ---- Memory forensics ------------------------------------------------------------------------------------------------
  289. MEMORY: {
  290. "config": {
  291. "status_words": ("Read", "Observed", "General knowledge", "**est.**"),
  292. "addresses_allow": (r"127\.0\.0\.1",),
  293. "addresses_require": ("127.0.0.1",),
  294. "min_register_rows": 20,
  295. "min_links": 4,
  296. "min_glossary_rows": 4,
  297. "nav_contains": (DRAFT, FORENSICS),
  298. # the siblings are on main now: each is a link to a page that exists (they were plain text before)
  299. "must_link_prefix": ("Digital-Forensics-Foundations", "Disk-Forensics", "Network-Log-and-Timeline-Forensics", "DFIR-Toolkits", "Device-Firmware-Security", "Open-Firmware"),
  300. },
  301. "rows": [
  302. {"id": "banner", "startswith": "# Memory forensics: acquiring RAM", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Volatility 3 2.28.2"]},
  303. {"id": "callsign-and-machine-names-are-placeholders", "contains": ["N0TST", r"local-hostname: lab\n"]},
  304. {
  305. "id": "guest-never-bridged-onto-a-real-network",
  306. "code": {
  307. "tags": ["bash"],
  308. "require": ["-nic user", "hostfwd=tcp:127.0.0.1"],
  309. "forbid": r"-(nic|netdev|net)\s+(bridge|tap)|\bbridge=",
  310. "bite_bad": ["qemu-system-x86_64 -nic bridge,br=br0"],
  311. "bite_good": ["qemu-system-x86_64 -nic user,model=virtio-net-pci"],
  312. },
  313. },
  314. {"id": "checksum-before-first-boot", "order": [("sha512sum -c sums", "qemu-system-x86_64 -accel kvm")], "contains": ["do not boot the image"]},
  315. {"id": "license-and-version-dated", "contains": ["Volatility Software License, Version 1.0", "2.28.2", "2026-09-17"]},
  316. {"id": "plugins-it-ran", "contains": ["linux.pslist.PsList", "linux.psscan.PsScan", "linux.sockstat.Sockstat", "linux.malware.malfind.Malfind", "windows.psscan.PsScan", "windows.netscan.NetScan"]},
  317. ],
  318. },
  319. # ---- Network, log and timeline forensics -------------------------------------------------------------------------------
  320. NETLOG: {
  321. "config": {
  322. "status_words": ("Read", "Run", "Observed", "**est.**"),
  323. "addresses_allow": (r"10\.89\.0\.\d{1,3}", r"0\.0\.0\.0"), # the lab container network
  324. "min_register_rows": 15,
  325. "min_links": 6,
  326. "min_glossary_rows": 5,
  327. "nav_contains": (DRAFT, FORENSICS),
  328. },
  329. "rows": [
  330. {"id": "banner", "startswith": "# Network, log and timeline forensics", "contains": ["Status: unverified draft", "2026-11-07", "Not verified, plainly", "What I ran and what failed"]},
  331. {"id": "in-page-anchors-were-collected", "regex_count_at_least": {r"\]\(#[a-z0-9-]+\)": 1}},
  332. {"id": "invented-lab-password-is-marked-invented", "contains": ["hunter2-lab", "invented"]},
  333. {"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"]},
  334. {"id": "plaso-facts-dated-with-real-parser-names", "contains": ["20261027", "Apache-2.0", "text/apache_access", "text/syslog_traditional"]},
  335. {"id": "law-section-and-own-network-only", "contains": ["not legal advice"], "contains_any": ["own computer", "container network you create"]},
  336. ],
  337. },
  338. # ---- Open firmware -------------------------------------------------------------------------------------------------
  339. FIRMWARE: {
  340. "config": {
  341. "status_words": ("Read", "Observed", "General knowledge", "**est.**", "**not verified**"),
  342. "addresses_allow": (),
  343. "min_register_rows": 35,
  344. "min_links": 5,
  345. "min_glossary_rows": 6,
  346. "nav_contains": (DRAFT,),
  347. },
  348. "rows": [
  349. {"id": "banner", "startswith": "# Open firmware and trustworthy hardware", "contains": ["> **Status: unverified draft.", "Nothing was flashed", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
  350. {"id": "no-en-dash", "absent": ["–"]},
  351. {"id": "no-affiliate-links", "urls_min": 20, "url_forbid": r"[?&](ref|aff|affiliate|utm_[a-z]+|tag|partner)="},
  352. {
  353. "id": "no-flashing-or-write-commands-in-any-code-block",
  354. "code": {
  355. "require": ["curl", "fwupdmgr"],
  356. "forbid": r"\bsudo\b|\bflashrom\b|\bifdtool\b|\bme_cleaner\b|\bnvramtool\b|\bdd\b|\bchmod\b|>\s*/(?:sys|dev|boot)",
  357. "ignorecase": True,
  358. "bite_bad": ["sudo flashrom -p internal -w rom.bin", "python me_cleaner.py -S image.bin", "echo 1 > /sys/class/x"],
  359. "bite_good": ["cat /sys/class/tpm/tpm0/tpm_version_major"],
  360. },
  361. },
  362. {
  363. "id": "each-vendor-has-a-firmware-and-an-me-line",
  364. "vendor_sections": {
  365. "Novacustom": ["Firmware", "ME"],
  366. "System76": ["Firmware", "ME"],
  367. "Purism": ["Firmware", "ME"],
  368. "Tuxedo": ["ME"],
  369. "Tuxedo Computers": ["I could not verify a claim"],
  370. },
  371. },
  372. {"id": "me-words-and-dasharo-modes-are-named", "contains": ["**Absent**", "**Neutralized**", "**Soft-disabled**", "**HAP-disabled**", "Enabled", "Disabled (Soft)", "Disabled (HAP)"]},
  373. {"id": "register-is-dated", "count_at_least": {"2026-11-07": 8}},
  374. {"id": "register-names-every-vendor", "start": "## Claims register", "contains": ["Novacustom", "System76", "Purism", "Tuxedo"]},
  375. {"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"]},
  376. {
  377. "id": "page-ends-by-linking-the-firmware-and-hardware-keys-lessons",
  378. "start": "## Where this goes next",
  379. "links_in_scope": ["Device-Firmware-Security-Intel-ME-AMD-PSP-MINIX-and-Kernel-Design", "Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV"],
  380. "absent": ["no link"],
  381. },
  382. {"id": "no-unwritten-page-wording", "absent": ["not written yet"], "contains": ["Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV.md"]},
  383. {
  384. "id": "tuxedo-is-a-dated-user-selectable-option-on-one-model",
  385. "vendor_sections": {"Tuxedo Computers": ["2018-03-14", "InfinityBook Pro 13", "TUXEDO-disables-Intels-Management-Engine.tuxedo"]},
  386. },
  387. {
  388. "id": "tuxedo-wording-pin",
  389. "absent": ["Ask Tuxedo in writing"],
  390. "absent_except": [("ships with the ME disabled", 'not "ships with the ME disabled"')],
  391. "register_row": {"select": ["press release", "Tuxedo"], "first_has": ["2018-03-14"], "second_has": ["TUXEDO-disables"]},
  392. },
  393. ],
  394. },
  395. # ---- Virtual machines and hypervisors -------------------------------------------------------------------------------------
  396. VM: {
  397. "config": {
  398. "status_words": ("Read", "Observed", "Page read", "General knowledge", "**est.**"),
  399. "addresses_allow": (r"127\.0\.0\.1",),
  400. "addresses_require": ("127.0.0.1",),
  401. "min_register_rows": 25,
  402. "min_links": 8,
  403. "min_glossary_rows": 5,
  404. "nav_contains": (DRAFT,),
  405. },
  406. "rows": [
  407. {"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"]},
  408. {"id": "pages-that-assume-a-vm-link-the-lesson", "inbound_min": 4},
  409. {
  410. "id": "lab-commands-never-bridge-the-guest-onto-a-real-network",
  411. "code": {
  412. "tags": ["bash"],
  413. "require": ["qemu-system-x86_64", "-nic user"],
  414. "forbid": BRIDGE_FORBID,
  415. "bite_bad": ["qemu-system-x86_64 -nic bridge,br=br0", "qemu-system-x86_64 -netdev tap,id=n0"],
  416. "bite_good": ["qemu-system-x86_64 -nic user,model=virtio-net-pci"],
  417. },
  418. },
  419. {
  420. "id": "safety-rule-names-the-three-core-steps",
  421. "start": "## The safety rule for malware and recon labs",
  422. "end": "## Free path",
  423. "contains": ["Isolate the network first", "Snapshot a clean state first", "Never bridge a hostile VM onto your home LAN"],
  424. },
  425. {"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}`"]},
  426. {
  427. "id": "vmware-account-dated-with-vendor-and-news-sources",
  428. "start": "## VMware after Broadcom: a dated account",
  429. "end": "## The bigger options",
  430. "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"],
  431. "contains_ci": ["not verified"],
  432. },
  433. {"id": "apple-options-from-apples-own-pages", "contains": ["Virtualization framework", "macOS 11.0", "`container`", "macOS 26"]},
  434. # test_vm_exercise_3_runs_and_the_snapshot_round_trips (needs qemu-img) stays code in the suite
  435. ],
  436. },
  437. }