Skip to content

Conversation

@bdossantos
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings November 28, 2025 13:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Trivy vulnerability scanning to the Docker build and publish GitHub Action workflow. The scanner is configured to fail the build on critical and high severity vulnerabilities in OS and library dependencies, while ignoring unfixed issues.

Key changes:

  • Introduced a scan_image variable to specify which image tag to scan
  • Added a new Trivy scanning step that runs after the Docker image is built and pushed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

version=$(egrep ' VERSION=(.*)$' '${{ inputs.dockerfile }}' | sed 's/^.*=//')
vcs_ref=$(git rev-parse --short HEAD)
image_name=$(cd $(dirname ${{ inputs.dockerfile }}) && echo "${PWD##*/}")
scan_image=bdossantos/${image_name}:${version}-${vcs_ref}
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

The scan_image variable is defined but never added to $GITHUB_OUTPUT. It needs to be exported with echo \"scan_image=${scan_image}\" >> $GITHUB_OUTPUT to be accessible in step 'Run Trivy vulnerability scanner' at line 59.

Copilot uses AI. Check for mistakes.
tags: ${{ steps.context.outputs.tags }}

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.33.1
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider pinning the action to a full commit SHA instead of a tag version (e.g., aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b9ceae441) for better security and immutability, especially since dependabot is configured to manage GitHub Actions updates.

Suggested change
uses: aquasecurity/trivy-action@0.33.1
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b9ceae441

Copilot uses AI. Check for mistakes.
Comment on lines 56 to 64
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.33.1
with:
image-ref: ${{ steps.context.outputs.scan_image }}
format: table
exit-code: 1
ignore-unfixed: true
vuln-type: os,library
severity: CRITICAL,HIGH
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

The Trivy scan will run even for pull requests, but the image won't be pushed (line 53 shows push: ${{ github.event_name != 'pull_request' }}). This means Trivy will fail because the image won't exist in the registry. Consider adding a condition if: ${{ github.event_name != 'pull_request' }} to this step, or use scan-type: fs to scan the build context instead for PRs.

Copilot uses AI. Check for mistakes.
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.

2 participants