mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-12-18 12:48:08 +00:00
Fix Junit missing testsuites (#920)
Fix issue https://github.com/aquasecurity/kube-bench/issues/883 but also bug with overriding output when --outputfile is effective and only write the last controls
This commit is contained in:
parent
aedc2942bd
commit
14aef408e8
@ -437,13 +437,19 @@ func writeJSONOutput(controlsCollection []*check.Controls) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func writeJunitOutput(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 {
|
for _, controls := range controlsCollection {
|
||||||
out, err := controls.JUnit()
|
tempOut, err := controls.JUnit()
|
||||||
|
outputAllControls = append(outputAllControls[:], tempOut[:]...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exitWithError(fmt.Errorf("failed to output in JUnit format: %v", err))
|
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) {
|
func writePgsqlOutput(controlsCollection []*check.Controls) {
|
||||||
|
Loading…
Reference in New Issue
Block a user