Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Keep native updater controls on supplied fixture tools
pulse-triage[bot]0e7951b01aac
diff --git a/scripts/installtests/auto_update_systemd.py b/scripts/installtests/auto_update_systemd.pyindex e1d2feaab0..b680c95d27 100644--- a/scripts/installtests/auto_update_systemd.py+++ b/scripts/installtests/auto_update_systemd.py@@ -16,6 +16,7 @@ from pathlib import Pathimport reimport shutilimport signal+import statimport subprocessimport tarfileimport time@@ -211,7 +212,8 @@ class NativeLab:for tag, binary in self.binaries.items():if self.run(str(binary), "--version").stdout.decode().splitlines()[0] != "Pulse " + tag:raise ValueError("synthetic binary identity mismatch")- self.run("ssh-keygen", "-q", "-t", "ed25519", "-N", "", "-f", str(self.root / "signer/key"))+ self.signer_command("generate-ephemeral-key", "-q", "-t", "ed25519", "-N", "", "-f",+ str(self.root / "signer/key"))for tag, binary in self.binaries.items():version = self.root / "VERSION"version.write_text(tag + "\n")@@ -245,9 +247,56 @@ class NativeLab:self.baseline_data = {p: digest(data / p) for p in files}self.baseline_mode = (self.root / "install/bin/pulse").stat().st_mode & 0o777+ def signer_command(self, operation, *arguments):+ """Retain non-secret facts about a failed, fixed ephemeral-signer step.++ Do not publish command output or key bytes. In particular, an exit and+ digest alone cannot distinguish generation from signing, or establish+ why a hosted OpenSSH invocation failed before the first native phase.+ Diagnostic labels below mean observed text, not a causal diagnosis.+ """+ try:+ return self.run("ssh-keygen", *arguments)+ except RuntimeError:+ failure = self.receipt.get("command_failure")+ if failure is None:+ # A confined control may stop before command execution. Do+ # not manufacture an executed-command observation for it.+ raise+ failure["operation"] = operation+ try:+ info = (self.root / "signer/key").lstat()+ failure["signer_key_metadata"] = {+ "present": True, "regular_file": stat.S_ISREG(info.st_mode),+ "mode": format(stat.S_IMODE(info.st_mode), "04o"),+ "owned_by_executor": info.st_uid == os.geteuid(),+ }+ except FileNotFoundError:+ failure["signer_key_metadata"] = {"present": False}+ except OSError:+ failure["signer_key_metadata"] = {"observation": "unavailable"}+ output = getattr(self, "_last_output", b"")+ # A timeout has no completed output. Never label an earlier+ # command's output as this command's diagnostic.+ if failure.get("output_sha256") == hashlib.sha256(output).hexdigest():+ markers = {+ "private-key-permissions": (b"UNPROTECTED PRIVATE KEY FILE", b"bad permissions"),+ "key-load-failure": (b"Load key", b"Couldn't load public key"),+ "missing-file": (b"No such file or directory",),+ "unsupported-operation": (b"Unsupported operation", b"unknown option"),+ }+ failure["observed_diagnostics"] = [+ label for label, texts in markers.items() if any(text in output for text in texts)+ ]+ raise+def sign(self, path):- self.run("ssh-keygen", "-Y", "sign", "-f", str(self.root / "signer/key"),- "-n", "pulse-install", str(path))+ name = Path(path).name+ operation = {"installer": "sign-installer",+ **{f"pulse-{tag}-linux-amd64.tar.gz": "sign-archive-" + tag+ for tag in TAGS}}.get(name, "sign-confined-fixture")+ self.signer_command(operation, "-Y", "sign", "-f", str(self.root / "signer/key"),+ "-n", "pulse-install", str(path))Path(str(path) + ".sig").rename(str(path) + ".sshsig")def assert_runtime(self, tag, active):diff --git a/scripts/tests/test_auto_update_systemd.py b/scripts/tests/test_auto_update_systemd.pyindex ea7db9aec3..877c4a7baf 100644--- a/scripts/tests/test_auto_update_systemd.py+++ b/scripts/tests/test_auto_update_systemd.py@@ -6,7 +6,9 @@ import jsonimport osfrom pathlib import Pathimport re+import shutilimport subprocess+import sysimport tempfileimport unittestfrom unittest.mock import patch@@ -17,6 +19,17 @@ native = importlib.util.module_from_spec(SPEC)SPEC.loader.exec_module(native)WORKFLOW = ROOT / ".github/workflows/build-and-test.yml"STEP = "Check current-source unattended recovery on native systemd"+FIXTURE_COMMANDS = ("bash", "tar", "chmod", "mv", "timeout")+++def selected_fixture_commands():+ # The containing native job has already supplied its Linux-only tools.+ # Capture only these executables, not the whole ambient PATH or environment.+ commands = {name: shutil.which(name) for name in FIXTURE_COMMANDS}+ for name, executable in commands.items():+ if executable is None:+ raise ValueError("missing installer fixture tool: " + name)+ return commandsdef recipe(source):@@ -49,6 +62,13 @@ def recipe(source):class NativeContracts(unittest.TestCase):+ def test_fixture_command_selection_refuses_missing_tools_without_fallback(self):+ for missing in FIXTURE_COMMANDS:+ with self.subTest(missing=missing), patch.object(shutil, "which", side_effect=+ lambda name: None if name == missing else "/supplied/" + name):+ with self.assertRaisesRegex(ValueError, "missing installer fixture tool: " + missing):+ selected_fixture_commands()+def test_definition_boundary_is_exact_and_rejects_drift(self):source = (ROOT / "install.sh").read_text()definitions = native.installer_definitions(source)@@ -107,6 +127,48 @@ class NativeContracts(unittest.TestCase):self.assertEqual(result.returncode, 1)self.assertIn(b"Cryptographic signature verification failed", result.stdout)+ def test_signer_failure_retains_operation_and_metadata_not_private_output(self):+ with tempfile.TemporaryDirectory() as directory:+ root = Path(directory)+ (root / "signer").mkdir(mode=0o700)+ lab = native.NativeLab(root, ROOT, root / "a", root / "b", "a" * 40)+ lab.signer_command("generate-ephemeral-key", "-q", "-t", "ed25519", "-N", "", "-f",+ str(root / "signer/key"))+ target = root / "installer"+ target.write_text("closed synthetic fixture, not a release\n")+ # A real OpenSSH refusal, not a simulated exit code or key read.+ (root / "signer/key").chmod(0o644)+ with self.assertRaisesRegex(RuntimeError, "native command failed"):+ lab.sign(target)+ failure = lab.receipt["command_failure"]+ self.assertEqual(failure["operation"], "sign-installer")+ self.assertEqual(failure["observed_exit"], 255)+ self.assertIn("private-key-permissions", failure["observed_diagnostics"])+ self.assertEqual(failure["signer_key_metadata"], {+ "present": True, "regular_file": True, "mode": "0644", "owned_by_executor": True,+ })+ self.assertFalse(Path(str(target) + ".sshsig").exists())+ retained = json.dumps(lab.receipt)+ self.assertNotIn("PRIVATE KEY", retained)+ self.assertNotIn(str(root), retained)+ self.assertNotIn(lab._last_output.decode(), retained)++ def test_signer_timeout_does_not_attribute_stale_output_to_new_command(self):+ with tempfile.TemporaryDirectory() as directory:+ root = Path(directory)+ lab = native.NativeLab(root, ROOT, root / "a", root / "b", "a" * 40)+ lab._last_output = b"UNPROTECTED PRIVATE KEY FILE from an earlier command"+ def timeout(*args):+ lab.receipt["command_failure"] = {"command": "ssh-keygen", "deadline_exceeded": True,+ "observed_exit": -9}+ raise RuntimeError("native command deadline exceeded")+ with patch.object(lab, "run", side_effect=timeout), self.assertRaises(RuntimeError):+ lab.signer_command("generate-ephemeral-key", "-q")+ failure = lab.receipt["command_failure"]+ self.assertEqual(failure["operation"], "generate-ephemeral-key")+ self.assertEqual(failure["signer_key_metadata"], {"present": False})+ self.assertNotIn("observed_diagnostics", failure)+def make_phase(self, directory, mutation=""):root = Path(directory)for name in ("install/bin", "data", "tmp"):@@ -318,6 +380,11 @@ elif args[0] == "unmask": unit.unlink()elif args[0] not in ("daemon-reload", "reset-failed"): sys.exit(97)'''class FixtureLab(native.NativeLab):+ def run(self, *args, **kwargs):+ if args[0] == "/bin/bash":+ args = (str(tools / "bash"), *args[1:])+ return super().run(*args, **kwargs)+def assert_runtime(self, tag, active):if native.digest(self.root / "install/bin/pulse") != self.receipt["binaries"][tag]:raise RuntimeError("fixture executable mismatch")@@ -328,6 +395,19 @@ elif args[0] not in ("daemon-reload", "reset-failed"): sys.exit(97)return statewith tempfile.TemporaryDirectory() as directory:base = Path(directory); tools = base / "tools"; tools.mkdir()+ selected = selected_fixture_commands()+ tool_trace = base / "selected-tools.jsonl"+ for name, executable in selected.items():+ # Record only tool identity, never shell arguments or key/log+ # bytes. Execute the actual supplied GNU utility, not a double.+ tool = tools / name+ tool.write_text(f'''#!{sys.executable}+import json, os, pathlib, sys+with pathlib.Path({str(tool_trace)!r}).open('a') as receipt:+ receipt.write(json.dumps({name!r}) + '\\n')+os.execv({executable!r}, [{executable!r}, *sys.argv[1:]])+''')+ tool.chmod(0o700)path = tools / "systemctl"; path.write_text(manager); path.chmod(0o755)account = r'''#!/usr/bin/python3import os, pathlib, sys@@ -385,6 +465,9 @@ else: sys.exit(97)["forward", "manual-reverse", "failed-active", "failed-inactive","failed-masked", "bad-signature", "incomplete-restore"])self.assertTrue(lab.receipt["phases"][-1]["backup_retained"])+ used = [json.loads(line) for line in tool_trace.read_text().splitlines()]+ self.assertEqual(set(used), set(FIXTURE_COMMANDS),+ "nested shell lost a containing-job fixture tool")finally:lab.cleanup()self.assertTrue(lab.receipt["cleanup"]["complete"])