Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions scanrepository/scanrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ func (sr *ScanRepositoryCmd) scanAndFixBranch(repository *utils.Repository) (tot
return 0, err
}
}
if scanResults == nil {
err = fmt.Errorf("scan returned empty results for branch '%s'", sr.scanDetails.BaseBranch())
if err = utils.CreateErrorIfFailUponScannerErrorEnabled(repository.GeneralConfig.FailUponAnyScannerError, fmt.Sprintf("An error occurred during Audit execution for '%s' branch. Downstream processing will be skipped", sr.scanDetails.BaseBranch()), err); err != nil {
return 0, err
}
return 0, nil
}
defer func() {
// Always check policy even if an error occurred during the scan
err = errors.Join(err, policy.CheckPolicyFailBuildError(scanResults))
Expand Down Expand Up @@ -497,10 +504,6 @@ func (sr *ScanRepositoryCmd) switchToTempWorkingDir() (tempWd string, restoreDir

// Create a vulnerabilities map - a map with 'impacted package' as a key and all the necessary information of this vulnerability as value.
func (sr *ScanRepositoryCmd) createVulnerabilitiesMap(failUponError bool, scanResults *results.SecurityCommandResults) (map[string]*utils.VulnerabilityDetails, error) {
if scanResults == nil {
log.Info("No scan results found")
return nil, nil
}
vulnerabilitiesMap := map[string]*utils.VulnerabilityDetails{}
simpleJsonResult, err := conversion.NewCommandResultsConvertor(conversion.ResultConvertParams{IncludeVulnerabilities: scanResults.IncludesVulnerabilities(), HasViolationContext: scanResults.HasViolationContext()}).ConvertToSimpleJson(scanResults)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions scanrepository/scanrepository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,6 @@ func TestCreateVulnerabilitiesMap(t *testing.T) {
scanResults *results.SecurityCommandResults
expectedMap map[string]*utils.VulnerabilityDetails
}{
{
name: "No results",
scanResults: nil,
expectedMap: map[string]*utils.VulnerabilityDetails{},
},
{
name: "Scan results with no violations and vulnerabilities",
scanResults: &results.SecurityCommandResults{Targets: []*results.TargetResults{{
Expand Down
Loading