diff --git a/pkg/report/table/licensing.go b/pkg/report/table/licensing.go index 602dc9033e00..5b41d7d25cc1 100644 --- a/pkg/report/table/licensing.go +++ b/pkg/report/table/licensing.go @@ -39,6 +39,12 @@ func NewPkgLicenseRenderer(result types.Result, isTerminal bool, severities []db } func (r pkgLicenseRenderer) Render() string { + // Trivy doesn't currently support showing suppressed licenses + // So just skip this result + if len(r.result.Licenses) == 0 { + return "" + } + r.setHeaders() r.setRows() @@ -54,7 +60,12 @@ func (r pkgLicenseRenderer) Render() string { } func (r pkgLicenseRenderer) setHeaders() { - header := []string{"Package", "License", "Classification", "Severity"} + header := []string{ + "Package", + "License", + "Classification", + "Severity", + } r.tableWriter.SetHeaders(header...) } @@ -63,11 +74,17 @@ func (r pkgLicenseRenderer) setRows() { var row []string if r.isTerminal { row = []string{ - l.PkgName, l.Name, colorizeLicenseCategory(l.Category), ColorizeSeverity(l.Severity, l.Severity), + l.PkgName, + l.Name, + colorizeLicenseCategory(l.Category), + ColorizeSeverity(l.Severity, l.Severity), } } else { row = []string{ - l.PkgName, l.Name, string(l.Category), l.Severity, + l.PkgName, + l.Name, + string(l.Category), + l.Severity, } } r.tableWriter.AddRow(row...) @@ -109,6 +126,12 @@ func NewFileLicenseRenderer(result types.Result, isTerminal bool, severities []d } func (r fileLicenseRenderer) Render() string { + // Trivy doesn't currently support showing suppressed licenses + // So just skip this result + if len(r.result.Licenses) == 0 { + return "" + } + r.setHeaders() r.setRows() @@ -124,7 +147,12 @@ func (r fileLicenseRenderer) Render() string { } func (r fileLicenseRenderer) setHeaders() { - header := []string{"Classification", "Severity", "License", "File Location"} + header := []string{ + "Classification", + "Severity", + "License", + "File Location", + } r.tableWriter.SetHeaders(header...) } @@ -148,11 +176,17 @@ func (r fileLicenseRenderer) setRows() { var row []string if r.isTerminal { row = []string{ - colorizeLicenseCategory(l.Category), ColorizeSeverity(l.Severity, l.Severity), l.Name, l.FilePath, + colorizeLicenseCategory(l.Category), + ColorizeSeverity(l.Severity, l.Severity), + l.Name, + l.FilePath, } } else { row = []string{ - string(l.Category), l.Severity, l.Name, l.FilePath, + string(l.Category), + l.Severity, + l.Name, + l.FilePath, } } r.tableWriter.AddRow(row...) diff --git a/pkg/report/table/misconfig.go b/pkg/report/table/misconfig.go index 5f706fbd5787..112d783d0875 100644 --- a/pkg/report/table/misconfig.go +++ b/pkg/report/table/misconfig.go @@ -50,6 +50,11 @@ func NewMisconfigRenderer(result types.Result, severities []dbTypes.Severity, tr } func (r *misconfigRenderer) Render() string { + // Trivy doesn't currently support showing suppressed misconfigs + // So just skip this result + if len(r.result.Misconfigurations) == 0 { + return "" + } target := fmt.Sprintf("%s (%s)", r.result.Target, r.result.Type) RenderTarget(r.w, target, r.ansi) diff --git a/pkg/report/table/secret.go b/pkg/report/table/secret.go index 4b4fe4b0d1bc..cff91a98d9ed 100644 --- a/pkg/report/table/secret.go +++ b/pkg/report/table/secret.go @@ -40,6 +40,11 @@ func NewSecretRenderer(target string, secrets []types.DetectedSecret, ansi bool, } func (r *secretRenderer) Render() string { + // Trivy doesn't currently support showing suppressed secrets + // So just skip this result + if len(r.secrets) == 0 { + return "" + } target := r.target + " (secrets)" RenderTarget(r.w, target, r.ansi)