Repository navigation
build: pick up OS security updates in images - #749
Conversation
Upgrade all Debian packages in the base stage with apt-get upgrade instead of single ones, so that the images get the fixes Debian has released (e.g., zlib1g for CVE-2026-76844 and CVE-2026-85091) before the upstream Python images have them. apt-get update fails if an index can't be fetched, which would otherwise leave the packages as they are. Refs #747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Install updates that need new packages (--with-new-pkgs) instead of keeping them back, and keep changed configuration files without a dpkg prompt (--force-confdef, --force-confold), so that fixes aren't left out silently and builds don't fail on a prompt. Refs #747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Limit the checks of the upgrade step to the command itself, without the comments that follow it, and word the Dockerfile comment on configuration files precisely. Refs #747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideConfigurationUpgrade all Debian packages in the Docker base stage, fail on unavailable indexes or updates still kept back, and install new dependencies noninteractively so released OS fixes reach derived images.
DocumentationExplain that builds install available Debian updates and may therefore differ over time, including guidance for image scans, local builds, deployment, and releases.
TestsReplace the apt-only Dockerfile check with assertions covering the general OS upgrade command, its failure behavior, and its noninteractive options.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Refs #747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docker/Dockerfile" line_range="43" />
<code_context>
+# modified in the base image keep their version, without a prompt
+RUN apt-get update --error-on=any && \
+ DEBIAN_FRONTEND=noninteractive \
+ apt-get upgrade -y --with-new-pkgs --no-install-recommends \
+ -o Dpkg::Options::=--force-confdef \
+ -o Dpkg::Options::=--force-confold && \
</code_context>
<issue_to_address>
**Vulnerable package remains in image**
When a Debian security update requires removing an installed package, `apt-get upgrade --with-new-pkgs` keeps the update back while exiting successfully, so the image retains the vulnerable package despite the expectation that pending updates are installed.
Use an upgrade command that permits removing installed packages and ensure the build fails if the security update cannot be applied.
Also at `docs/contributing/index.md:135-136`, `docs/deployment.md:474-476`.
</issue_to_address>
### Comment 2
<location path="tests/test_image_requirements.py" line_range="56" />
<code_context>
+ run = re.split(r"(?<!\\)\n", run, maxsplit=1)[0]
+ # Fails if an index can't be fetched, which would otherwise leave the
+ # packages as they are, without an error
+ assert re.search(r"\bapt-get update --error-on=any\b", run)
+ # Also updates that need new packages, which would be kept back otherwise
+ assert re.search(r"\bapt-get upgrade\b[^&]*\s--with-new-pkgs\b", run)
</code_context>
<issue_to_address>
**Failed index fetch is ignored**
When the Docker command suppresses `apt-get update`'s nonzero exit status before running the upgrade, `test_base_stage_upgrades_os_packages` checks for the update and upgrade text separately at lines 55 and 57, so it passes if the update's failure is suppressed and the upgrade continues using stale indexes.
Assert that the update and upgrade are chained so a failed update stops the build.
</issue_to_address>
### Comment 3
<location path="tests/test_image_requirements.py" line_range="58" />
<code_context>
+ # packages as they are, without an error
+ assert re.search(r"\bapt-get update --error-on=any\b", run)
+ # Also updates that need new packages, which would be kept back otherwise
+ assert re.search(r"\bapt-get upgrade\b[^&]*\s--with-new-pkgs\b", run)
+ # Without prompts, of debconf and of dpkg for changed configuration files
+ assert "DEBIAN_FRONTEND=noninteractive" in run
</code_context>
<issue_to_address>
**Upgrade uses stale package index**
When the Docker command places `apt-get upgrade` before `apt-get update` in the same step, `test_base_stage_upgrades_os_packages` independently searches for the update at line 55 and upgrade at line 57, so it passes if the upgrade runs before the update and misses fixes available from the refreshed index.
Assert that the update precedes the upgrade in the command.
</issue_to_address>
Linked issues
#747 build: pick up OS security updates in images · 3 of 4 met · 1 to check by hand
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Install all pending Debian updates in the base stage instead of upgrading single packages. | ✅ Met | The base stage runs apt-get update --error-on=any and apt-get upgrade --with-new-pkgs --no-install-recommends; it also handles configuration files noninteractively. |
| 2 | Update the test of the base stage. | ✅ Met | test_base_stage_upgrades_os_packages checks the update and upgrade command options and that the step is in the base stage. |
| 3 | Document the build-time Debian updates in the image documentation and release notes. | ✅ Met | The getting-started, deployment, and contributing docs, and the 0.22.0 release notes describe the updates and their availability at build time. |
| 4 | Have all Python-version images pass the CI scan with no fixable critical or high findings, including zlib1g. | 👀 Check by hand (runtime) | Verify the reported CI scan results for every Python version and confirm they show no fixable critical or high findings. |
Sourcery assessment
Needs a human reviewer. 3 findings to address first, and the build now upgrades all available Debian packages, so an incompatible update could change runtime behavior or break an image. Published images retain those package versions after a code revert, but the bounded impact can be repaired by rebuilding and replacing the affected images.
Blocking findings: docker/Dockerfile:43, tests/test_image_requirements.py:56, tests/test_image_requirements.py:58
Fail the build if updates are still kept back after the upgrade (e.g., as they would remove packages), listing them, instead of leaving them out silently, and check in the test that the update comes first and stops the step on failure (Sourcery review). Refs #747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
FOCA's images inherit fixable OS vulnerabilities from their pinned
python:3.X-slim-trixiebase images, currently zlib1g1:1.3.dfsg+really1.3.1-1+b1(CVE-2026-76844 and CVE-2026-85091, high; CVE-2026-27171, medium). The fix (+deb13u1) is intrixie-security, but not in any upstream base image yet, not even the latestpython:3.13-slim-trixiedigest (sha256:e48f59cd..., checked 2026-11-08), so a digest bump doesn't help.The base stage of
docker/Dockerfilenow installs all pending Debian updates instead of upgradingaptalone (#697):--error-on=anyfails the build if a package index can't be fetched. Without it,apt-get updateexits 0 on fetch errors and the upgrade silently does nothing; this happened in a local build (the Python 3.12 image kept apt 3.0.3 and zlib1g+b1).--with-new-pkgsinstalls updates that need new packages instead of keeping them back.dist-upgrade: letting the base image remove packages on its own could break the image silently, so a maintainer decides.So OS fixes reach FOCA's images, and every image built on them (proTES, cloud-registry, trs-filer, Pubgrade, Pubgrade-Sidecar), with the next build, without a Dockerfile change per advisory. As a trade-off, builds of the same commit at different times may differ in their OS packages. This includes release images, which are rebuilt at tag time. The docs say so.
The test of the base stage (
tests/test_image_requirements.py) now checks the general upgrade step. Docs are updated: getting started (Docker), deployment (image scans), contributing (image scan, base images, release flow), and the 0.22.0 release notes (Security).After 0.22.0 is released and downstream images move to it, the temporary Trivy ignores of the zlib1g findings in Pubgrade-Sidecar and cloud-registry (expiring 2026-11-30) can be removed.
Closes #747
Verification
pytest tests/test_image_requirements.py: 18 passed. The new test failed before the Dockerfile change.ruff check,ruff format --check,mypy: pass.mkdocs build --strict: passes.docker build --no-cache -f docker/Dockerfile --build-arg PY_IMAGE=3.X-slim-trixie .(3.11 to 3.15). All have apt 3.0.4 and zlib1g1:1.3.dfsg+really1.3.1-1+deb13u1, andimport focaworks.aquasec/trivy:latest image --scanners vuln --ignore-unfixed --ignorefile .trivyignore.yaml):elixircloud/foca:20261107-py3.13(dev, d5595dc): 3 fixable findings, all zlib1g (CVE-2026-76844 HIGH, CVE-2026-85091 HIGH, CVE-2026-27171 MEDIUM).Scan imagepasses for Python 3.11 to 3.15; no open code scanning alerts for the PR.Reviews
adversarial-reviewerandquality-reviewerran in round 1, andadversarial-reviewerran again in round 2. All findings were fixed:--with-new-pkgs.Declined review findings
release.yml. That changes the release workflow, which is out of scope here. The OS package drift of release images is documented instead, and the release scan still gates publishing.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Install available Debian OS updates during image builds so released security fixes reach FOCA and downstream images without per-advisory Dockerfile changes.
Bug Fixes:
Enhancements:
Documentation:
Tests: