Skip to content

fix(agent): pin base image digest, always rebuild for security scan#132

Merged
scottschreckengaust merged 2 commits into
mainfrom
fix/container-cves
May 19, 2026
Merged

fix(agent): pin base image digest, always rebuild for security scan#132
scottschreckengaust merged 2 commits into
mainfrom
fix/container-cves

Conversation

@scottschreckengaust
Copy link
Copy Markdown
Contributor

@scottschreckengaust scottschreckengaust commented May 19, 2026

Summary

  • Pin python:3.13-slim to SHA256 digest for reproducible, cacheable builds
  • Remove docker image inspect || build conditional — always rebuild ensures apt-get upgrade picks up latest Debian security patches

Problem

The pre-push security:image task only built the Docker image if it didn't exist locally. A stale cached image retained old unfixed packages, causing trivy to report CVEs that had already been patched upstream. Developers were forced to use --no-verify on every push.

Root cause

Not missing Dockerfile logic (the apt-get upgrade was already present) — but stale Docker layer cache from a previous build being reused indefinitely.

Changes

File Change
agent/Dockerfile Pin base image to python:3.13-slim@sha256:dc1546... for reproducibility
agent/mise.toml Always rebuild image (remove inspect-or-build conditional)

How it works

  • SHA digest pin — deterministic builds; Docker can cache layers against a known base. Dependabot (RFC: Automated toolchain version monitoring and upgrade workflow #104) can auto-bump this digest when upstream publishes security patches.
  • Always rebuildCACHE_BUST=$(date +%s) already ensures the apt-get upgrade layer is fresh. The old docker image inspect || build skip was defeating this by reusing a days-old local image.
  • Trivy --ignore-unfixed — already handles won't fix CVEs without needing a separate ignore file.

Test plan

  • Fresh docker build --no-cache + trivy --ignore-unfixed --severity HIGH,CRITICAL --exit-code 1 → exit 0
  • Pre-commit hooks pass
  • CI build passes

Related

🤖 Generated with Claude Code

scottschreckengaust and others added 2 commits May 19, 2026 05:13
The pre-push security scan failed on stale Docker layer cache — fixable
CVEs in the base image weren't picked up because the `security:image`
task skipped rebuilds when the image already existed locally.

- Pin `python:3.13-slim` to SHA256 digest for reproducible builds
- Remove `docker image inspect || build` conditional — always rebuild
  ensures `apt-get upgrade` picks up latest Debian security patches
- Add `.grype.yaml` with documented suppressions for won't-fix CVEs
  (glibc, curl, ncurses, libexpat, libtasn1, GnuTLS, GnuPG, CPython)

The existing `apt-get upgrade --no-install-recommends` in the Dockerfile
already handles fixable CVEs — the root cause was stale cache, not
missing upgrade logic.

Fixes #92

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The file is not picked up by any scanner — grype auto-discovers from
CWD (repo root), not agent/, and the image scan uses trivy with
--ignore-unfixed which already handles won't-fix CVEs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@scottschreckengaust scottschreckengaust marked this pull request as ready for review May 19, 2026 05:22
@scottschreckengaust scottschreckengaust requested a review from a team as a code owner May 19, 2026 05:22
@scottschreckengaust scottschreckengaust added this pull request to the merge queue May 19, 2026
Merged via the queue into main with commit 98aff27 May 19, 2026
9 checks passed
@scottschreckengaust scottschreckengaust deleted the fix/container-cves branch May 20, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent (Python runtime): container base image blocking pre-push hooks

2 participants