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 2 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("No CPE indices found")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, xerrors.Errorf("No CPE indices found")
return nil, xerrors.Errorf("no CPE indices found")

Copy link
Collaborator

@knqyf263 knqyf263 Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this error message is unclear. What do you think about adding this issue to the error message?
#435

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It make sense.
Updated in 83716e8

}

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: "No CPE indices found",
},
{
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: "No CPE indices found",
},
{
name: "broken JSON",
Expand Down