Files
alzeo/tests/test_security_doc_root.py
Hasan BasbunarandClaude Opus 5.5 d782f94391 a new box installs in one go: the docker group, python3-dev and ffmpeg
NVIDIA's first-boot setup leaves the account it creates out of the docker group (its oobe-admin,
DGX OS 7.6.0 on an ASUS GX10), and DGX OS 7.6.0 has neither python3-dev nor ffmpeg: the one-liner
stopped at its first check on every new box, and past it the image and video lanes stopped on the
packages. lanes.sh now has docker_grant (install.sh's step 1, after every refusal that comes before
it: the account added with sudo, said first, then the run started again with the group; --no-service
says how instead), docker_session (a terminal older than the group: install.sh, switch-model.sh,
prepare-lane.sh, uninstall.sh and the lanes' installers start again with it), docker_relaunch (sg
docker, then back to the account's own group, with the environment the run started with, no value of
it in a command line, and the signals it ignored) and host_packages (install.sh puts in what the image
and video lanes need while its terminal can give sudo its password, once per run, and the lanes'
installers do the same from a terminal). SECURITY.md and the README say what the installer does on a
new box. tests/test_fresh_machine.py: 56 cases, 55 failing on the code before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 01:15:11 +02:00

70 lines
3.6 KiB
Python

#!/usr/bin/env python3
"""SECURITY.md says what the cockpit's user can reach as root, as the code has it.
It said the cockpit reached root through "exactly one surface", its sudoers lines, while
install.sh requires the user to be in the docker group (root-equivalent by itself) and
two of those lines install a file the user writes into /etc/systemd/system, next to
daemon-reload and restart: whoever writes it runs what it says as root (found in review,
2026-09-24). These tie the page to the two facts, so it cannot drift back."""
import pathlib
import re
import unittest
REPO = pathlib.Path(__file__).resolve().parents[1]
SECURITY = (REPO / "SECURITY.md").read_text()
FLAT = re.sub(r"\s+", " ", SECURITY)
class TheCockpitsRootIsStatedAsItIs(unittest.TestCase):
def test_no_single_surface_claim(self):
self.assertNotIn("reaches root through exactly one", FLAT)
def test_the_docker_group_is_named_while_install_sh_requires_it(self):
# install.sh reaches docker through lanes.sh (docker_grant) since v1.37.2: the check
# reads both, or it would have stopped checking without a word when the line moved
code = (REPO / "install.sh").read_text() + (REPO / "lanes.sh").read_text()
self.assertIn("docker_grant", (REPO / "install.sh").read_text())
self.assertIn("usermod -aG docker", code)
self.assertIn("`docker` group", FLAT)
self.assertIn("root-equivalent", FLAT)
def test_the_page_says_the_installer_adds_the_account(self):
# it adds the account itself on a box whose first-boot setup left it out (v1.37.2)
if "sudo usermod -aG docker" in (REPO / "lanes.sh").read_text():
self.assertIn("adds it to that group when it is not in it", FLAT)
self.assertIn("before it runs sudo", FLAT)
# and not a promise of a password prompt that a sudo ticket skips (found in review)
self.assertIn("does not ask while an earlier ticket is still valid", FLAT)
def test_the_staged_unit_install_is_named_while_the_allowlist_has_it(self):
sudoers = (REPO / "dashboard" / "sudoers-cockpit.template").read_text()
if re.search(r"/usr/bin/install .*switch-stage /etc/systemd/system/", sudoers):
self.assertIn("switch-stage", FLAT)
self.assertIn("runs what it says as root", FLAT)
class WhatLeavesTheBoxIsStatedAsItIs(unittest.TestCase):
"""Three sentences of SECURITY.md were false: the update check ran "at most once every
six hours" (a failure retries after a minute), downloads went only to Hugging Face and
the image registry (GitHub too), and every pinned byte was hash-verified with nothing
said of the image lane's unpinned pip dependencies (found in review, 2026-09-24)."""
def test_github_is_named_while_install_sh_downloads_from_it(self):
if "https://github.com/anomalyco/opencode/releases" in (REPO / "install.sh").read_text():
self.assertIn("the pinned opencode release", FLAT)
def test_the_retry_schedule_is_the_code_s(self):
ck = (REPO / "dashboard" / "cockpit.py").read_text()
if "min(60.0 * 2 ** max(0, _RELEASE[\"fails\"] - 1), 21600.0)" in ck:
self.assertNotIn("at most once every six hours", FLAT)
self.assertIn("retried after one minute, then two, four, eight", FLAT)
def test_the_image_lanes_unpinned_bytes_are_named(self):
img = (REPO / "install-image.sh").read_text()
if "--require-hashes" not in img:
self.assertIn("pip resolves the wheel's dependency tree from PyPI", FLAT)
if __name__ == "__main__":
unittest.main(verbosity=2)