mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
support more than score
This commit is contained in:
@@ -21,7 +21,7 @@ func (jsonPrinter *JsonPrinter) SetWriter(outputFile string) {
|
||||
}
|
||||
|
||||
func (jsonPrinter *JsonPrinter) Score(score float32) {
|
||||
fmt.Printf("\nFinal score: %d\n", int(score))
|
||||
fmt.Printf("\nFinal score: %d", int(score*100))
|
||||
}
|
||||
|
||||
func (jsonPrinter *JsonPrinter) ActionPrint(opaSessionObj *cautils.OPASessionObj) {
|
||||
|
||||
@@ -22,7 +22,7 @@ func (junitPrinter *JunitPrinter) SetWriter(outputFile string) {
|
||||
}
|
||||
|
||||
func (junitPrinter *JunitPrinter) Score(score float32) {
|
||||
fmt.Printf("\nFinal score: %d\n", int(score))
|
||||
fmt.Printf("\nFinal score: %d", int(score*100))
|
||||
}
|
||||
|
||||
func (junitPrinter *JunitPrinter) ActionPrint(opaSessionObj *cautils.OPASessionObj) {
|
||||
|
||||
@@ -38,14 +38,16 @@ func (resultsHandler *ResultsHandler) HandleResults(scanInfo *cautils.ScanInfo)
|
||||
|
||||
// CalculatePostureScore calculate final score
|
||||
func CalculatePostureScore(postureReport *reporthandling.PostureReport) float32 {
|
||||
totalResources := 0
|
||||
totalFailed := 0
|
||||
lowestScore := float32(0)
|
||||
for _, frameworkReport := range postureReport.FrameworkReports {
|
||||
totalFailed += frameworkReport.GetNumberOfFailedResources()
|
||||
totalResources += frameworkReport.GetNumberOfResources()
|
||||
totalFailed := frameworkReport.GetNumberOfFailedResources()
|
||||
totalResources := frameworkReport.GetNumberOfResources()
|
||||
|
||||
frameworkScore := (float32(totalResources) - float32(totalFailed)) / float32(totalResources)
|
||||
if lowestScore > frameworkScore || frameworkScore == 0 {
|
||||
frameworkScore = lowestScore
|
||||
}
|
||||
}
|
||||
if totalResources == 0 {
|
||||
return float32(0)
|
||||
}
|
||||
return (float32(totalResources) - float32(totalFailed)) / float32(totalResources)
|
||||
|
||||
return lowestScore
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user