From 5c0973cea9048514879b9553b70dac883228b696 Mon Sep 17 00:00:00 2001 From: Simar Date: Tue, 15 Oct 2024 17:45:29 -0600 Subject: [PATCH] feat(report): Include verbose message if no results found --- pkg/report/table/misconfig.go | 3 +++ pkg/report/table/table.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/pkg/report/table/misconfig.go b/pkg/report/table/misconfig.go index 112d783d0875..c7c6b824cc23 100644 --- a/pkg/report/table/misconfig.go +++ b/pkg/report/table/misconfig.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/aquasecurity/trivy/pkg/log" "github.com/fatih/color" "golang.org/x/term" @@ -53,8 +54,10 @@ func (r *misconfigRenderer) Render() string { // Trivy doesn't currently support showing suppressed misconfigs // So just skip this result if len(r.result.Misconfigurations) == 0 { + log.Info("No results found") return "" } + target := fmt.Sprintf("%s (%s)", r.result.Target, r.result.Type) RenderTarget(r.w, target, r.ansi) diff --git a/pkg/report/table/table.go b/pkg/report/table/table.go index 8bfa75922013..47ad4b41ef9e 100644 --- a/pkg/report/table/table.go +++ b/pkg/report/table/table.go @@ -9,6 +9,7 @@ import ( "slices" "strings" + "github.com/aquasecurity/trivy/pkg/log" "github.com/fatih/color" "github.com/aquasecurity/table" @@ -53,6 +54,9 @@ type Renderer interface { // Write writes the result on standard output func (tw Writer) Write(_ context.Context, report types.Report) error { + if len(report.Results) == 0 { + log.Info("No results found") + } for _, result := range report.Results { // Not display a table of custom resources @@ -61,6 +65,7 @@ func (tw Writer) Write(_ context.Context, report types.Report) error { } tw.write(result) } + return nil }