@@ -63,6 +63,7 @@ type ScanCommand struct {
6363 threads int
6464 // The location of the downloaded Xray indexer binary on the local file system.
6565 outputFormat format.OutputFormat
66+ outputDir string
6667 minSeverityFilter severityutils.Severity
6768 fail bool
6869 printExtendedTable bool
@@ -124,6 +125,11 @@ func (scanCmd *ScanCommand) SetThreads(threads int) *ScanCommand {
124125 return scanCmd
125126}
126127
128+ func (scanCmd * ScanCommand ) SetOutputDir (outputDir string ) * ScanCommand {
129+ scanCmd .outputDir = outputDir
130+ return scanCmd
131+ }
132+
127133func (scanCmd * ScanCommand ) SetOutputFormat (format format.OutputFormat ) * ScanCommand {
128134 scanCmd .outputFormat = format
129135 return scanCmd
@@ -248,6 +254,7 @@ func (scanCmd *ScanCommand) RunAndRecordResults(cmdType utils.CommandType, recor
248254
249255 if err = output .NewResultsWriter (cmdResults ).
250256 SetOutputFormat (scanCmd .outputFormat ).
257+ SetOutputDir (scanCmd .outputDir ).
251258 SetPlatformUrl (scanCmd .serverDetails .Url ).
252259 SetPrintExtendedTable (scanCmd .printExtendedTable ).
253260 SetSubScansPerformed (scanCmd .scansToPerform ).
@@ -517,6 +524,13 @@ func (scanCmd *ScanCommand) RunBinaryScaScan(fileTarget string, cmdResults *resu
517524 }
518525 targetResults .ScaScanResults (scan .GetScaScansStatusCode (err , * graphScanResults ), * graphScanResults )
519526 targetResults .Technology = techutils .ToTechnology (graphScanResults .ScannedPackageType )
527+ // Dump scan response if requested
528+ if scanCmd .outputDir == "" {
529+ return
530+ }
531+ if e := scan .DumpScanResponseToFileIfNeeded (* graphScanResults , scanCmd .outputDir , utils .ScaScan , scanThreadId ); e != nil {
532+ log .Warn (fmt .Sprintf (clientutils .GetLogMsgPrefix (scanThreadId , false )+ "Failed to dump SCA scan results for target %s: %s" , targetResults .Target , e .Error ()))
533+ }
520534 return
521535}
522536
@@ -574,11 +588,12 @@ func (scanCmd *ScanCommand) RunBinaryJasScans(cmdType utils.CommandType, msi str
574588 }
575589 log .Debug (fmt .Sprintf ("Using analyzer manager executable at: %s" , scanner .AnalyzerManager .AnalyzerManagerFullPath ))
576590 jasParams := runner.JasRunnerParams {
577- Runner : jasFileProducerConsumer ,
578- ServerDetails : scanCmd .serverDetails ,
579- Scanner : scanner ,
580- Module : module ,
581- ScansToPerform : scanCmd .scansToPerform ,
591+ Runner : jasFileProducerConsumer ,
592+ ServerDetails : scanCmd .serverDetails ,
593+ Scanner : scanner ,
594+ Module : module ,
595+ TargetOutputDir : scanCmd .outputDir ,
596+ ScansToPerform : scanCmd .scansToPerform ,
582597 CvesProvider : func () (directCves []string , indirectCves []string ) {
583598 if graphScanResults == nil {
584599 // No SCA scan results, return empty CVE lists.
0 commit comments