CI / tests (Python 3.10) (pull_request) Successful in 30s
CI / tests (Python 3.11) (pull_request) Successful in 30s
CI / tests (Python 3.12) (pull_request) Successful in 28s
CI / tests (Python 3.13) (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 3s
Past its end of support a release gets no more security updates, so apt offers nothing and the host showed ok indefinitely. The server now has a table of when free security support ends for each release the agent installs on (support.py): Debian's LTS end, and Ubuntu's end of standard support plus end of ESM. Dates from Debian LTS and Ubuntu's release cycle via endoflife.date; a test checks the table covers every release agent/install.sh accepts. The agent reports whether Ubuntu Pro is attached and esm-infra's status, read from the pro client's world-readable status.json. A host past its date goes to update; within os_eol_warn_days (default 90) of it, the row gets a note. An Ubuntu host with ESM enabled isn't warned when standard support ends, only before ESM does. The host page shows the dates. Agent 0.7.0; older agents don't report ESM and count as having none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
4.2 KiB
Python
99 lines
4.2 KiB
Python
"""When each supported OS release stops getting security updates.
|
|
|
|
A host past that date shows `ok` forever, because no updates will ever arrive to
|
|
flag. So the status check compares the host's release (`os_id`, `os_version_id`)
|
|
with the dates below.
|
|
|
|
Sources: the Debian security team and Debian LTS (wiki.debian.org/LTS) and
|
|
Ubuntu's release cycle (ubuntu.com/about/release-cycle), as collected by
|
|
endoflife.date. Add each new release when it ships; tests/test_support.py checks
|
|
that every release the agent supports is listed.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from datetime import date
|
|
from typing import Any
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Release:
|
|
name: str
|
|
# Debian: end of LTS, the last free security support (regular security support
|
|
# ends about two years earlier and LTS continues it from the same repository).
|
|
# Ubuntu: end of standard support for the main archive.
|
|
end: date
|
|
# Ubuntu only: end of Expanded Security Maintenance (esm-infra, part of Ubuntu
|
|
# Pro), which keeps patching main after standard support ends.
|
|
esm_end: date | None = None
|
|
|
|
|
|
RELEASES: dict[tuple[str, str], Release] = {
|
|
("debian", "11"): Release("Debian 11", date(2026, 8, 31)),
|
|
("debian", "12"): Release("Debian 12", date(2028, 6, 30)),
|
|
("debian", "13"): Release("Debian 13", date(2030, 6, 30)),
|
|
("ubuntu", "20.04"): Release("Ubuntu 20.04", date(2025, 5, 31), date(2030, 4, 23)),
|
|
("ubuntu", "22.04"): Release("Ubuntu 22.04", date(2027, 6, 1), date(2032, 4, 21)),
|
|
("ubuntu", "24.04"): Release("Ubuntu 24.04", date(2029, 5, 31), date(2034, 4, 25)),
|
|
("ubuntu", "26.04"): Release("Ubuntu 26.04", date(2031, 5, 29), date(2036, 4, 23)),
|
|
}
|
|
|
|
|
|
def release(report: dict[str, Any]) -> Release | None:
|
|
return RELEASES.get((report.get("os_id") or "", report.get("os_version_id") or ""))
|
|
|
|
|
|
def _esm(report: dict[str, Any]) -> bool:
|
|
return report.get("ubuntu_esm_infra") == "enabled"
|
|
|
|
|
|
def check(report: dict[str, Any], today: date, warn_days: int) -> tuple[bool, str] | None:
|
|
"""(is it a problem, why) about this host's OS support, or None if there's nothing to say.
|
|
|
|
A problem means no security updates are coming: the release is past its last
|
|
support date, or an Ubuntu release is past standard support without ESM. The
|
|
rest are warnings for the `warn_days` before such a date (0 disables them)."""
|
|
os_id, version = report.get("os_id"), report.get("os_version_id")
|
|
if os_id not in ("debian", "ubuntu") or not version:
|
|
return None # Debian testing/sid has no VERSION_ID; other distros aren't supported
|
|
rel = release(report)
|
|
if rel is None:
|
|
return False, f"no end-of-support date known for {os_id} {version}"
|
|
|
|
def soon(day: date) -> int | None:
|
|
left = (day - today).days
|
|
return left if warn_days and 0 <= left <= warn_days else None
|
|
|
|
if rel.esm_end is None:
|
|
if today > rel.end:
|
|
return True, f"{rel.name} security support ended {rel.end}; upgrade the release"
|
|
if (left := soon(rel.end)) is not None:
|
|
return False, f"{rel.name} security support ends {rel.end} (in {left} days); plan the upgrade"
|
|
return None
|
|
|
|
if today > rel.esm_end:
|
|
return True, f"{rel.name} ESM ended {rel.esm_end}; upgrade the release"
|
|
if _esm(report):
|
|
if today > rel.end and (left := soon(rel.esm_end)) is not None:
|
|
return False, f"{rel.name} ESM ends {rel.esm_end} (in {left} days); plan the upgrade"
|
|
return None
|
|
if today > rel.end:
|
|
return True, (f"{rel.name} standard support ended {rel.end} and ESM isn't enabled; "
|
|
"enable it with Ubuntu Pro or upgrade the release")
|
|
if (left := soon(rel.end)) is not None:
|
|
return False, (f"{rel.name} standard support ends {rel.end} (in {left} days); "
|
|
"enable ESM with Ubuntu Pro or plan the upgrade")
|
|
return None
|
|
|
|
|
|
def summary(report: dict[str, Any]) -> str | None:
|
|
"""The host page's one-line view of the release's support dates."""
|
|
rel = release(report)
|
|
if rel is None:
|
|
return None
|
|
if rel.esm_end is None:
|
|
return f"until {rel.end}"
|
|
esm = report.get("ubuntu_esm_infra")
|
|
return f"standard until {rel.end}, ESM until {rel.esm_end} (esm-infra: {esm or 'unknown'})"
|