@@ -170,15 +170,17 @@ func auditPullRequestSourceCode(repoConfig *utils.Repository, scanDetails *utils
170170 }
171171 // Set JAS output flags based on the scan results
172172 repoConfig .OutputWriter .SetJasOutputFlags (scanResults .EntitledForJas , scanResults .HasJasScansResults (jasutils .Applicability ))
173- workingDirs := []string {strings .TrimPrefix (sourceBranchWd , string (filepath .Separator ))}
174- if targetBranchWd != "" && scanDetails .ResultsToCompare != nil {
175- log .Debug ("Diff scan - converting to new issues..." )
176- workingDirs = append (workingDirs , strings .TrimPrefix (targetBranchWd , string (filepath .Separator )))
177- }
178173
174+ if targetBranchWd == "" || scanDetails .ResultsToCompare == nil {
175+ // Since we only perform a Diff scan in this flow - if target wd or target results are missing it means something went wrong with the target scan
176+ issuesCollection = & issues.ScansIssuesCollection {ScanStatus : getResultScanStatues (scanResults )}
177+ err = errors .New ("targetBranchWd or target branch scans results are empty" )
178+ return
179+ }
179180 filterFailedResultsIfScannersFailuresAreAllowed (scanDetails .ResultsToCompare , scanResults , repoConfig .Params .ConfigProfile .GeneralConfig .FailUponAnyScannerError , sourceBranchWd , targetBranchWd )
180181
181- issuesCollection , e := scanResultsToIssuesCollection (scanResults , workingDirs ... )
182+ log .Debug ("Diff scan - converting to new issues..." )
183+ issuesCollection , e := scanResultsToIssuesCollection (scanResults , strings .TrimPrefix (sourceBranchWd , string (filepath .Separator )), strings .TrimPrefix (targetBranchWd , string (filepath .Separator )))
182184 if e != nil {
183185 err = errors .Join (err , fmt .Errorf ("failed to get issues for pull request. Error: %s" , e .Error ()))
184186 }
0 commit comments