5
5
"errors"
6
6
"fmt"
7
7
"github.com/jfrog/jfrog-cli-security/utils/results/output"
8
+ "github.com/jfrog/jfrog-client-go/utils/errorutils"
8
9
"os"
9
10
"os/exec"
10
11
"path/filepath"
@@ -22,7 +23,6 @@ import (
22
23
"github.com/jfrog/jfrog-cli-security/utils/xray"
23
24
"github.com/jfrog/jfrog-client-go/artifactory/services/fspatterns"
24
25
clientutils "github.com/jfrog/jfrog-client-go/utils"
25
- "github.com/jfrog/jfrog-client-go/utils/errorutils"
26
26
ioUtils "github.com/jfrog/jfrog-client-go/utils/io"
27
27
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
28
28
"github.com/jfrog/jfrog-client-go/utils/log"
@@ -84,7 +84,7 @@ func AppendVulnsToJson(cmdResults *results.SecurityCommandResults) error {
84
84
var vulnerabilities []map [string ]string
85
85
xrayResults := cmdResults .GetScaScansXrayResults ()
86
86
if len (xrayResults ) == 0 {
87
- return fmt .Errorf ("failed while getting sca scan from xray: %s" , err . Error () )
87
+ return fmt .Errorf ("xray scan results are empty" )
88
88
} else if len (xrayResults ) > 1 {
89
89
log .Warn ("Received %d results, parsing only first result" , len (xrayResults ))
90
90
}
@@ -108,7 +108,7 @@ func AppendVulnsToXML(cmdResults *results.SecurityCommandResults) error {
108
108
destination := result .FindElements ("//bom" )[0 ]
109
109
xrayResults := cmdResults .GetScaScansXrayResults ()
110
110
if len (xrayResults ) == 0 {
111
- return fmt .Errorf ("failed while getting sca scan from xray: %s" , err . Error () )
111
+ return fmt .Errorf ("xray scan results are empty" )
112
112
} else if len (xrayResults ) > 1 {
113
113
log .Warn ("Received %d results, parsing only first result" , len (xrayResults ))
114
114
}
@@ -187,6 +187,10 @@ func (enrichCmd *EnrichCommand) Run() (err error) {
187
187
scanResults .GeneralError = errors .Join (scanResults .GeneralError , fileCollectingErr )
188
188
}
189
189
190
+ if scanResults .GetErrors () != nil {
191
+ return errorutils .CheckError (scanResults .GetErrors ())
192
+ }
193
+
190
194
isXml , err := isXML (scanResults .Targets )
191
195
if err != nil {
192
196
return
@@ -200,13 +204,6 @@ func (enrichCmd *EnrichCommand) Run() (err error) {
200
204
return
201
205
}
202
206
}
203
-
204
- if err != nil {
205
- return err
206
- }
207
- if scanResults .GetErrors () != nil {
208
- return errorutils .CheckError (scanResults .GetErrors ())
209
- }
210
207
log .Info ("Enrich process completed successfully." )
211
208
return nil
212
209
}
@@ -262,7 +259,7 @@ func (enrichCmd *EnrichCommand) createIndexerHandlerFunc(indexedFileProducer par
262
259
if err != nil {
263
260
return targetResults .AddTargetError (fmt .Errorf ("%s failed to create Xray service manager: %s" , logPrefix , err .Error ()), false )
264
261
}
265
- scanResults , err := enrichgraph .RunImportGraphAndGetResults (importGraphParams , xrayManager )
262
+ scanResults , err := enrichgraph .RunImportGraphAndGetResults (importGraphParams , xrayManager , filepath . Base ( filePath ) )
266
263
if err != nil {
267
264
return targetResults .AddTargetError (fmt .Errorf ("%s failed to import graph: %s" , logPrefix , err .Error ()), false )
268
265
}
0 commit comments