diff --git a/commands/detect.go b/commands/detect.go index 05e4652..7620d30 100644 --- a/commands/detect.go +++ b/commands/detect.go @@ -184,6 +184,9 @@ func renderCommit(image query.Image) string { func renderVulnerabilities(image query.Image) string { if len(image.Report) > 0 { report := image.Report[0] + if report.Total == -1 { + return " no CVE data available " + } parts := make([]string, 0) if report.Critical > 0 { parts = append(parts, " C"+strconv.FormatInt(report.Critical, 10)) @@ -201,5 +204,5 @@ func renderVulnerabilities(image query.Image) string { return strings.Join(parts, " ") + " " } } - return " no CVE data available " + return "" } diff --git a/query/index.go b/query/index.go index dbc00b7..ace3622 100644 --- a/query/index.go +++ b/query/index.go @@ -85,6 +85,9 @@ func ForBaseImageInIndex(digest digest.Digest, workspace string, apiKey string) CreatedAt: ii.CreatedAt, Tags: manifestList[0].Tags, Repository: *repository, + Report: []Report{{ + Total: -1, + }}, } return &[]Image{image}, nil } diff --git a/query/query.go b/query/query.go index 5e244be..cd629a9 100644 --- a/query/query.go +++ b/query/query.go @@ -36,6 +36,7 @@ type ManifestList struct { } type Report struct { + Total int64 `edn:"vulnerability.report/total"` Critical int64 `edn:"vulnerability.report/critical"` High int64 `edn:"vulnerability.report/high"` Medium int64 `edn:"vulnerability.report/medium"` diff --git a/registry/registry.go b/registry/registry.go index bf58742..c91a62b 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -48,7 +48,7 @@ func DigestForImage(dockerCli command.Cli, image string) ([]digest.Digest, error } // check local daemon first - img, err := daemon.Image(ref) + img, err := daemon.Image(ref, daemon.WithClient(dockerCli.Client())) if err != nil { // image doesn't exist in daemon; try remote index, _ := remote.Index(ref, remote.WithAuthFromKeychain(authn.DefaultKeychain))