Optionally refresh apt package lists before each report
CI / tests (Python 3.10) (pull_request) Successful in 15s
CI / tests (Python 3.11) (pull_request) Successful in 15s
CI / tests (Python 3.12) (pull_request) Successful in 15s
CI / tests (Python 3.13) (pull_request) Successful in 15s
CI / lint (pull_request) Successful in 3s
CI / tests (Python 3.10) (pull_request) Successful in 15s
CI / tests (Python 3.11) (pull_request) Successful in 15s
CI / tests (Python 3.12) (pull_request) Successful in 15s
CI / tests (Python 3.13) (pull_request) Successful in 15s
CI / lint (pull_request) Successful in 3s
The agent's dist-upgrade simulation already finds new-ABI kernels and security updates, but only once apt's lists know about them. Debian doesn't refresh lists by default, so a kernel security release could stay invisible until someone ran apt update. install.sh --with-apt-update adds a marker that enables kernelwatch-apt-update.service, a sandboxed root oneshot the agent pulls in before each report. Failures (no network, apt lock held) are ignored so the report still goes out. deploy.sh now ships the unit; a test keeps deploy.sh's file list in sync with what install.sh uses. Agent 0.3.2, server 0.3.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9c8f889c7
commit
f35cc007f5
8 files changed
+104
-11
No files matched your search
+25
-1
@@ -5,6 +5,7 @@ replaced by a recorder so we can check what each host received.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
@@ -57,7 +58,8 @@ class DeployTest(unittest.TestCase):
|
||||
os.makedirs(d)
|
||||
|
||||
for name in ("deploy.sh", "kernelwatch-agent", "kernelwatch-agent.service",
|
||||
"kernelwatch-agent.timer", "kernelwatch-needrestart.service"):
|
||||
"kernelwatch-agent.timer", "kernelwatch-needrestart.service",
|
||||
"kernelwatch-apt-update.service"):
|
||||
shutil.copy2(os.path.join(AGENT_DIR, name), self.agent)
|
||||
write_exec(os.path.join(self.agent, "install.sh"), FAKE_INSTALL)
|
||||
|
||||
@@ -187,5 +189,27 @@ class DeployTest(unittest.TestCase):
|
||||
self.assertIn("deploy.conf.example", proc.stderr)
|
||||
|
||||
|
||||
|
||||
class PackagingTest(unittest.TestCase):
|
||||
def read(self, name):
|
||||
with open(os.path.join(AGENT_DIR, name)) as f:
|
||||
return f.read()
|
||||
|
||||
def test_deploy_ships_every_file_install_uses(self):
|
||||
files = re.search(r"^FILES=\(([^)]*)\)", self.read("deploy.sh"), re.M).group(1).split()
|
||||
used = set(re.findall(r'"\$here/([^"]+)"', self.read("install.sh")))
|
||||
self.assertTrue(used)
|
||||
self.assertEqual(used - set(files), set())
|
||||
|
||||
def test_apt_update_is_opt_in_and_runs_before_reports(self):
|
||||
unit = self.read("kernelwatch-apt-update.service")
|
||||
self.assertIn("ConditionPathExists=/etc/kernelwatch/apt-update", unit)
|
||||
self.assertIn("ExecStart=-/usr/bin/apt-get -q update", unit, "failure mustn't block the report")
|
||||
agent = self.read("kernelwatch-agent.service")
|
||||
for key in ("Wants=", "After="):
|
||||
line = next(l for l in agent.splitlines() if l.startswith(key))
|
||||
self.assertIn("kernelwatch-apt-update.service", line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user