-
Notifications
You must be signed in to change notification settings - Fork 505
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
Add CVE Information to Release Notes #1441
Changes from 1 commit
d3fa4b7
15d64a3
2163900
181a262
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1086,3 +1086,41 @@ func (rn *ReleaseNote) ContentHash() (string, error) { | |
} | ||
return fmt.Sprintf("%x", h.Sum(nil)), nil | ||
} | ||
|
||
// Validate checks the data defined in a CVE map is complete and valid | ||
func (cve *CVEData) Validate() error { | ||
if cve.CVSSRating == "" { | ||
return errors.New("CVSS rating missing from CVE data") | ||
} | ||
|
||
// Check rating is a valid string | ||
if cve.CVSSRating != "None" && | ||
cve.CVSSRating != "Low" && | ||
cve.CVSSRating != "Medium" && | ||
cve.CVSSRating != "High" && | ||
cve.CVSSRating != "Critical" { | ||
return errors.New("Invalida CVSS rating") | ||
} | ||
|
||
if cve.CVSSVector == "" { | ||
return errors.New("CVSS vector string missing from CVE data") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a library that can validate the form is the expected CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:H sort of form? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying this one and seems to do the job just fine: https://github.com/spiegel-im-spiegel/go-cvss |
||
} | ||
|
||
if cve.CVSSScore == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should validate versus the known range of 0..10. |
||
return errors.New("CVSS score missing from CVE data") | ||
} | ||
|
||
if cve.ID == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this validate more that the id is of the expected form for a CVE? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✔️ Added a basic regexp validation |
||
return errors.New("ID missing from CVE data") | ||
} | ||
|
||
if cve.Title == "" { | ||
return errors.New("Title missing from CVE data") | ||
} | ||
|
||
if cve.Description == "" { | ||
return errors.New("CVE description missing from CVE data") | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see the new TrackingIssue perhaps being empty, but can't tell if that's intended. A couple changes to consider depending on if it is required or not
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've modified it to make the field optional. Once it is in use we can decide if we enforce it. |
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo -> Invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ Thanks!