From 9d982a7fd1ca3bd65257ac2d3999bda059ae44ac Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 12 Nov 2026 21:54:20 +0000 Subject: [PATCH] fix(update): drop image_tag suppressions when a version source moves the tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docker updater drops the image_tag CVE suppressions of every service it moves to another version. The version-sources updater did not, so each bump left suppressions that named the old tag, and TestCveSuppressions rejected the pull request: PR 1707 moved bigbluebutton from v3.0.39 to v4.0.2 and failed on 10 stale entries. apply_updates now drops them for every service whose version moved. The drop runs after every pin of the file moved, because the pins are addressed by their collected line and the drop removes lines. Replaying PR 1707's bumps on main's bigbluebutton file moves the same 11 pins and leaves no TestCveSuppressions problem. Accepted security finding (unchanged): B603 on utils/update/source.py, reviewed 2026-11-07. 🎯 Fix: 95 % 💥 Break: 2 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 93 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 --- tests/unit/python/utils/update/test_source.py | 55 +++++++++++++++++++ utils/update/source.py | 11 ++++ 2 files changed, 66 insertions(+) diff --git a/tests/unit/python/utils/update/test_source.py b/tests/unit/python/utils/update/test_source.py index f5ba65c76a..e9bbeeadf6 100644 --- a/tests/unit/python/utils/update/test_source.py +++ b/tests/unit/python/utils/update/test_source.py @@ -110,6 +110,35 @@ bundle: pattern: 'part (v[0-9.]+-v[0-9.]+)' """ +SUPPRESSED = """\ +--- +first: + image: example/first + version: "v1.0.0" + update: + type: npm + package: first + security: + suppressions: + # nocheck: cve stale tag + - image_tag: "v1.0.0" + until: 2026-11-30 + # nocheck: cve accepted + - id: CVE-2026-1234 + until: 2026-11-30 +second: + image: example/second + version: "v2.0.0" + update: + type: npm + package: second + security: + suppressions: + # nocheck: cve stale tag + - image_tag: "v2.0.0" + until: 2026-11-30 +""" + def _repo(services: str = SERVICES) -> Path: tmp = Path(tempfile.mkdtemp()) @@ -198,6 +227,32 @@ class TestOutdated(unittest.TestCase): self.assertEqual(module.outdated([self._entry(root)], root), []) +class TestSuppressions(unittest.TestCase): + def test_a_moved_version_drops_its_image_tag_suppressions_and_every_pin_moves( + self, + ) -> None: + root = _repo(SUPPRESSED) + latest = {"first": "v1.1.0", "second": "v2.1.0"} + with ( + mock.patch.object(module, "manifest_exists", return_value=True), + mock.patch.object( + module, + "candidates", + side_effect=lambda entry, _: [latest[entry.entity]], + ), + ): + updates = module.outdated(module.collect_entries(root), root) + module.apply_updates(updates) + + config = root / "roles" / "web-app-example" / ROLE_FILE_META_SERVICES + written = config.read_text() # nocheck: cache-read just rewritten here + self.assertIn('version: "v1.1.0"', written) + self.assertIn('version: "v2.1.0"', written) + self.assertNotIn("image_tag", written) + self.assertIn("id: CVE-2026-1234", written) + self.assertEqual(written.count("security:"), 1) + + class TestTemplate(unittest.TestCase): def _outdated(self, services: str, upstream: str) -> list[str]: root = _repo(services) diff --git a/utils/update/source.py b/utils/update/source.py index c8eabb8949..409edc2c4f 100644 --- a/utils/update/source.py +++ b/utils/update/source.py @@ -42,6 +42,7 @@ from utils.cache.files import read_text from utils.cache.yaml import load_yaml from utils.docker.registry import manifest_exists from utils.roles.mapping import ROLE_FILE_META_SERVICES +from utils.security.suppressions import drop_image_tag_entries from utils.update import checksum from utils.update.addons import GITHUB_RELEASES_CATALOG, iter_addon_files from utils.update.base import ( @@ -475,6 +476,7 @@ def bump_archive(line: str, current: str, latest: str) -> str: def apply_updates(updates: Iterable[VersionSourceUpdate]) -> list[Path]: """Rewrite every pin to its newer version and return the changed files.""" changed: list[Path] = [] + moved: dict[Path, list[str]] = {} for update in updates: path = update.entry.config_path lines = path.read_text( # nocheck: cache-read read-modify-write: a cached read serves the pre-write content when two pins of one file are bumped in the same run @@ -496,4 +498,13 @@ def apply_updates(updates: Iterable[VersionSourceUpdate]) -> list[Path]: path.write_text("".join(lines), encoding="utf-8") if path not in changed: changed.append(path) + if not update.entry.addon and update.entry.key == DEFAULT_KEY: + moved.setdefault(path, []).append(update.entry.entity) + for path, services in moved.items(): + lines = path.read_text( # nocheck: cache-read read-modify-write of the file the loop above just rewrote + encoding="utf-8" + ).splitlines(keepends=True) + for service in services: + lines = drop_image_tag_entries(lines, service) + path.write_text("".join(lines), encoding="utf-8") return changed