Check that the release's security repository is configured and fresh
CI / tests (Python 3.10) (pull_request) Successful in 36s
CI / tests (Python 3.11) (pull_request) Successful in 36s
CI / tests (Python 3.12) (pull_request) Successful in 37s
CI / tests (Python 3.13) (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 4s
CI / tests (Python 3.10) (pull_request) Successful in 36s
CI / tests (Python 3.11) (pull_request) Successful in 36s
CI / tests (Python 3.12) (pull_request) Successful in 37s
CI / tests (Python 3.13) (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 4s
security_count is only meaningful if apt has the release's security suite. A host missing it from its sources shows 0 security updates forever, and one whose apt can't fetch it (expired key, wrong URL after a release upgrade, a mirror that fell behind) keeps the last copy while the update stamps and other lists move on, so neither the simulation nor the package list age notices. The agent (0.9.0) now finds apt's list for <codename>-security by its Suite: (Ubuntu) or Codename: (Debian) field, since file names depend on the mirror (mirror+file: sources, several mirrors), and reports security_repo_suite and security_repo_age_seconds from its Date:, the newest copy winning. The server puts the host in update when there's no such list, or when it's older than security_repo_stale_after_days (default 7) while the package lists are otherwise fresh; if all of them are old, the existing "package lists N days old" reason covers it. Releases past the end of support are skipped: their suite has stopped publishing, and support.check already says so. ESM suites publish too rarely to judge by date and aren't checked. The host page gets a "Security repository" row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fa6cca4f64
commit
c9912d5fbc
12 files changed
+261
-4
No files matched your search
@@ -352,6 +352,59 @@ class EvaluateTest(unittest.TestCase):
|
||||
evaluate(NOW, rep, NOW, Config(os_eol_warn_days=200)).reasons[0])
|
||||
self.assertEqual(self.level(rep).reasons, [], "outside the default 90 days")
|
||||
|
||||
def sec(self, age=3 * 3600, suite="trixie-security", cfg=CFG, **kw):
|
||||
fields = dict(os_id="debian", os_version_id="13", security_repo_suite=suite,
|
||||
security_repo_age_seconds=age)
|
||||
fields.update(kw)
|
||||
return evaluate(NOW - 60, report(**fields), NOW, cfg)
|
||||
|
||||
def test_security_repo_fresh(self):
|
||||
s = self.sec()
|
||||
self.assertEqual((s.level, s.reasons), ("ok", []))
|
||||
|
||||
def test_security_repo_missing(self):
|
||||
s = self.sec(age=None)
|
||||
self.assertEqual(s.level, "update")
|
||||
self.assertEqual(s.reasons, ["apt has no trixie-security repository, so security updates "
|
||||
"can't arrive; add it to the apt sources and run apt update"])
|
||||
|
||||
def test_security_repo_stale_while_apt_update_succeeds(self):
|
||||
s = self.sec(age=10 * 86400)
|
||||
self.assertEqual(s.level, "update")
|
||||
self.assertEqual(s.reasons, ["apt's trixie-security list is 10d old while apt update otherwise "
|
||||
"succeeds; run apt update and look for errors about trixie-security"])
|
||||
self.assertEqual(self.sec(age=6 * 86400).level, "ok", "within the default 7 days")
|
||||
|
||||
def test_security_repo_stale_with_all_lists_stale_reports_once(self):
|
||||
s = self.sec(age=10 * 86400, apt_lists_age_seconds=10 * 86400)
|
||||
self.assertEqual(s.reasons, ["package lists 10d old; apt update not running?"])
|
||||
|
||||
def test_security_repo_check_can_be_disabled(self):
|
||||
cfg = Config(security_repo_stale_after_days=0)
|
||||
self.assertEqual(self.sec(age=None, cfg=cfg).level, "ok")
|
||||
self.assertEqual(self.sec(age=30 * 86400, cfg=cfg).level, "ok")
|
||||
|
||||
def test_security_repo_not_reported(self):
|
||||
# Agents before 0.9.0, and releases without a codename.
|
||||
self.assertEqual(self.sec(suite=None, age=None).level, "ok")
|
||||
rep = report(os_id="debian", os_version_id="13")
|
||||
self.assertEqual(self.level(rep).level, "ok")
|
||||
|
||||
def test_security_repo_ignored_past_end_of_support(self):
|
||||
# NOW is 2027-01-15. Debian 11's LTS ended 2026-08-31, so bullseye-security no
|
||||
# longer publishes; the end-of-support reason is the one that matters.
|
||||
s = self.sec(age=60 * 86400, suite="bullseye-security", os_version_id="11")
|
||||
self.assertEqual(len(s.reasons), 1, s.reasons)
|
||||
self.assertIn("Debian 11 security support ended", s.reasons[0])
|
||||
# Ubuntu 20.04 past standard support with ESM: focal-security is frozen, but fine.
|
||||
s = self.sec(age=400 * 86400, suite="focal-security", os_id="ubuntu", os_version_id="20.04",
|
||||
ubuntu_esm_infra="enabled")
|
||||
self.assertEqual((s.level, s.reasons), ("ok", []))
|
||||
|
||||
def test_security_repo_checked_within_standard_support(self):
|
||||
s = self.sec(age=10 * 86400, suite="jammy-security", os_id="ubuntu", os_version_id="22.04")
|
||||
self.assertEqual(s.level, "update")
|
||||
|
||||
def uu(self, success=6 * 3600, run=6 * 3600, state="enabled", **kw):
|
||||
return self.level(report(unattended_upgrades=state, unattended_upgrades_success_age_seconds=success,
|
||||
unattended_upgrades_run_age_seconds=run, **kw))
|
||||
|
||||
Reference in new issue
Block a user