Skip to content

fix: trivy scan should exit with failure code#310

Open
alpe wants to merge 1 commit intollm-d:mainfrom
alpe:alex/ci_trivy
Open

fix: trivy scan should exit with failure code#310
alpe wants to merge 1 commit intollm-d:mainfrom
alpe:alex/ci_trivy

Conversation

@alpe
Copy link
Contributor

@alpe alpe commented Feb 13, 2026

Not sure if it runs for information purpose only but without the exit code param, it does not fail the build.

Copilot AI review requested due to automatic review settings February 13, 2026 12:22
Copy link
Contributor

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 updates the repository’s composite GitHub Action used for container image vulnerability scanning so that Trivy findings (HIGH/CRITICAL) will fail the workflow, preventing releases/builds from succeeding when severe vulnerabilities are detected.

Changes:

  • Add Trivy’s --exit-code 1 flag to make the scan fail the job when matching vulnerabilities are found.

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

- name: Scan image
run: |
trivy image --severity HIGH,CRITICAL --no-progress ${{ inputs.image }}
trivy image --severity HIGH,CRITICAL --exit-code 1 --no-progress ${{ inputs.image }}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The image reference is injected into a bash command without quoting. If the upstream workflow ever passes a tag/name containing shell metacharacters (e.g., from GITHUB_REF), this can break the command or enable shell injection. Quote the image input when invoking trivy (and consider similar quoting in other composite actions).

Suggested change
trivy image --severity HIGH,CRITICAL --exit-code 1 --no-progress ${{ inputs.image }}
trivy image --severity HIGH,CRITICAL --exit-code 1 --no-progress "${{ inputs.image }}"

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