Skip to content

Commit 89fdf98

Browse files
committed
fix
1 parent a3c9754 commit 89fdf98

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

commands/audit/scarunner.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ func buildDepTreeAndRunScaScan(auditParallelRunner *utils.SecurityParallelRunner
9797
}
9898
// Create sca scan task
9999
auditParallelRunner.ScaScansWg.Add(1)
100-
defer auditParallelRunner.ScaScansWg.Done()
100+
// defer auditParallelRunner.ScaScansWg.Done()
101101
_, taskErr := auditParallelRunner.Runner.AddTaskWithError(executeScaScanTask(auditParallelRunner, serverDetails, auditParams, targetResult, treeResult), func(err error) {
102102
_ = targetResult.AddTargetError(fmt.Errorf("Failed to execute SCA scan: %s", err.Error()), auditParams.AllowPartialResults())
103103
})
104104
if taskErr != nil {
105105
_ = targetResult.AddTargetError(fmt.Errorf("Failed to create SCA scan task: %s", taskErr.Error()), auditParams.AllowPartialResults())
106+
auditParallelRunner.ScaScansWg.Done()
106107
}
107108
}
108109
return
@@ -120,14 +121,8 @@ func getRequestedDescriptors(params *AuditParams) map[techutils.Technology][]str
120121
func executeScaScanTask(auditParallelRunner *utils.SecurityParallelRunner, serverDetails *config.ServerDetails, auditParams *AuditParams,
121122
scan *results.TargetResults, treeResult *DependencyTreeResult) parallel.TaskFunc {
122123
return func(threadId int) (err error) {
124+
defer auditParallelRunner.ScaScansWg.Done()
123125
log.Info(clientutils.GetLogMsgPrefix(threadId, false)+"Running SCA scan for", scan.Target, "vulnerable dependencies in", scan.Target, "directory...")
124-
var xrayErr error
125-
defer func() {
126-
if xrayErr == nil {
127-
// We Sca waitGroup as done only when we have no errors. If we have errors we mark it done in the error's handler function
128-
auditParallelRunner.ScaScansWg.Done()
129-
}
130-
}()
131126
// Scan the dependency tree.
132127
scanResults, xrayErr := runScaWithTech(scan.Technology, auditParams, serverDetails, *treeResult.FlatTree, treeResult.FullDepTrees)
133128
if xrayErr != nil {

0 commit comments

Comments
 (0)