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

csaf: read aggregate_severity #1466

Merged
merged 1 commit into from
Jan 10, 2025
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
17 changes: 13 additions & 4 deletions toolkit/types/csaf/csaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ type CSAF struct {
//
// https://docs.oasis-open.org/csaf/csaf/v2.0/os/csaf-v2.0-os.html#321-document-property
type DocumentMetadata struct {
Title string `json:"title"`
Tracking Tracking `json:"tracking"`
References []Reference `json:"references"`
Publisher Publisher `json:"publisher"`
Title string `json:"title"`
Tracking Tracking `json:"tracking"`
References []Reference `json:"references"`
Publisher Publisher `json:"publisher"`
AggregateSeverity AggregateSeverity `json:"aggregate_severity"`
}

// Document references holds a list of references associated with the whole document.
Expand Down Expand Up @@ -82,6 +83,14 @@ type Publisher struct {
Namespace string `json:"namespace"`
}

// AggregateSeverity provides information on the severity of one or more vulnerabilities in the document.
//
// https://docs.oasis-open.org/csaf/csaf/v2.0/os/csaf-v2.0-os.html#3212-document-property---aggregate-severity
type AggregateSeverity struct {
Namespace string `json:"namespace"`
Text string `json:"text"`
}

// Vulnerability contains information about a CVE and its associated threats.
//
// https://docs.oasis-open.org/csaf/csaf/v2.0/os/csaf-v2.0-os.html#323-vulnerabilities-property
Expand Down
16 changes: 16 additions & 0 deletions toolkit/types/csaf/csaf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var testBattery = []struct {
remediation *RemediationData
scoreProductID string
score *Score
severity AggregateSeverity
prodIdentifier *Product
threatProductID string
threatData *ThreatData
Expand All @@ -40,6 +41,10 @@ var testBattery = []struct {
},
remediation: nil, // no remediation data in this file
score: nil, // no score data in this file
severity: AggregateSeverity{
Namespace: "https://access.redhat.com/security/updates/classification/",
Text: "important",
},
prodIdentifier: &Product{
Name: "Red Hat Enterprise Linux 7",
ID: "red_hat_enterprise_linux_7",
Expand Down Expand Up @@ -73,6 +78,10 @@ var testBattery = []struct {
URL: "https://access.redhat.com/errata/RHSA-2022:0011",
},
score: nil, // no score for RHSAs
severity: AggregateSeverity{
Namespace: "https://access.redhat.com/security/updates/classification/",
Text: "Important",
},
prodIdentifier: &Product{
Name: "Red Hat Enterprise Linux Server E4S (v. 7.6)",
ID: "7Server-7.6.E4S",
Expand Down Expand Up @@ -111,6 +120,10 @@ var testBattery = []struct {
},
ProductIDs: []string{"red_hat_satellite_6:rubygem-audited"},
},
severity: AggregateSeverity{
Namespace: "https://access.redhat.com/security/updates/classification/",
Text: "low",
},
threatProductID: "red_hat_satellite_6:rubygem-audited",
threatData: &ThreatData{
Category: "impact",
Expand Down Expand Up @@ -146,6 +159,9 @@ func TestAll(t *testing.T) {
t.Log("advisory deleted", c.Document.Tracking.ID)
return
}
if !cmp.Equal(tc.severity, c.Document.AggregateSeverity) {
t.Error(cmp.Diff(tc.severity, c.Document.AggregateSeverity))
}
if got := c.ProductTree.FindProductByID(tc.product.ID); !cmp.Equal(tc.product, got) {
t.Error(cmp.Diff(tc.product, got))
}
Expand Down
Loading