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
+44
-2
@@ -6,7 +6,7 @@
|
||||
# rules can change without redeploying agents.
|
||||
set -euo pipefail
|
||||
|
||||
AGENT_VERSION=0.8.0
|
||||
AGENT_VERSION=0.9.0
|
||||
|
||||
# Prefix for every file the agent reads. Only the test suite sets this.
|
||||
ROOT=${KERNELWATCH_ROOT:-}
|
||||
@@ -246,6 +246,45 @@ apt_lists_age() {
|
||||
printf '%s' $(($(date +%s) - newest))
|
||||
}
|
||||
|
||||
# The release's security suite (trixie-security, noble-security) and how old,
|
||||
# in seconds, apt's newest list for it is, as "SUITE AGE". The age is by the
|
||||
# list's Date: field, when the repository last published as of apt's last
|
||||
# successful fetch, so it grows if fetches fail even while other repositories
|
||||
# refresh. AGE is empty if apt has no list for the suite: it isn't in the
|
||||
# sources, and security updates can't arrive. Nothing at all without a release
|
||||
# codename. Lists are matched by their Suite: (Ubuntu) or Codename: (Debian)
|
||||
# field, since file names depend on the mirror; with several mirrors the newest
|
||||
# counts.
|
||||
APT_LISTS_DIR=$ROOT/var/lib/apt/lists
|
||||
security_repo() {
|
||||
local codename suite f published t newest=0 now
|
||||
codename=$(os_release_field VERSION_CODENAME)
|
||||
[[ -n $codename ]] || codename=$(os_release_field UBUNTU_CODENAME)
|
||||
[[ $codename =~ ^[a-z]+$ ]] || return 0
|
||||
suite=$codename-security
|
||||
for f in "$APT_LISTS_DIR"/*_InRelease "$APT_LISTS_DIR"/*_Release; do
|
||||
[[ -f $f ]] || continue
|
||||
# The fields come before the checksum lists, which can be long.
|
||||
published=$(awk -v want="$suite" '
|
||||
/^(MD5Sum|SHA1|SHA256|SHA512):/ { exit }
|
||||
($1 == "Suite:" || $1 == "Codename:") && $2 == want { found = 1 }
|
||||
$1 == "Date:" { sub(/^Date:[ \t]*/, ""); date = $0 }
|
||||
END { if (found) print (date == "" ? "-" : date) }' "$f" 2>/dev/null) || continue
|
||||
[[ -n $published ]] || continue
|
||||
if [[ $published == - ]] || ! t=$(date -d "$published" +%s 2>/dev/null); then
|
||||
# apt sets a list's mtime from the server's Last-Modified.
|
||||
t=$(stat -c %Y "$f" 2>/dev/null) || continue
|
||||
fi
|
||||
((t > newest)) && newest=$t
|
||||
done
|
||||
printf '%s ' "$suite"
|
||||
if ((newest > 0)); then
|
||||
now=$(date +%s)
|
||||
printf '%s' $((now > newest ? now - newest : 0))
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Size and free space of the filesystem holding /boot, in KiB, as "SIZE FREE";
|
||||
# empty if df can't tell. That's the root filesystem when /boot isn't its own
|
||||
# mount. A full /boot makes the next kernel's postinst fail, so the host stays
|
||||
@@ -326,7 +365,7 @@ uptime_seconds() {
|
||||
|
||||
build_report() {
|
||||
local running newest kernels sim inst sim_err rc apt_ok=1 apt_err='' reboot_file=0 reboot_pkgs=
|
||||
local boot_size='' boot_free='' pro_attached='' pro_esm=''
|
||||
local boot_size='' boot_free='' pro_attached='' pro_esm='' sec_suite='' sec_age=''
|
||||
|
||||
running=$(uname -r)
|
||||
kernels=$(installed_kernels)
|
||||
@@ -352,6 +391,7 @@ build_report() {
|
||||
|
||||
read -r boot_size boot_free <<<"$(boot_space)" || true
|
||||
read -r pro_attached pro_esm <<<"$(ubuntu_pro)" || true
|
||||
read -r sec_suite sec_age <<<"$(security_repo)" || true
|
||||
[[ $pro_esm == - ]] && pro_esm=
|
||||
|
||||
printf '{'
|
||||
@@ -404,6 +444,8 @@ build_report() {
|
||||
printf '"unattended_upgrades_kept_back":%s,' \
|
||||
"$( { [[ -r $UU_KEPT_FILE ]] && tr -s ' \t' '\n' <"$UU_KEPT_FILE"; } | sort -u | json_str_array)"
|
||||
printf '"apt_lists_age_seconds":%s,' "$(json_int "$(apt_lists_age)")"
|
||||
printf '"security_repo_suite":%s,' "$(json_str_or_null "$sec_suite")"
|
||||
printf '"security_repo_age_seconds":%s,' "$(json_int "$sec_age")"
|
||||
printf '"uptime_seconds":%s' "$(json_int "$(uptime_seconds)")"
|
||||
printf '}\n'
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user