Skip to content

Commit 0c29c0a

Browse files
authored
Add nil check for ScaResults when SCA scan is not performed in audit (#519)
1 parent 4213930 commit 0c29c0a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

utils/results/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ func CheckIfFailBuild(auditResults *SecurityCommandResults) (bool, error) {
8080
func checkIfFailBuildConsideringApplicability(target *TargetResults, entitledForJas bool, shouldFailBuild *bool) error {
8181
jasApplicabilityResults := target.JasResults.GetApplicabilityScanResults()
8282

83+
if target.ScaResults == nil {
84+
return nil
85+
}
8386
// Get new violations from the target
8487
newViolations := target.ScaResults.Violations
8588

utils/results/common_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ func TestViolationFailBuild(t *testing.T) {
169169
},
170170
expectedResult: true, // Should fail because second target has a violation that should fail
171171
},
172+
{
173+
name: "no sca results - build should not fail",
174+
auditResults: &SecurityCommandResults{
175+
EntitledForJas: true,
176+
Targets: []*TargetResults{
177+
{
178+
ScanTarget: ScanTarget{Target: "test-target"},
179+
ScaResults: nil,
180+
JasResults: &JasScansResults{},
181+
},
182+
},
183+
},
184+
expectedResult: false,
185+
},
172186
}
173187

174188
for _, test := range tests {

0 commit comments

Comments
 (0)