Skip to content

Commit 9a5383e

Browse files
authored
fix(report): clean buffer after flushing (#8725)
1 parent 346a6b7 commit 9a5383e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

pkg/k8s/writer_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,42 @@ Failures: 0 (CRITICAL: 0)
320320
════════════════════════════════════════
321321
Your config file is not good.
322322
323+
See https://google.com/search?q=bad%20config
324+
────────────────────────────────────────`,
325+
},
326+
{
327+
name: "vulns and misconfig with `--report all`",
328+
report: report.Report{
329+
ClusterName: "test",
330+
Resources: []report.Resource{
331+
deployOrionWithSingleVuln,
332+
deployOrionWithSingleMisconfig,
333+
},
334+
},
335+
scanners: types.Scanners{types.VulnerabilityScanner, types.MisconfigScanner},
336+
severities: []dbTypes.Severity{
337+
dbTypes.SeverityCritical, dbTypes.SeverityLow,
338+
},
339+
reportType: report.AllReport,
340+
expectedOutput: `namespace: default, deploy: orion ()
341+
====================================
342+
Total: 1 (LOW: 1, CRITICAL: 0)
343+
344+
┌─────────┬───────────────┬──────────┬─────────┬───────────────────┬───────────────┬───────────────────────────────────────────┐
345+
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
346+
├─────────┼───────────────┼──────────┼─────────┼───────────────────┼───────────────┼───────────────────────────────────────────┤
347+
│ foo/bar │ CVE-2022-1111 │ LOW │ unknown │ v0.0.1 │ v0.0.2 │ https://avd.aquasec.com/nvd/cve-2022-1111 │
348+
└─────────┴───────────────┴──────────┴─────────┴───────────────────┴───────────────┴───────────────────────────────────────────┘
349+
350+
namespace: default, deploy: orion ()
351+
====================================
352+
Tests: 1 (SUCCESSES: 0, FAILURES: 1)
353+
Failures: 1 (LOW: 1, CRITICAL: 0)
354+
355+
(LOW): Oh no, a bad config.
356+
════════════════════════════════════════
357+
Your config file is not good.
358+
323359
See https://google.com/search?q=bad%20config
324360
────────────────────────────────────────`,
325361
},

pkg/report/table/table.go

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func (tw *Writer) Write(_ context.Context, report types.Report) error {
110110

111111
func (tw *Writer) flush() {
112112
_, _ = fmt.Fprint(tw.options.Output, tw.buf.String())
113+
tw.buf.Reset()
113114
}
114115

115116
func (tw *Writer) render(result types.Result) {

0 commit comments

Comments
 (0)