|
|
|
@ -131,41 +131,48 @@ func colorPrint(state check.State, s string) {
|
|
|
|
|
|
|
|
|
|
// prettyPrint outputs the results to stdout in human-readable format
|
|
|
|
|
func prettyPrint(r *check.Controls, summary check.Summary) {
|
|
|
|
|
colorPrint(check.INFO, fmt.Sprintf("%s %s\n", r.ID, r.Text))
|
|
|
|
|
for _, g := range r.Groups {
|
|
|
|
|
colorPrint(check.INFO, fmt.Sprintf("%s %s\n", g.ID, g.Text))
|
|
|
|
|
for _, c := range g.Checks {
|
|
|
|
|
colorPrint(c.State, fmt.Sprintf("%s %s\n", c.ID, c.Text))
|
|
|
|
|
// Print check results.
|
|
|
|
|
if !noResults {
|
|
|
|
|
colorPrint(check.INFO, fmt.Sprintf("%s %s\n", r.ID, r.Text))
|
|
|
|
|
for _, g := range r.Groups {
|
|
|
|
|
colorPrint(check.INFO, fmt.Sprintf("%s %s\n", g.ID, g.Text))
|
|
|
|
|
for _, c := range g.Checks {
|
|
|
|
|
colorPrint(c.State, fmt.Sprintf("%s %s\n", c.ID, c.Text))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Println()
|
|
|
|
|
fmt.Println()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Print remediations.
|
|
|
|
|
if summary.Fail > 0 || summary.Warn > 0 {
|
|
|
|
|
colors[check.WARN].Printf("== Remediations ==\n")
|
|
|
|
|
for _, g := range r.Groups {
|
|
|
|
|
for _, c := range g.Checks {
|
|
|
|
|
if c.State != check.PASS {
|
|
|
|
|
fmt.Printf("%s %s\n", c.ID, c.Remediation)
|
|
|
|
|
if !noRemediations {
|
|
|
|
|
if summary.Fail > 0 || summary.Warn > 0 {
|
|
|
|
|
colors[check.WARN].Printf("== Remediations ==\n")
|
|
|
|
|
for _, g := range r.Groups {
|
|
|
|
|
for _, c := range g.Checks {
|
|
|
|
|
if c.State != check.PASS {
|
|
|
|
|
fmt.Printf("%s %s\n", c.ID, c.Remediation)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fmt.Println()
|
|
|
|
|
}
|
|
|
|
|
fmt.Println()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Print summary setting output color to highest severity.
|
|
|
|
|
var res check.State
|
|
|
|
|
if summary.Fail > 0 {
|
|
|
|
|
res = check.FAIL
|
|
|
|
|
} else if summary.Warn > 0 {
|
|
|
|
|
res = check.WARN
|
|
|
|
|
} else {
|
|
|
|
|
res = check.PASS
|
|
|
|
|
}
|
|
|
|
|
if !noSummary {
|
|
|
|
|
var res check.State
|
|
|
|
|
if summary.Fail > 0 {
|
|
|
|
|
res = check.FAIL
|
|
|
|
|
} else if summary.Warn > 0 {
|
|
|
|
|
res = check.WARN
|
|
|
|
|
} else {
|
|
|
|
|
res = check.PASS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
colors[res].Printf("== Summary ==\n")
|
|
|
|
|
fmt.Printf("%d checks PASS\n%d checks FAIL\n%d checks WARN\n",
|
|
|
|
|
summary.Pass, summary.Fail, summary.Warn,
|
|
|
|
|
)
|
|
|
|
|
colors[res].Printf("== Summary ==\n")
|
|
|
|
|
fmt.Printf("%d checks PASS\n%d checks FAIL\n%d checks WARN\n",
|
|
|
|
|
summary.Pass, summary.Fail, summary.Warn,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|