@@ -808,6 +808,7 @@ func (c *checkmarxOneExecuteScanHelper) getDetailedResults(scan *checkmarxOne.Sc
808808 resultMap ["Preset" ] = scanmeta .PresetName
809809 resultMap ["DeepLink" ] = fmt .Sprintf ("%v/projects/%v/overview?branch=%v" , c .config .ServerURL , c .Project .ProjectID , url .QueryEscape (scan .Branch ))
810810 resultMap ["ReportCreationTime" ] = time .Now ().String ()
811+ resultMap ["Critical" ] = map [string ]int {}
811812 resultMap ["High" ] = map [string ]int {}
812813 resultMap ["Medium" ] = map [string ]int {}
813814 resultMap ["Low" ] = map [string ]int {}
@@ -817,6 +818,8 @@ func (c *checkmarxOneExecuteScanHelper) getDetailedResults(scan *checkmarxOne.Sc
817818 for _ , result := range * results {
818819 key := "Information"
819820 switch result .Severity {
821+ case "CRITICAL" :
822+ key = "Critical"
820823 case "HIGH" :
821824 key = "High"
822825 case "MEDIUM" :
@@ -1075,20 +1078,29 @@ func (c *checkmarxOneExecuteScanHelper) enforceThresholds(results *map[string]in
10751078 insecureResults := []string {}
10761079 insecure := false
10771080
1081+ cxCriticalThreshold := c .config .VulnerabilityThresholdCritical
10781082 cxHighThreshold := c .config .VulnerabilityThresholdHigh
10791083 cxMediumThreshold := c .config .VulnerabilityThresholdMedium
10801084 cxLowThreshold := c .config .VulnerabilityThresholdLow
10811085 cxLowThresholdPerQuery := c .config .VulnerabilityThresholdLowPerQuery
10821086 cxLowThresholdPerQueryMax := c .config .VulnerabilityThresholdLowPerQueryMax
1087+ criticalValue := (* results )["Critical" ].(map [string ]int )["NotFalsePositive" ]
10831088 highValue := (* results )["High" ].(map [string ]int )["NotFalsePositive" ]
10841089 mediumValue := (* results )["Medium" ].(map [string ]int )["NotFalsePositive" ]
10851090 lowValue := (* results )["Low" ].(map [string ]int )["NotFalsePositive" ]
10861091 var unit string
1092+ criticalViolation := ""
10871093 highViolation := ""
10881094 mediumViolation := ""
10891095 lowViolation := ""
10901096 if c .config .VulnerabilityThresholdUnit == "percentage" {
10911097 unit = "%"
1098+ criticalAudited := (* results )["Critical" ].(map [string ]int )["Issues" ] - (* results )["Critical" ].(map [string ]int )["NotFalsePositive" ]
1099+ criticalOverall := (* results )["Critical" ].(map [string ]int )["Issues" ]
1100+ if criticalOverall == 0 {
1101+ criticalAudited = 1
1102+ criticalOverall = 1
1103+ }
10921104 highAudited := (* results )["High" ].(map [string ]int )["Issues" ] - (* results )["High" ].(map [string ]int )["NotFalsePositive" ]
10931105 highOverall := (* results )["High" ].(map [string ]int )["Issues" ]
10941106 if highOverall == 0 {
@@ -1107,10 +1119,15 @@ func (c *checkmarxOneExecuteScanHelper) enforceThresholds(results *map[string]in
11071119 lowAudited = 1
11081120 lowOverall = 1
11091121 }
1122+ criticalValue = int (float32 (criticalAudited ) / float32 (criticalOverall ) * 100.0 )
11101123 highValue = int (float32 (highAudited ) / float32 (highOverall ) * 100.0 )
11111124 mediumValue = int (float32 (mediumAudited ) / float32 (mediumOverall ) * 100.0 )
11121125 lowValue = int (float32 (lowAudited ) / float32 (lowOverall ) * 100.0 )
11131126
1127+ if criticalValue < cxCriticalThreshold {
1128+ insecure = true
1129+ criticalViolation = fmt .Sprintf ("<-- %v %v deviation" , cxCriticalThreshold - criticalValue , unit )
1130+ }
11141131 if highValue < cxHighThreshold {
11151132 insecure = true
11161133 highViolation = fmt .Sprintf ("<-- %v %v deviation" , cxHighThreshold - highValue , unit )
@@ -1148,6 +1165,10 @@ func (c *checkmarxOneExecuteScanHelper) enforceThresholds(results *map[string]in
11481165 }
11491166 if c .config .VulnerabilityThresholdUnit == "absolute" {
11501167 unit = " findings"
1168+ if criticalValue > cxCriticalThreshold {
1169+ insecure = true
1170+ criticalViolation = fmt .Sprintf ("<-- %v%v deviation" , criticalValue - cxCriticalThreshold , unit )
1171+ }
11511172 if highValue > cxHighThreshold {
11521173 insecure = true
11531174 highViolation = fmt .Sprintf ("<-- %v%v deviation" , highValue - cxHighThreshold , unit )
@@ -1162,9 +1183,17 @@ func (c *checkmarxOneExecuteScanHelper) enforceThresholds(results *map[string]in
11621183 }
11631184 }
11641185
1186+ criticalText := fmt .Sprintf ("Critical %v%v %v" , criticalValue , unit , criticalViolation )
11651187 highText := fmt .Sprintf ("High %v%v %v" , highValue , unit , highViolation )
11661188 mediumText := fmt .Sprintf ("Medium %v%v %v" , mediumValue , unit , mediumViolation )
11671189 lowText := fmt .Sprintf ("Low %v%v %v" , lowValue , unit , lowViolation )
1190+ if len (criticalViolation ) > 0 {
1191+ insecureResults = append (insecureResults , criticalText )
1192+ log .Entry ().Error (criticalText )
1193+ } else {
1194+ neutralResults = append (neutralResults , criticalText )
1195+ log .Entry ().Info (criticalText )
1196+ }
11681197 if len (highViolation ) > 0 {
11691198 insecureResults = append (insecureResults , highText )
11701199 log .Entry ().Error (highText )
@@ -1191,6 +1220,13 @@ func (c *checkmarxOneExecuteScanHelper) enforceThresholds(results *map[string]in
11911220}
11921221
11931222func (c * checkmarxOneExecuteScanHelper ) reportToInflux (results * map [string ]interface {}) {
1223+ c .influx .checkmarxOne_data .fields .critical_issues = (* results )["Critical" ].(map [string ]int )["Issues" ]
1224+ c .influx .checkmarxOne_data .fields .critical_not_false_postive = (* results )["Critical" ].(map [string ]int )["NotFalsePositive" ]
1225+ c .influx .checkmarxOne_data .fields .critical_not_exploitable = (* results )["Critical" ].(map [string ]int )["NotExploitable" ]
1226+ c .influx .checkmarxOne_data .fields .critical_confirmed = (* results )["Critical" ].(map [string ]int )["Confirmed" ]
1227+ c .influx .checkmarxOne_data .fields .critical_urgent = (* results )["Critical" ].(map [string ]int )["Urgent" ]
1228+ c .influx .checkmarxOne_data .fields .critical_proposed_not_exploitable = (* results )["Critical" ].(map [string ]int )["ProposedNotExploitable" ]
1229+ c .influx .checkmarxOne_data .fields .critical_to_verify = (* results )["Critical" ].(map [string ]int )["ToVerify" ]
11941230
11951231 c .influx .checkmarxOne_data .fields .high_issues = (* results )["High" ].(map [string ]int )["Issues" ]
11961232 c .influx .checkmarxOne_data .fields .high_not_false_postive = (* results )["High" ].(map [string ]int )["NotFalsePositive" ]
0 commit comments