mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
fix(report): clean buffer after flushing (#8725)
This commit is contained in:
@@ -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
|
||||
────────────────────────────────────────`,
|
||||
},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user