Skip to content

ci: migrate Trivy image build-and-scan workflows - #248

Open
kkurzacz-intel wants to merge 10 commits into
mainfrom
kkurzacz/migrate-trivy-scans
Open

kkurzacz-intel wants to merge 10 commits into
mainfrom
kkurzacz/migrate-trivy-scans

Conversation

@kkurzacz-intel

@kkurzacz-intel kkurzacz-intel commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ports the scheduled image scan ("Sec :: Trivy") from the previous internal repository, along with its reusable workflows and result scripts.

  • trivy-images.yml: reads deployment/images.yaml (existing read-images-reusable.yml), builds and scans every image as a matrix, then merges the results into summary-all.csv (trivy-results-archive artifact).
  • trivy-build-and-scan-reusable.yml: docker build + docker save, uploads the tarball as image-<name>.
  • trivy-reusable.yml: Trivy v0.74.0 table / JSON / SDL scans on the tarball. It writes a per-image job summary, uploads trivy-<name> and exposes scan-status (error / vulnerable / clean).
  • .github/custom_tools/trivy/: post-processing and summary scripts plus the SDL config/template.

Changes vs. the original

  • Runs on intel-ubuntu-default. Everything internal is removed: CA certificates, proxy build args, the cache registry and the internal certs action.
  • skopeo and the Trivy container are dropped. Trivy comes from pinned aquasecurity/setup-trivy and scans the tarball with --input.
  • Result artifacts are prefixed with trivy-, so the summary job downloads only results and not the image tarballs.

Triggers

workflow_dispatch and weekly on Monday 00:00 UTC. schedule fires only on the default branch.

Testing

  • actionlint: clean, apart from the unknown custom runner label.
  • Ran the scan steps and scripts locally against an alpine tarball with Trivy 0.74.0.
  • Ran on this PR through a temporary pull_request trigger: images build, the cached Trivy DB is restored and the scans complete. The trigger was removed afterwards.

Scanned branch

A manual run scans the branch given in the branch input. The weekly run, and a manual run with an empty input, scan the branch in the repository variable TRIVY_DEFAULT_BRANCH. When neither is set, the triggering ref is scanned. The Trivy scripts and config always come from the workflow's own branch.

@kkurzacz-intel
kkurzacz-intel marked this pull request as draft December 2, 2026 18:43
Port the scheduled "Sec :: Trivy" image scan from the innersource repo
together with its reusable build/scan workflows and the result
post-processing scripts.

- Runs on intel-ubuntu-default; Intel certificates, proxy build args,
  the internal cache registry and the innersource certs action are dropped.
- Image is built with plain docker build and scanned from the saved tarball
  (trivy --input), so skopeo and the Trivy container are no longer needed.
- Trivy v0.74.0 via aquasecurity/setup-trivy, matching trivy.yml.
- Per-image results are uploaded as trivy-<image> so the summary job
  downloads only those, not the image tarballs.
- Triggers: workflow_dispatch, weekly on Monday, and PRs to release-3.1
  for testing.

Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
trivy.yml becomes trivy-code.yml ("Trivy - Code") and the image scan is named "Trivy - Images". The reusable build/scan workflows also move to the intel-ubuntu-latest runner.

Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
A trivy-db job downloads the vulnerability DB and saves it to the Actions cache under trivy-db-<run_id>. Each scan job restores it and runs with TRIVY_SKIP_DB_UPDATE, so the matrix no longer hits the DB registry once per image. A scan downloads the DB itself on a cache miss. setup-trivy now caches the Trivy binary.

Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
DOCKER_CONTEXT is read by the Docker CLI as the context/builder name, so docker build failed with 'no builder "src" found'. Use BUILD_CONTEXT instead. The summary job no longer fails when no scan produced results.

Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
The image list and the image builds check out vars.TRIVY_BRANCH, falling back to the triggering ref when it is unset. The run name shows the scanned branch.

Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
@kkurzacz-intel
kkurzacz-intel force-pushed the kkurzacz/migrate-trivy-scans branch from dedbe37 to dbd3610 Compare December 3, 2026 15:02
@kkurzacz-intel
kkurzacz-intel changed the base branch from release-3.1 to main December 3, 2026 15:02
@kkurzacz-intel kkurzacz-intel reopened this Dec 3, 2026
trivy-build-and-scan-reusable.yml becomes trivy-images-build-scan-reusable.yml and trivy-reusable.yml becomes trivy-images-scan-reusable.yml, with matching workflow names. The inner scan job is named Trivy so checks read '<image> / Scan / Trivy'.

Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
A manual run scans the 'branch' input and falls back to the TRIVY_BRANCH variable, which the weekly schedule uses. Runs for different branches no longer cancel each other. The pull_request trigger was only for testing the migration.

Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
@kkurzacz-intel
kkurzacz-intel marked this pull request as ready for review December 3, 2026 16:31
Comment thread .github/workflows/trivy-images.yml Dismissed

@mik-now mik-now left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, we could extend possibility to track if fix is available or we wait for upstream.

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.

3 participants