Add state cve report#1240
Merged
mdrohmann merged 9 commits intomartind/state-cve-176449951from Feb 9, 2021
Merged
Conversation
MDrakos
approved these changes
Feb 8, 2021
Member
MDrakos
left a comment
There was a problem hiding this comment.
Makes sense. My comments are just nits and suggestions.
Co-authored-by: Mike Drakos <miked@activestate.com>
Naatan
suggested changes
Feb 8, 2021
| func newReportCommand(prime *primer.Values) *captain.Command { | ||
| report := cve.NewReport(prime) | ||
| params := cve.ReportParams{ | ||
| Namespace: &project.Namespaced{}, |
Contributor
There was a problem hiding this comment.
Why initialize an empty namespace? Shouldn't this be nil if it wasn't provided?
Contributor
Author
There was a problem hiding this comment.
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
Comment on lines
80
to
107
| 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, | ||
| }) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Can we move this into the model?
internal/runners/cve/report.go
Outdated
| } | ||
| visited[v.Name] = struct{}{} | ||
|
|
||
| cves := make(map[string][]medmodel.Vulnerability) |
Contributor
There was a problem hiding this comment.
If we're going to do post-processing on these types at least alias the type.
Naatan
approved these changes
Feb 9, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://www.pivotaltracker.com/story/show/176449977