diff --git a/vulns.go b/vulns.go index 27a59be8..b9e89e4b 100644 --- a/vulns.go +++ b/vulns.go @@ -87,6 +87,11 @@ func (cmd *vulnsCommand) Run(ctx context.Context, args []string) error { } } + if len(report.VulnsBySeverity) < 1 { + fmt.Println("No vulnerabilies found.") + return nil + } + // Print summary and count. for sev, vulns := range report.VulnsBySeverity { fmt.Printf("%s: %d\n", sev, len(vulns)) diff --git a/vulns_test.go b/vulns_test.go index 22b1c6de..e4c92276 100644 --- a/vulns_test.go +++ b/vulns_test.go @@ -12,7 +12,8 @@ func TestVulns(t *testing.T) { t.Fatalf("output: %s, error: %v", out, err) } - expected := `clair.clair resp.Status=200 OK` + expected := `clair.clair resp.Status=200 OK +No vulnerabilies found.` if !strings.HasSuffix(strings.TrimSpace(out), expected) { t.Fatalf("expected: %s\ngot: %s", expected, out) }