Skip to content

Commit

Permalink
added comments and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
eranturgeman committed Oct 10, 2024
1 parent 1742aae commit caff52f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions commands/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func RunAudit(auditParams *AuditParams) (results *utils.Results, err error) {
}
// The sca scan doesn't require the analyzer manager, so it can run separately from the analyzer manager download routine.
if scaScanErr := buildDepTreeAndRunScaScan(auditParallelRunner, auditParams, results); scaScanErr != nil {
// If error to be caught, we add it to the auditParallelRunner error queue and continue. The error need not be returned
_ = createErrorIfPartialResultsDisabled(auditParams, auditParallelRunner, fmt.Sprintf("An error has occurred during SCA scan process. SCA scan is skipped for the following directories: %s.", auditParams.workingDirs), scaScanErr)
}
go func() {
Expand Down Expand Up @@ -278,8 +279,9 @@ func downloadAnalyzerManagerAndRunScanners(auditParallelRunner *utils.SecurityPa
return
}

// This function checks if partial results is allowed. If so we log the error and continue.
// If partial results is not allowed we add the error to the SecurityParallelRunner error's channel if one is provided, or simply return the error if not.
// This function checks if partial results are allowed. If so we log the error and continue.
// If partial results are not allowed and a SecurityParallelRunner is provided we add the error to its error queue and return without an error, since the errors will be later collected from the queue.
// If partial results are not allowed and a SecurityParallelRunner is not provided we return the error.
func createErrorIfPartialResultsDisabled(auditParams *AuditParams, auditParallelRunner *utils.SecurityParallelRunner, extraMassageForLog string, err error) error {
if err == nil {
return nil
Expand Down
1 change: 1 addition & 0 deletions commands/audit/scarunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func buildDepTreeAndRunScaScan(auditParallelRunner *utils.SecurityParallelRunner
// Create sca scan task
auditParallelRunner.ScaScansWg.Add(1)
_, taskErr := auditParallelRunner.Runner.AddTaskWithError(executeScaScanTask(auditParallelRunner, serverDetails, auditParams, scan, treeResult), func(err error) {
// If error to be caught, we add it to the auditParallelRunner error queue and continue. The error need not be returned
_ = createErrorIfPartialResultsDisabled(auditParams, auditParallelRunner, fmt.Sprintf("Failed to execute SCA scan for the following target: %s", scan.Target), fmt.Errorf("audit command in '%s' failed:\n%s", scan.Target, err.Error()))
auditParallelRunner.ScaScansWg.Done()
})
Expand Down

0 comments on commit caff52f

Please sign in to comment.