Merge pull request 'fix(updates): read dnf's security advisories from the cached metadata (#76)' (#77) from fix/dnf-security-cache-only into main
driver / standard (push) Failing after 2s
driver / lint (push) Successful in 14s
driver / types (push) Successful in 1m1s
driver / test (3.12) (push) Successful in 1m1s
driver / test (3.13) (push) Successful in 55s
driver / lowest (push) Successful in 31s
driver / build (push) Successful in 31s
driver / security (push) Successful in 1m3s
CI / driver (push) Failing after 2m6s
driver / publish (push) Skipped

Reviewed-on: #77
This commit was merged in pull request #77.
This commit is contained in:
christianmanivong committed 2026-11-02 07:18:33 +00:00
commit 935fad2a2d
3 files changed
+25 -2

No files matched your search

+8
View File
@@ -7,6 +7,14 @@ recorded here; their history is the git log.
## [Unreleased]
### Fixed
- `DNF_SECURITY_COMMAND` reads the cached metadata only (`dnf --cacheonly`), as
`APT_UPGRADABLE_COMMAND` reads apt's local index (#76). With an expired cache dnf
downloaded the repositories' metadata first, and on an Oracle Linux host on OCI that
outlasted netOrk's whole poll budget. Refreshing the index stays a step of its own
(`dnf makecache`). Without a cache dnf fails at once, which already reads as
"security unknown".
## [4.23.0] - 2026-11-02
### Changed
+5 -2
View File
@@ -28,9 +28,12 @@ APT_UPGRADABLE_COMMAND = "{ LC_ALL=C apt list --upgradable 2>/dev/null; echo __A
#: Read-only. Lists the packages that a pending security advisory covers. A
#: failed dnf prints nothing, the same as no advisories, so its exit status is
#: printed inside the group, as apt's is.
#: printed inside the group, as apt's is. It reads the cached metadata only, as
#: apt reads its local index: an expired cache otherwise makes dnf download the
#: repositories' metadata first, which can take minutes (#76).
DNF_SECURITY_COMMAND = (
"{ LC_ALL=C dnf updateinfo list --security --quiet 2>/dev/null; echo __DNF_RC=$?; } | cat"
"{ LC_ALL=C dnf --cacheonly updateinfo list --security --quiet 2>/dev/null;"
" echo __DNF_RC=$?; } | cat"
)
# openssl/noble-updates,noble-security 3.0.13-0ubuntu3.6 amd64 [upgradable from: 3.0.13-0ubuntu3.5]
+12
View File
@@ -176,6 +176,18 @@ __DNF_RC=0
with pytest.raises(ValueError, match="exit status 1"):
parse_dnf_security(out)
def test_the_command_reads_only_the_cached_metadata(self, tmp_path):
"""An expired cache made dnf download the repositories' metadata inside the
poll, which outlasted its whole budget (#76)."""
args = tmp_path / "args"
dnf = tmp_path / "dnf"
dnf.write_text(f"#!/bin/sh\nprintf '%s\\n' \"$@\" > {args}\n")
dnf.chmod(0o755)
env = {"PATH": f"{tmp_path}:{os.environ.get('PATH', '/usr/bin:/bin')}"}
subprocess.run(["sh", "-c", DNF_SECURITY_COMMAND], capture_output=True, env=env)
assert "--cacheonly" in args.read_text().split()
@pytest.mark.parametrize(
("nevra", "name"),
[