Skip to content

ci(image-scan): scan the newest published images and pin Trivy by digest - #612

Merged
jsenecal merged 3 commits into
mainfrom
ci/520-image-scan
Nov 25, 2026
Merged

jsenecal merged 3 commits into
mainfrom
ci/520-image-scan

Conversation

@jsenecal

Copy link
Copy Markdown
Collaborator

Closes #520

The weekly published image scan defaulted to latest, which is published only for a stable version. No stable version exists yet, so every scheduled run logged "not published" and passed without scanning anything.

Changes

  • A new resolve job reads the GHCR tag list anonymously (the same access Trivy uses) and picks:
    • the newest version tag by semver precedence (3.0.0-rc.2 today; a prerelease sorts before its version),
    • latest, once a stable version tag exists. Before that it logs a notice; after it, a missing latest is an error,
    • the newest sha-<commit> image of main, found by walking the last 100 commits on main.
      Each tag is resolved to its manifest digest with the pinned buildx, and tags that share a digest are scanned once. The run fails if no version tag or main image is found. When newer main commits have no image, a notice gives how many were skipped and the commit and date of the image scanned, so a broken publish job shows up.
  • Registry and API calls retry transient errors: curl retries timeouts, refused connections and 408/429/5xx (not 404), and the buildx lookup and commit listing retry three times. "Not found" fails at once.
  • The resolve job runs only in hyperglass-community/hyperglass, so forks don't go red every week. Timeouts: 10 minutes for resolve, 30 for each scan.
  • A scan matrix job runs Trivy on each digest, with fail-fast: false, so one finding doesn't hide the other images' results.
  • Trivy runs as aquasec/trivy:${TRIVY_VERSION}@${TRIVY_DIGEST}, the same pair as ci.yml. The existing Renovate regex manager already matches the version line followed by the digest line, so it updates this file along with ci.yml.
  • Trivy pulls the image by registry digest itself, as the release-image job does. The runner no longer pulls the image or mounts the Docker socket, and the registry login is gone.
  • Permissions are now {} at the workflow level, with contents: read only on resolve.
  • The workflow_dispatch input tag is now optional with an empty default. Empty scans the default set; a tag scans only that tag and fails if it isn't published. The input is checked against the OCI tag grammar and is never echoed into a workflow command.

Verification

  • actionlint 1.7.12 with shellcheck 0.11.0 reports nothing.
  • I ran the resolve script locally against GHCR. Default set: 3.0.0-rc.2 and sha-f345e88d…, plus a notice for latest. tag=3.0.0-rc.2 resolves; tag=latest and an invalid tag fail. Pagination works with a page size of 7 (15 pages). With the newest main commit's image hidden, the skipped-commit notice appears and the previous commit's image is used, and against an unreachable registry the lookup retries three times and then fails.
  • The TRIVY_DIGEST matches docker buildx imagetools inspect aquasec/trivy:0.74.0.
  • I ran the exact Trivy command without the socket against both digests. The main image is clean. 3.0.0-rc.2 has one fixable HIGH (libxml2 CVE-2026-86144, fixed in 2.13.9-r3), so the first run after merge is expected to fail on that leg. That is the scan doing its job. The fix is the next release, since the main image already has it.

Testing after merge

Run "Published image scan" from the Actions tab (workflow_dispatch) with tag left empty. The resolve job's summary lists the tags and digests, and each one gets its own scan job. To test a single image, run it with tag set, for example 3.0.0-rc.2.

The weekly scan defaulted to `latest`, which is published only for a
stable version, so every run logged "not published" and passed without
scanning anything.

A scheduled run now resolves the newest version tag from the registry,
`latest` when a stable version exists, and the newest sha- image of
main, and scans each digest once. It fails when an expected image is
missing. Trivy runs by the same TRIVY_VERSION and TRIVY_DIGEST pair as
ci.yml and pulls the image by digest, without the Docker socket.

Closes #520
Retry transient registry and API errors so a single GHCR 5xx does not
fail the run, while a missing tag still fails at once. Report how many
newer main commits had no published image and which commit was scanned,
so a broken publish job is visible. Skip the scan on forks, keep the raw
tag input out of workflow commands, and bound both jobs with timeouts.
@github-actions github-actions Bot added the ci Build, test and release pipelines label Nov 24, 2026
@coveralls

coveralls commented Nov 24, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 89.198%. remained the same — ci/520-image-scan into main

@jsenecal
jsenecal marked this pull request as ready for review November 25, 2026 20:24
@jsenecal
jsenecal requested a review from WilhelmZA November 25, 2026 20:24

@WilhelmZA WilhelmZA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 4eef5526.

GitHub marks the head merge commit as unverified because the commit email is not verified. Please recreate the merge commit using a verified commit email, sign it, and push again. Every commit must show as verified before approval.

@WilhelmZA WilhelmZA added container Docker image and compose docs Improve documentation reviewing Issue is being reviewed by maintainers security Hardening and security-relevant changes labels Nov 25, 2026
@jsenecal

Copy link
Copy Markdown
Collaborator Author

Thanks. The merge commit was made with a wrong local commit email. It's recreated with the verified address and signed, with the same parents and the same tree, so the content is unchanged. The new head is b442393b, and every commit on this PR now shows as verified.

@jsenecal
jsenecal requested a review from WilhelmZA November 25, 2026 20:45

@WilhelmZA WilhelmZA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at b442393b.

Checked image selection, digest pinning and CI; all commits now verify.

@jsenecal
jsenecal merged commit b487240 into main Nov 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Build, test and release pipelines container Docker image and compose docs Improve documentation reviewing Issue is being reviewed by maintainers security Hardening and security-relevant changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weekly image scan scans nothing before 3.0.0 and runs Trivy by tag

3 participants