Merge pull request #45 from anchore/fix-duplicate-options

deduplicate json presenter + add pkg type
This commit is contained in:
Alex Goodman 2020-07-10 09:32:11 -04:00 committed by GitHub
commit 350cf11a29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 8 deletions

View file

@ -27,6 +27,7 @@ type ResultObj struct {
type Package struct {
Name string `json:"name"`
Version string `json:"version"`
Type string `json:"type"`
}
// Present creates a JSON-based reporting
@ -35,18 +36,12 @@ func (pres *Presenter) Present(output io.Writer, catalog *pkg.Catalog, results r
for match := range results.Enumerate() {
pkg := catalog.Package(match.Package.ID())
doc = append(
doc,
ResultObj{
Cve: match.Vulnerability.ID,
Package: Package{Name: pkg.Name, Version: pkg.Version}},
)
doc = append(
doc,
ResultObj{
Cve: match.Vulnerability.ID,
Package: Package{Name: pkg.Name, Version: pkg.Version}},
Package: Package{Name: pkg.Name, Version: pkg.Version, Type: pkg.Type.String()}},
)
}

View file

@ -1 +1 @@
[{"cve":"CVE-1999-0001","package":{"name":"package-1","version":"1.0.1"}},{"cve":"CVE-1999-0001","package":{"name":"package-1","version":"1.0.1"}},{"cve":"CVE-1999-0002","package":{"name":"package-1","version":"1.0.1"}},{"cve":"CVE-1999-0002","package":{"name":"package-1","version":"1.0.1"}}]
[{"cve":"CVE-1999-0001","package":{"name":"package-1","version":"1.0.1","type":"deb"}},{"cve":"CVE-1999-0002","package":{"name":"package-1","version":"1.0.1","type":"deb"}}]