File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ const (
2020 WebKind osvReferenceKind = "WEB"
2121 PackageKind osvReferenceKind = "PACKAGE"
2222 osvTimeout = 5 * time .Minute
23+ // https://google.github.io/osv-scanner/output/#return-codes
24+ osvReturnCodeSuccess int = 0
25+ osvReturnCodeVulnsFound int = 1
26+ osvReturnCodeNoPackages int = 128
2327)
2428
2529type osvSource struct {
@@ -116,10 +120,13 @@ func (s *osvScanner) Scan(dir string) (*OsvReport, error) {
116120 )
117121
118122 //Handle exit codes according to https://google.github.io/osv-scanner/output/#return-codes
119- if cmdOut .ExitCode == 0 && err == nil {
123+ if cmdOut .ExitCode == osvReturnCodeSuccess && err == nil {
120124 // Successful run of osv-scanner, no report because no vulnerabilities found
121125 log .Debug ().Int ("exitCode" , cmdOut .ExitCode ).Msg ("osv-scanner did not find vulnerabilities" )
122126 return nil , nil
127+ } else if cmdOut .ExitCode == osvReturnCodeNoPackages {
128+ log .Warn ().Int ("exitCode" , cmdOut .ExitCode ).Msg ("osv-scanner did not find any packages to scan" )
129+ return nil , nil
123130 } else if cmdOut .ExitCode > 1 || cmdOut .ExitCode == - 1 {
124131 // Failed to run osv-scanner at all, or it returned an error
125132 log .Debug ().Int ("exitCode" , cmdOut .ExitCode ).Msg ("osv-scanner failed to run" )
You can’t perform that action at this time.
0 commit comments