@@ -218,7 +218,6 @@ func getAddTaskToProducerFunc(producer parallel.Runner, errorsQueue *clientutils
218218}
219219
220220func (scanCmd * ScanCommand ) performScanTasks (fileConsumer parallel.Runner , indexedFileConsumer parallel.Runner , resultsArr [][]* services.ScanResponse ) (bool , error ) {
221-
222221 go func () {
223222 // Blocking until consuming is finished.
224223 fileConsumer .Run ()
@@ -233,30 +232,30 @@ func (scanCmd *ScanCommand) performScanTasks(fileConsumer parallel.Runner, index
233232 vulnerabilities := []services.Vulnerability {}
234233 licenses := []services.License {}
235234 flatResults := []services.ScanResponse {}
236- tempDirPath , err := fileutils .CreateTempDir ()
237- if err != nil {
238- return false , err
239- }
240235 for _ , arr := range resultsArr {
241236 for _ , res := range arr {
237+ flatResults = append (flatResults , * res )
238+
242239 if scanCmd .outputFormat == Table {
243- if err = xrutils .WriteJsonResults (res , tempDirPath ); err != nil {
244- return false , err
245- }
246240 violations = append (violations , res .Violations ... )
247241 vulnerabilities = append (vulnerabilities , res .Vulnerabilities ... )
248242 licenses = append (licenses , res .Licenses ... )
249- } else {
250- flatResults = append (flatResults , * res )
251243 }
252244 if len (res .Violations ) > 0 || len (res .Vulnerabilities ) > 0 {
253245 // A violation or vulnerability was found, the scan failed.
254246 scanPassed = false
255247 }
256248 }
257249 }
250+ var err error
258251 if scanCmd .outputFormat == Table {
259- fmt .Println ("The full scan results are available here: " + tempDirPath )
252+ if len (flatResults ) > 0 {
253+ resultsPath , err := xrutils .WriteJsonResults (flatResults )
254+ if err != nil {
255+ return false , err
256+ }
257+ fmt .Println ("The full scan results are available here: " + resultsPath )
258+ }
260259 if scanCmd .includeVulnerabilities {
261260 xrutils .PrintVulnerabilitiesTable (vulnerabilities , true )
262261 } else {
@@ -267,7 +266,6 @@ func (scanCmd *ScanCommand) performScanTasks(fileConsumer parallel.Runner, index
267266 }
268267 } else {
269268 err = xrutils .PrintJson (flatResults )
270-
271269 }
272270 if scanPassed {
273271 log .Info ("Scan completed successfully." )
0 commit comments