Some images have just a binary (for example a go program) and trivy fails with the error:
2019-05-16T18:53:09.787+0100 FATAL error in image scan: failed to scan image: failed to analyze OS: Unknown OS
It also returns error code=1
We should have an option in the command line to return 0 as error code when the image OS isn't found as I want all my images to be scanned in the pipeline but the pipeline shouldn't fail because the scanner can't find the OS. I could wrap trivy with a shell script but I find in useless as it would be better to be included in the trivy command.
Thanks,
@nunofernandes Thank you for reporting an issue. I fixed not to give an error in the case of unsupported OS.
Awsome! Great work!
This seems to have regressed in version v0.3.1 (or earlier), I get the following for a FROM scratch image:
FATAL error in image scan: failed to scan the image: failed to analyze OS: Unknown OS
And since I call trivy with --exit-code 1 in my ci/cd pipeline this fails the step.
I guess this started happening when trivy start using the analyzer in the fanal repo, given that this returns an ErrUnknownOS at https://github.com/aquasecurity/fanal/blob/master/analyzer/analyzer.go#L161 which gets returned at https://github.com/aquasecurity/trivy/blob/master/pkg/scanner/ospkg/scan.go#L31-L34
I'm having the issue as well.
Ideally I would like to run Trivy for all my repositories, but some of the Docker images are Scratch based so Trivy returns a status code 1. It would be nice to have an option flag to return 0 if it's an unknown image.
Thanks!
Most helpful comment
This seems to have regressed in version
v0.3.1(or earlier), I get the following for aFROM scratchimage:And since I call trivy with
--exit-code 1in my ci/cd pipeline this fails the step.I guess this started happening when trivy start using the analyzer in the fanal repo, given that this returns an
ErrUnknownOSat https://github.com/aquasecurity/fanal/blob/master/analyzer/analyzer.go#L161 which gets returned at https://github.com/aquasecurity/trivy/blob/master/pkg/scanner/ospkg/scan.go#L31-L34