-
Notifications
You must be signed in to change notification settings - Fork 14
Add state cve report #1240
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 state cve report #1240
Conversation
MDrakos
left a comment
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.
Makes sense. My comments are just nits and suggestions.
Co-authored-by: Mike Drakos <miked@activestate.com>
| func newReportCommand(prime *primer.Values) *captain.Command { | ||
| report := cve.NewReport(prime) | ||
| params := cve.ReportParams{ | ||
| Namespace: &project.Namespaced{}, |
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.
Why initialize an empty namespace? Shouldn't this be nil if it wasn't provided?
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.
This is how we did in other places to set the namespace as an argument, by calling its Set() method as required by the ArgMarshaler interface.
internal/runners/cve/report.go
Outdated
| var packageVulnerabilities []DetailedByPackageOutput | ||
| visited := make(map[string]struct{}) | ||
| for _, v := range resp.Project.Commit.Ingredients { | ||
| if len(v.Vulnerabilities) == 0 { | ||
| continue | ||
| } | ||
|
|
||
| // Remove this block with story https://www.pivotaltracker.com/story/show/176508772 | ||
| // filter double entries | ||
| if _, ok := visited[v.Name]; ok { | ||
| continue | ||
| } | ||
| visited[v.Name] = struct{}{} | ||
|
|
||
| cves := make(map[string][]medmodel.Vulnerability) | ||
| for _, ve := range v.Vulnerabilities { | ||
| if _, ok := cves[ve.Version]; !ok { | ||
| cves[ve.Version] = []medmodel.Vulnerability{} | ||
| } | ||
| cves[ve.Version] = append(cves[ve.Version], ve) | ||
| } | ||
|
|
||
| for ver, vuls := range cves { | ||
| packageVulnerabilities = append(packageVulnerabilities, DetailedByPackageOutput{ | ||
| v.Name, ver, vuls, | ||
| }) | ||
| } | ||
| } |
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.
Can we move this into the model?
internal/runners/cve/report.go
Outdated
| } | ||
| visited[v.Name] = struct{}{} | ||
|
|
||
| cves := make(map[string][]medmodel.Vulnerability) |
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.
If we're going to do post-processing on these types at least alias the type.
https://www.pivotaltracker.com/story/show/176449977