diff --git a/cmd/common.go b/cmd/common.go index 2cade9adb0719ac81b72dc50e7a6ffb9842a58c3..60f2913321f6b1682f96e0ffe041b11ccc2d87d9 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -437,13 +437,19 @@ func writeJSONOutput(controlsCollection []*check.Controls) { } func writeJunitOutput(controlsCollection []*check.Controls) { + // QuickFix for issue https://github.com/aquasecurity/kube-bench/issues/883 + // Should consider to deprecate of switch to using Junit template + prefix := "<testsuites>\n" + suffix := "\n</testsuites>" + var outputAllControls []byte for _, controls := range controlsCollection { - out, err := controls.JUnit() + tempOut, err := controls.JUnit() + outputAllControls = append(outputAllControls[:], tempOut[:]...) if err != nil { exitWithError(fmt.Errorf("failed to output in JUnit format: %v", err)) } - printOutput(string(out), outputFile) } + printOutput(prefix+string(outputAllControls)+suffix, outputFile) } func writePgsqlOutput(controlsCollection []*check.Controls) {