mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
Merge remote-tracking branch 'upstream/dev'
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/armosec/opa-utils/reporthandling/apis"
|
||||
"github.com/armosec/opa-utils/reporthandling/results/v1/reportsummary"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func generateRow(controlSummary reportsummary.IControlSummary, infoToPrintInfoMap map[string]string) []string {
|
||||
@@ -13,6 +15,14 @@ func generateRow(controlSummary reportsummary.IControlSummary, infoToPrintInfoMa
|
||||
row = append(row, fmt.Sprintf("%d", controlSummary.NumberOfResources().Excluded()))
|
||||
row = append(row, fmt.Sprintf("%d", controlSummary.NumberOfResources().All()))
|
||||
|
||||
if controlSummary.GetStatus().IsPassed() {
|
||||
row = append(row, color.CyanString("Passed"))
|
||||
} else if controlSummary.GetStatus().IsSkipped() {
|
||||
row = append(row, "skipped")
|
||||
} else {
|
||||
row = append(row, setColor(apis.ControlSeverityToString(controlSummary.GetScoreFactor())))
|
||||
}
|
||||
|
||||
if !controlSummary.GetStatus().IsSkipped() {
|
||||
row = append(row, fmt.Sprintf("%d", int(controlSummary.GetScore()))+"%")
|
||||
row = append(row, "")
|
||||
@@ -27,6 +37,21 @@ func generateRow(controlSummary reportsummary.IControlSummary, infoToPrintInfoMa
|
||||
return row
|
||||
}
|
||||
|
||||
func setColor(controlSeverity string) string {
|
||||
switch controlSeverity {
|
||||
case "Critical":
|
||||
return color.New(color.FgRed, color.Bold).Add(color.Underline).SprintFunc()(controlSeverity)
|
||||
case "High":
|
||||
return color.New(color.FgRed, color.Bold).SprintFunc()(controlSeverity)
|
||||
case "Medium":
|
||||
return color.New(color.FgYellow, color.Bold).SprintFunc()(controlSeverity)
|
||||
case "Low":
|
||||
return color.New(color.FgGreen, color.Bold).SprintFunc()(controlSeverity)
|
||||
default:
|
||||
return color.New(color.FgBlue, color.Bold).SprintFunc()(controlSeverity)
|
||||
}
|
||||
}
|
||||
|
||||
func getSortedControlsNames(controls reportsummary.ControlSummaries) []string {
|
||||
controlNames := make([]string, 0, len(controls))
|
||||
for k := range controls {
|
||||
@@ -38,5 +63,5 @@ func getSortedControlsNames(controls reportsummary.ControlSummaries) []string {
|
||||
}
|
||||
|
||||
func getControlTableHeaders() []string {
|
||||
return []string{"CONTROL NAME", "FAILED RESOURCES", "EXCLUDED RESOURCES", "ALL RESOURCES", "% RISK-SCORE", "INFO"}
|
||||
return []string{"CONTROL NAME", "FAILED RESOURCES", "EXCLUDED RESOURCES", "ALL RESOURCES", "SEVERITY", "% RISK-SCORE", "INFO"}
|
||||
}
|
||||
|
||||
@@ -172,6 +172,7 @@ func generateFooter(summaryDetails *reportsummary.SummaryDetails) []string {
|
||||
row = append(row, fmt.Sprintf("%d", summaryDetails.NumberOfResources().Failed()))
|
||||
row = append(row, fmt.Sprintf("%d", summaryDetails.NumberOfResources().Excluded()))
|
||||
row = append(row, fmt.Sprintf("%d", summaryDetails.NumberOfResources().All()))
|
||||
row = append(row, " ")
|
||||
row = append(row, fmt.Sprintf("%.2f%s", summaryDetails.Score, "%"))
|
||||
row = append(row, " ")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user