Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(report): Include verbose message if no results found #7748

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/report/table/misconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strings"

"github.com/aquasecurity/trivy/pkg/log"
"github.com/fatih/color"
"golang.org/x/term"

Expand Down Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions pkg/report/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"slices"
"strings"

"github.com/aquasecurity/trivy/pkg/log"
"github.com/fatih/color"

"github.com/aquasecurity/table"
Expand Down Expand Up @@ -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")
}
Comment on lines +57 to +59
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we drop the return value and since logger isn't passed in, it's makes it hard to test this.


for _, result := range report.Results {
// Not display a table of custom resources
Expand All @@ -61,6 +65,7 @@ func (tw Writer) Write(_ context.Context, report types.Report) error {
}
tw.write(result)
}

return nil
}

Expand Down
Loading