Skip to content

devops: reusable dockerfile scan workflow - #77

Merged
landsman merged 1 commit into
mainfrom
devops/dockerfile-scan-workflow
Aug 9, 2026
Merged

devops: reusable dockerfile scan workflow#77
landsman merged 1 commit into
mainfrom
devops/dockerfile-scan-workflow

Conversation

@landsman

@landsman landsman commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Same idea as semgrep.yml: one copy of the scan here, every repo with a Dockerfile calls it.

jobs:
  dockerfile:
    uses: landsman/config/.github/workflows/dockerfile.yml@main
    with:
      dockerfile: github-runner/Dockerfile

That replaces the two trivy-action steps currently pasted into the caller.

The base image is read off the FROM line, not passed in. A tag written both in the workflow and in the Dockerfile drifts silently green — Dependabot bumps the Dockerfile, the workflow keeps scanning last year's image and keeps passing. The image: input stays for the one case that cannot be read: a FROM assembled from an ARG.

Multi-stage takes the last FROM that is not an earlier stage, which is the image the container actually runs on; --platform= flags and scratch are handled. Parser checked against nine Dockerfile shapes before committing.

Both scans exit 1 on a finding. Trivy's default is exit 0 with the findings printed, which is a check that cannot fail — this is a behaviour change from the pasted version, whose config step could not go red. CRITICAL,HIGH on both, so the misconfig scan does not fail on style.

Named for what it checks rather than for trivy, so replacing the scanner later does not rename the job in every caller.

… trivy config

The two trivy steps were copied into a repo by hand, with the base image tag
written a second time next to the Dockerfile's FROM — a copy that goes stale
green: Dependabot bumps the Dockerfile, the workflow keeps scanning the old
tag and keeps passing. Here the image is read off the FROM line instead.

Both scans exit 1 on a finding. Trivy's default is exit 0 with the findings
printed, which is a check that cannot fail.

Named for what it checks, not for trivy, so swapping the scanner later does
not rename the job in every caller.
@landsman
landsman merged commit 7785514 into main Aug 9, 2026
3 checks passed
@landsman
landsman deleted the devops/dockerfile-scan-workflow branch August 9, 2026 17:19
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.

1 participant