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

🐛 Handle osvscanner errors on projects with no dependencies #3803

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clients/osv.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func (v osvClient) ListUnfixedVulnerabilities(

response := VulnerabilitiesResponse{}

if err == nil { // No vulns found
// either no vulns found, or no packages detected by osvscanner, which likely means no vulns
// while there could still be vulns, not detecting any packages shouldn't be a runtime error.
if err == nil || errors.Is(err, osvscanner.NoPackagesFoundErr) {
spencerschrock marked this conversation as resolved.
Show resolved Hide resolved
return response, nil
}

Expand Down
11 changes: 11 additions & 0 deletions clients/osv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package clients

import (
"context"
"reflect"
"testing"
)
Expand Down Expand Up @@ -46,3 +47,13 @@
})
}
}

func TestEmptyProject(t *testing.T) {

Check failure on line 51 in clients/osv_test.go

View workflow job for this annotation

GitHub Actions / check-linter

Function TestEmptyProject missing the call to method parallel
var client osvClient
var commit string
emptyDir := t.TempDir()
_, err := client.ListUnfixedVulnerabilities(context.Background(), commit, emptyDir)
if err != nil {
t.Fatalf("empty directory shouldn't throw an error: %v", err)
}
}
Loading