Skip to content

Commit

Permalink
AST-74615
Browse files Browse the repository at this point in the history
  • Loading branch information
margaritalm committed Jan 15, 2025
1 parent e25172e commit 79a0578
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions internal/commands/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,23 +985,35 @@ func runGetResultCommand(
if errorModel != nil {
return errors.Errorf("%s: CODE: %d, %s", failedGettingScan, errorModel.Code, errorModel.Message)
}
if isScanFinished(scan.Status) {
policyResponseModel, err := services.HandlePolicyEvaluation(cmd, policyWrapper, scan, ignorePolicy, agent, waitDelay, policyTimeout)
if err != nil {
return err
}

policyResponseModel, err := services.HandlePolicyEvaluation(cmd, policyWrapper, scan, ignorePolicy, agent, waitDelay, policyTimeout)
if err != nil {
if sastRedundancy {
resultsParams[commonParams.SastRedundancyFlag] = ""
}

_, err = CreateScanReport(resultsWrapper, risksOverviewWrapper, scsScanOverviewWrapper, exportWrapper,
policyResponseModel, resultsPdfReportsWrapper, scan, format, formatPdfToEmail, formatPdfOptions,
formatSbomOptions, targetFile, targetPath, agent, resultsParams, featureFlagsWrapper)
return err
}
} else {
log.Printf("Scan executed in asynchronous mode or still running. Hence, no policy generated")

if sastRedundancy {
resultsParams[commonParams.SastRedundancyFlag] = ""
}

_, err = CreateScanReport(resultsWrapper, risksOverviewWrapper, scsScanOverviewWrapper, exportWrapper,
policyResponseModel, resultsPdfReportsWrapper, scan, format, formatPdfToEmail, formatPdfOptions,
formatSbomOptions, targetFile, targetPath, agent, resultsParams, featureFlagsWrapper)
return err
return nil
}
}

func isScanFinished(status wrappers.ScanStatus) bool {
statusBytes, _ := json.Marshal(status)
statusString := string(statusBytes)
statusString = strings.Trim(statusString, `"`)
return strings.EqualFold(statusString, "Completed") || strings.EqualFold(statusString, "Partial")
}

func runGetCodeBashingCommand(
codeBashingWrapper wrappers.CodeBashingWrapper,
) func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -1973,7 +1985,7 @@ func parseGlDependencyLocation(result *wrappers.ScanResult) string {
} else {
location = ""
}
return (location)
return location
}
func parseGlScaFiles(result *wrappers.ScanResult, glScaResult *wrappers.GlScaResultsCollection) *wrappers.GlScaResultsCollection {
if result.ScanResultData.ScaPackageCollection != nil && result.ScanResultData.ScaPackageCollection.Locations != nil {
Expand Down

0 comments on commit 79a0578

Please sign in to comment.