-
Notifications
You must be signed in to change notification settings - Fork 512
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
Terrascan does not exit with error code in pipeline or CLI #950
Comments
Hello @stefangreim, Thanks for reporting this issue. Terrascan exits with a non zero exit code (exit code 3) when there are violations found in the scan. In the example you have shared, since there were no violations, the exit code is zero. By default, when a directory scan is initiated, terrascan scans with all iac types it supports and doesn't exit when error occurs in an iac provider. Instead, the errors are collected and reported in the scan summary. |
Hello @patilpankaj212, Thanks for the answer! Ok, that means if no violations occur but another error occurs during the scan (e.g. something could not be cloned), the exit code is equal to 0. Correct? But as a workaround I could write the scan results to a file and check them for errors... |
Hello @stefangreim, We will fix the behaviour for the scenario where scan errors exist in the scan summary. Thanks. |
Hello @patilpankaj212, that's great news. Thank you very much! |
Description
I want to execute terrascan in a gitlab pipeline. I noticed that terrascan was not able to clone the relevant terraform modules, but instead of exiting the pipeline, the job succeeded.
My first guess was that I was losing the exit code due to a pipe in my command. But after some tests it is clear that this is not the case but exit code 0 is returned.
I have tested the following errors:
echo $? returns 0 in both cases and the pipeline reports "Job succeeded" although no proper scan took place.
I would have expected anything other than 0 to be returned in case of an error. Is there anything I can do to react to such errors?
What I Did
or, easier for testing (in an empty directory):
The text was updated successfully, but these errors were encountered: