Merge remote-tracking branch 'upstream/dev'

This commit is contained in:
Daniel-GrunbergerCA
2021-10-25 17:41:15 +03:00
3 changed files with 15 additions and 10 deletions
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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) {
+13 -8
View File
@@ -38,14 +38,19 @@ func (resultsHandler *ResultsHandler) HandleResults(scanInfo *cautils.ScanInfo)
// CalculatePostureScore calculate final score
func CalculatePostureScore(postureReport *reporthandling.PostureReport) float32 {
totalResources := 0
totalFailed := 0
lowestScore := float32(100)
for _, frameworkReport := range postureReport.FrameworkReports {
totalFailed += frameworkReport.GetNumberOfFailedResources()
totalResources += frameworkReport.GetNumberOfResources()
totalFailed := frameworkReport.GetNumberOfFailedResources()
totalResources := frameworkReport.GetNumberOfResources()
frameworkScore := float32(0)
if float32(totalResources) > 0 {
frameworkScore = (float32(totalResources) - float32(totalFailed)) / float32(totalResources)
}
if lowestScore > frameworkScore {
lowestScore = frameworkScore
}
}
if totalResources == 0 {
return float32(0)
}
return (float32(totalResources) - float32(totalFailed)) / float32(totalResources)
return lowestScore
}