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

refactor(redhat-oval): return an error if the CPE is not found #428

Merged
Show file tree
Hide file tree
Changes from all commits
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: 4 additions & 0 deletions pkg/vulnsrc/redhat-oval/redhat-oval.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ func (vs VulnSrc) Get(pkgName string, repositories, nvrs []string) ([]types.Advi
return nil, xerrors.Errorf("CPE convert error: %w", err)
}

if len(cpeIndices) == 0 {
return nil, xerrors.Errorf("unable to find CPE indices. See https://github.com/aquasecurity/trivy-db/issues/435 for details")
}

rawAdvisories, err := vs.dbc.ForEachAdvisory([]string{rootBucket}, pkgName)
if err != nil {
return nil, xerrors.Errorf("unable to iterate advisories: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/vulnsrc/redhat-oval/redhat-oval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ func TestVulnSrc_Get(t *testing.T) {
"testdata/fixtures/happy.yaml",
"testdata/fixtures/cpe.yaml",
},
want: []types.Advisory(nil),
wantErr: "unable to find CPE indices.",
},
{
name: "no advisory bucket",
Expand All @@ -936,7 +936,7 @@ func TestVulnSrc_Get(t *testing.T) {
repositories: []string{"rhel-8-for-x86_64-baseos-rpms"},
},
fixtures: []string{"testdata/fixtures/happy.yaml"},
want: []types.Advisory(nil),
wantErr: "unable to find CPE indices.",
},
{
name: "broken JSON",
Expand Down