@@ -985,23 +985,35 @@ func runGetResultCommand(
985985 if errorModel != nil {
986986 return errors .Errorf ("%s: CODE: %d, %s" , failedGettingScan , errorModel .Code , errorModel .Message )
987987 }
988+ if isScanFinished (scan .Status ) {
989+ policyResponseModel , err := services .HandlePolicyEvaluation (cmd , policyWrapper , scan , ignorePolicy , agent , waitDelay , policyTimeout )
990+ if err != nil {
991+ return err
992+ }
988993
989- policyResponseModel , err := services .HandlePolicyEvaluation (cmd , policyWrapper , scan , ignorePolicy , agent , waitDelay , policyTimeout )
990- if err != nil {
994+ if sastRedundancy {
995+ resultsParams [commonParams .SastRedundancyFlag ] = ""
996+ }
997+
998+ _ , err = CreateScanReport (resultsWrapper , risksOverviewWrapper , scsScanOverviewWrapper , exportWrapper ,
999+ policyResponseModel , resultsPdfReportsWrapper , scan , format , formatPdfToEmail , formatPdfOptions ,
1000+ formatSbomOptions , targetFile , targetPath , agent , resultsParams , featureFlagsWrapper )
9911001 return err
992- }
1002+ } else {
1003+ log .Printf ("Scan executed in asynchronous mode or still running. Hence, no policy generated" )
9931004
994- if sastRedundancy {
995- resultsParams [commonParams .SastRedundancyFlag ] = ""
9961005 }
997-
998- _ , err = CreateScanReport (resultsWrapper , risksOverviewWrapper , scsScanOverviewWrapper , exportWrapper ,
999- policyResponseModel , resultsPdfReportsWrapper , scan , format , formatPdfToEmail , formatPdfOptions ,
1000- formatSbomOptions , targetFile , targetPath , agent , resultsParams , featureFlagsWrapper )
1001- return err
1006+ return nil
10021007 }
10031008}
10041009
1010+ func isScanFinished (status wrappers.ScanStatus ) bool {
1011+ statusBytes , _ := json .Marshal (status )
1012+ statusString := string (statusBytes )
1013+ statusString = strings .Trim (statusString , `"` )
1014+ return strings .EqualFold (statusString , "Completed" ) || strings .EqualFold (statusString , "Partial" )
1015+ }
1016+
10051017func runGetCodeBashingCommand (
10061018 codeBashingWrapper wrappers.CodeBashingWrapper ,
10071019) func (cmd * cobra.Command , args []string ) error {
0 commit comments