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

feat(redhat-oval): fill DataSource field in Advisories from Get function #323

Merged
merged 2 commits into from
Jun 30, 2023
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
1 change: 1 addition & 0 deletions pkg/vulnsrc/redhat-oval/redhat-oval.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ func (vs VulnSrc) Get(pkgName string, repositories, nvrs []string) ([]types.Advi
FixedVersion: entry.FixedVersion,
Arches: entry.Arches,
State: entry.State,
DataSource: &v.Source,
}

if strings.HasPrefix(vulnID, "CVE-") {
Expand Down
45 changes: 22 additions & 23 deletions pkg/vulnsrc/redhat-oval/redhat-oval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,39 +487,28 @@ func TestVulnSrc_Get(t *testing.T) {
pkgName: "bind",
repositories: []string{"rhel-8-for-x86_64-baseos-rpms"},
},
fixtures: []string{"testdata/fixtures/happy.yaml", "testdata/fixtures/cpe.yaml"},
want: []types.Advisory{
{
VulnerabilityID: "CVE-2017-3145",
VendorIDs: []string{"RHSA-2018:0488"},
Severity: types.SeverityHigh,
FixedVersion: "32:9.9.4-29.el7_2.8",
Arches: []string{"i386", "ppc64", "x86_64"},
},
{
VulnerabilityID: "CVE-2020-8625",
Severity: types.SeverityLow,
},
},
},
{
name: "nvr",
args: args{
pkgName: "bind",
nvrs: []string{"ubi8-init-container-8.0-7-x86_64"},
},
fixtures: []string{"testdata/fixtures/happy.yaml", "testdata/fixtures/cpe.yaml"},
fixtures: []string{"testdata/fixtures/happy.yaml", "testdata/fixtures/cpe.yaml", "testdata/fixtures/data-source.yaml"},
want: []types.Advisory{
{
VulnerabilityID: "CVE-2017-3145",
VendorIDs: []string{"RHSA-2018:0488"},
Severity: types.SeverityHigh,
FixedVersion: "32:9.9.4-29.el7_2.8",
Arches: []string{"i386", "ppc64", "x86_64"},
DataSource: &types.DataSource{
ID: vulnerability.RedHatOVAL,
Name: "Red Hat OVAL v2",
URL: "https://www.redhat.com/security/data/oval/v2/",
},
},
{
VulnerabilityID: "CVE-2020-8625",
Severity: types.SeverityLow,
DataSource: &types.DataSource{
ID: vulnerability.RedHatOVAL,
Name: "Red Hat OVAL v2",
URL: "https://www.redhat.com/security/data/oval/v2/",
},
},
},
},
Expand All @@ -529,18 +518,28 @@ func TestVulnSrc_Get(t *testing.T) {
pkgName: "bind",
nvrs: []string{"ubi8-init-container-8.0-7-x86_64"},
},
fixtures: []string{"testdata/fixtures/happy.yaml", "testdata/fixtures/cpe.yaml"},
fixtures: []string{"testdata/fixtures/happy.yaml", "testdata/fixtures/cpe.yaml", "testdata/fixtures/data-source.yaml"},
want: []types.Advisory{
{
VulnerabilityID: "CVE-2017-3145",
VendorIDs: []string{"RHSA-2018:0488"},
Severity: types.SeverityHigh,
FixedVersion: "32:9.9.4-29.el7_2.8",
Arches: []string{"i386", "ppc64", "x86_64"},
DataSource: &types.DataSource{
ID: vulnerability.RedHatOVAL,
Name: "Red Hat OVAL v2",
URL: "https://www.redhat.com/security/data/oval/v2/",
},
},
{
VulnerabilityID: "CVE-2020-8625",
Severity: types.SeverityLow,
DataSource: &types.DataSource{
ID: vulnerability.RedHatOVAL,
Name: "Red Hat OVAL v2",
URL: "https://www.redhat.com/security/data/oval/v2/",
},
},
},
},
Expand Down
7 changes: 7 additions & 0 deletions pkg/vulnsrc/redhat-oval/testdata/fixtures/data-source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- bucket: data-source
pairs:
- key: Red Hat
value:
ID: "redhat-oval"
Name: "Red Hat OVAL v2"
URL: "https://www.redhat.com/security/data/oval/v2/"