Skip to content

Conversation

@mdrohmann
Copy link
Contributor

@mdrohmann mdrohmann commented Feb 5, 2021

@mdrohmann mdrohmann changed the base branch from master to martind/state-cve-176449951 February 8, 2021 17:36
Copy link
Member

@MDrakos MDrakos left a 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.

mdrohmann and others added 2 commits February 8, 2021 13:46
Co-authored-by: Mike Drakos <miked@activestate.com>
@mdrohmann mdrohmann requested a review from Naatan February 8, 2021 21:52
func newReportCommand(prime *primer.Values) *captain.Command {
report := cve.NewReport(prime)
params := cve.ReportParams{
Namespace: &project.Namespaced{},
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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,
})
}
}
Copy link
Contributor

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?

}
visited[v.Name] = struct{}{}

cves := make(map[string][]medmodel.Vulnerability)
Copy link
Contributor

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.

@mdrohmann mdrohmann requested a review from Naatan February 8, 2021 23:11
@mdrohmann mdrohmann merged commit 6bc0a83 into martind/state-cve-176449951 Feb 9, 2021
@mdrohmann mdrohmann deleted the martind/state-cve-report-176449977 branch February 9, 2021 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants