Skip to content
Closed
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
32 changes: 22 additions & 10 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
Loading