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
@@ -191,6 +191,33 @@ def unattended_upgrades_problem(report: dict[str, Any], cfg: Config) -> tuple[bo
|
||||
"is apt-daily-upgrade.timer enabled?")
|
||||
|
||||
|
||||
def security_repo_problem(report: dict[str, Any], cfg: Config, today: date) -> str | None:
|
||||
"""Why security updates may not be reaching this host from its release's security
|
||||
suite, or None. Agents before 0.9.0, and releases without a codename, don't
|
||||
report the suite.
|
||||
|
||||
The age is of the suite's Date: field as of apt's last successful fetch of it, so
|
||||
it keeps growing when fetching that repository fails, even while the update
|
||||
stamps and other lists move on."""
|
||||
suite = report.get("security_repo_suite")
|
||||
if not suite or not cfg.security_repo_stale_after_days:
|
||||
return None
|
||||
rel = support.release(report)
|
||||
if rel is not None and today > rel.end:
|
||||
return None # the suite has stopped publishing; support.check covers it
|
||||
age = report.get("security_repo_age_seconds")
|
||||
if age is None:
|
||||
return (f"apt has no {suite} repository, so security updates can't arrive; "
|
||||
"add it to the apt sources and run apt update")
|
||||
if age <= cfg.security_repo_stale_after_days * 86400:
|
||||
return None
|
||||
apt_age = report.get("apt_lists_age_seconds")
|
||||
if apt_age is None or apt_age / 3600 > cfg.apt_stale_after_hours:
|
||||
return None # apt isn't refreshing anything; the package list reason covers it
|
||||
return (f"apt's {suite} list is {_age(age)} old while apt update otherwise succeeds; "
|
||||
f"run apt update and look for errors about {suite}")
|
||||
|
||||
|
||||
def _kernel_only_reboot_file(report: dict[str, Any]) -> bool:
|
||||
"""/run/reboot-required exists only because of kernel packages."""
|
||||
pkgs = report.get("reboot_required_pkgs") or []
|
||||
@@ -295,6 +322,8 @@ def evaluate(received_at: int | None, report: dict[str, Any] | None, now: float,
|
||||
status.raise_to("update", "package list age unknown")
|
||||
elif apt_age / 3600 > cfg.apt_stale_after_hours:
|
||||
status.raise_to("update", f"package lists {apt_age / 86400:.0f}d old; apt update not running?")
|
||||
if why := security_repo_problem(report, cfg, datetime.fromtimestamp(now, timezone.utc).date()):
|
||||
status.raise_to("update", why)
|
||||
|
||||
if host and (reported := hostname_mismatch(host, report)):
|
||||
status.note(f"registered as {host} but reports itself as {reported}; "
|
||||
|
||||
Reference in new issue
Block a user