mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-06 12:54:19 +01:00
compare_digest refuses a non-ASCII str, so {"key": "é"} ended the handler before the
attempt was counted: the key is compared as bytes. A NUL in a static path made resolve()
raise: it is a 404. The five-a-minute login limit was counted after the reply, so a burst
was judged far past it: the attempt is counted under a lock before it is judged, and given
back on success. The dead `if True:` and its unreachable refusal go. SECURITY.md names
GitHub among the downloads, gives the update check's real retry schedule, and says the
image lane's pip dependencies are unpinned.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
58 lines
2.7 KiB
Python
58 lines
2.7 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):
|
|
if "usermod -aG docker" in (REPO / "install.sh").read_text():
|
|
self.assertIn("`docker` group", FLAT)
|
|
self.assertIn("root-equivalent", 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)
|