Skip to content

Conversation

@jbern0rd
Copy link
Contributor

@jbern0rd jbern0rd commented Jan 8, 2026

Note

Tightens Docker image security in the CI workflow and defers pushing until after vulnerability checks.

  • Build a local linux/amd64 image with load: true (no push) for scanning
  • Upgrade aquasecurity/trivy-action to 0.33.1 and scan the built image via image-ref (remove tarball path)
  • Add gating step to fail the job on CRITICAL/HIGH vulnerabilities with fixes available (ignore-unfixed: true, exit-code: 1)
  • If checks pass, build and push multi-platform image using inputs.platforms; add cleanup of scan artifacts and local image

Written by Cursor Bugbot for commit 7e1a111. This will update automatically on new commits. Configure here.

@jbern0rd jbern0rd self-assigned this Jan 8, 2026
@jbern0rd jbern0rd changed the title feat: improve docker build feat: fail docker-build on CRITICAL or HIGH fixed vulnerabilities found with Trivy Jan 12, 2026
@jbern0rd jbern0rd changed the title feat: fail docker-build on CRITICAL or HIGH fixed vulnerabilities found with Trivy feat: fail docker-build on CRITICAL or HIGH vulnerabilities with fix available Jan 12, 2026
file: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
push: ${{ inputs.push }}
load: true # Make the image available on runner

Choose a reason for hiding this comment

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

⚠️ load: true is not compatible with multi-platform builds. Docker can only load a single architecture image locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see 0d18116

- name: Fail build on CRITICAL or HIGH vulnerabilities
if: ${{ inputs.security-scan }}
uses: aquasecurity/trivy-action@0.33.1

Choose a reason for hiding this comment

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

Trivy is executed twice (around line 88).
In my opinion, we can merge this into a single scan using exit-code: 1.
If we still want to publish the report before failing, we can use continue-on-error and then check the exit code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trivy is executed twice to allow for a full scan and a restrictive scan only on CRITICAL and HIGH.
This can be improved and is inspired by
https://github.com/aquasecurity/trivy-action?tab=readme-ov-file#skipping-setup-when-calling-trivy-action-multiple-times

skip-setup-trivy: true
exit-code: 1

- name: Build and push Docker image

Choose a reason for hiding this comment

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

There is a double build. I think we can push the already built image after it has been scanned, without rebuilding the image again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only works if load can be used, in the other case, the tag is not created locally and the image is not available through docker client

Comment on lines +200 to +209
- name: Build and push Docker image
if: ${{ inputs.push }}
uses: docker/build-push-action@v6
with:
build-args: ${{ inputs.build-args }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
push: true
tags: ${{ inputs.image-name }}:${{ inputs.image-tag }}

Choose a reason for hiding this comment

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

Suggested change
- name: Build and push Docker image
if: ${{ inputs.push }}
uses: docker/build-push-action@v6
with:
build-args: ${{ inputs.build-args }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
push: true
tags: ${{ inputs.image-name }}:${{ inputs.image-tag }}
- name: Push Docker image
if: ${{ inputs.push }}
run: docker push ${{ inputs.image-name }}:${{ inputs.image-tag }}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I do this, with a single platform build, multi-platform build will be broken.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

file: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
push: ${{ inputs.push }}
platforms: "linux/amd64"
Copy link

Choose a reason for hiding this comment

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

Security scan only covers one platform, not all pushed

High Severity

The security scan only runs on the linux/amd64 image (hardcoded at line 83), but the final push step uses ${{ inputs.platforms }} which defaults to "linux/amd64,linux/arm64". This means arm64 images (and any other non-amd64 platforms) are pushed to the registry without being scanned for vulnerabilities. Different architectures can have different base images with different vulnerabilities, defeating the purpose of failing builds on CRITICAL or HIGH vulnerabilities.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

4 participants