Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit code 1 not leading to a failed CI/CD when using format sarif #228

Closed
VictorDelCampo opened this issue Apr 19, 2023 · 4 comments · Fixed by #247
Closed

Exit code 1 not leading to a failed CI/CD when using format sarif #228

VictorDelCampo opened this issue Apr 19, 2023 · 4 comments · Fixed by #247

Comments

@VictorDelCampo
Copy link

We have been running trivy scans for different docker images on our github pipeline for a while using the following pattern:

image

We keep upgrading the version of the trivy action using the commit SHA.

Since a couple of updates we have realized that even if the scan finds HIGH/CRITICAL vulnerabilities, the step is not failed as expected using the exit-code = 1. We do see the vulnerability in the security tab and even the pipeline run linked in that page that produced that vulnerability, but the pipeline run did NOT fail as it used to do before.

We have run the pipeline locally with act and observed the exactly same behaviour. We came to the conclusion that as soon as the format "sarif" with an "output" are used, the exit-code is completely ignored.

This is not the case when running the trivy package itself on the very same image using the following command:

trivy image --exit-code 1 --severity HIGH,CRITICAL --format sarif -o trivy-results.sarif [image+tag]

This command returns an exit code of 1 if HIGH/CRITICAL vulnerabilities were found.

For now we are manually checking the sarif file and consequently producing an exit-code 1 if HIGH/CRITICAL vulnerabilities were found but it would be great if you could have a look.

Thanks a lot!

JulianRoesner added a commit to digitalservicebund/useid-backend-service that referenced this issue Apr 26, 2023
As mentioned in [this issue](aquasecurity/trivy-action#228) somehow the exit codes are not set correctly. Therefore, we are for now checking the scan results in an additional step
@VictorDelCampo
Copy link
Author

@rogercoll I just tested your latest commit and the bug with sarif + exit-code is still there.

@dnaprawa
Copy link

dnaprawa commented Sep 1, 2023

+1 – I have experienced the same problem for fs type scanning. When format is table – the job is failed, when sarif it is passed even if there are critical vulnerabilities

@simao-silva
Copy link
Contributor

I can confirm that #247 solves the issue.

simar7 pushed a commit that referenced this issue Nov 7, 2023
This change moves the return code to outside the trivy call. This fixes
#228 as the return code was not being propagated.
@simao-silva
Copy link
Contributor

Found this bug again. It still shows when using format: "sarif" and skip-files together.
Should this issue be reopened or create a new one?

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 a pull request may close this issue.

3 participants