fix(report): clean buffer after flushing (#8725)

This commit is contained in:
afdesk
2025-04-12 09:08:41 +06:00
committed by GitHub
parent 346a6b794d
commit 9a5383e993
2 changed files with 37 additions and 0 deletions

View File

@@ -320,6 +320,42 @@ Failures: 0 (CRITICAL: 0)
════════════════════════════════════════
Your config file is not good.
See https://google.com/search?q=bad%20config
────────────────────────────────────────`,
},
{
name: "vulns and misconfig with `--report all`",
report: report.Report{
ClusterName: "test",
Resources: []report.Resource{
deployOrionWithSingleVuln,
deployOrionWithSingleMisconfig,
},
},
scanners: types.Scanners{types.VulnerabilityScanner, types.MisconfigScanner},
severities: []dbTypes.Severity{
dbTypes.SeverityCritical, dbTypes.SeverityLow,
},
reportType: report.AllReport,
expectedOutput: `namespace: default, deploy: orion ()
====================================
Total: 1 (LOW: 1, CRITICAL: 0)
┌─────────┬───────────────┬──────────┬─────────┬───────────────────┬───────────────┬───────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
├─────────┼───────────────┼──────────┼─────────┼───────────────────┼───────────────┼───────────────────────────────────────────┤
│ foo/bar │ CVE-2022-1111 │ LOW │ unknown │ v0.0.1 │ v0.0.2 │ https://avd.aquasec.com/nvd/cve-2022-1111 │
└─────────┴───────────────┴──────────┴─────────┴───────────────────┴───────────────┴───────────────────────────────────────────┘
namespace: default, deploy: orion ()
====================================
Tests: 1 (SUCCESSES: 0, FAILURES: 1)
Failures: 1 (LOW: 1, CRITICAL: 0)
(LOW): Oh no, a bad config.
════════════════════════════════════════
Your config file is not good.
See https://google.com/search?q=bad%20config
────────────────────────────────────────`,
},

View File

@@ -110,6 +110,7 @@ func (tw *Writer) Write(_ context.Context, report types.Report) error {
func (tw *Writer) flush() {
_, _ = fmt.Fprint(tw.options.Output, tw.buf.String())
tw.buf.Reset()
}
func (tw *Writer) render(result types.Result) {