Skip to content

Commit

Permalink
Cr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
orz25 committed Feb 11, 2024
1 parent 28f94be commit e66f775
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions commands/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func RunAudit(auditParams *AuditParams) (results *xrayutils.Results, err error)
if err = xrayutils.SendXscGitInfoRequestIfEnabled(auditParams.xrayGraphScanParams, xrayManager); err != nil {
return nil, err
}
results.MultiScanId = auditParams.xrayGraphScanParams.MultiScanId
}

// The sca scan doesn't require the analyzer manager, so it can run separately from the analyzer manager download routine.
Expand Down
2 changes: 2 additions & 0 deletions utils/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type Results struct {

ExtendedScanResults *ExtendedScanResults
JasError error

MultiScanId string
}

func NewAuditResults() *Results {
Expand Down
25 changes: 14 additions & 11 deletions utils/xraymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ func SendXscGitInfoRequestIfEnabled(graphScanParams *services.XrayGraphScanParam
if graphScanParams.XscVersion, err = xrayManager.XscEnabled(); err != nil {
return err
}
if graphScanParams.XscVersion != "" && graphScanParams.MultiScanId == "" {
multiScanId, err := xrayManager.SendXscGitInfoRequest(graphScanParams.XscGitInfoContext)
if err != nil {
return fmt.Errorf("failed sending Git Info request to XSC service, error: %s ", err.Error())
}
graphScanParams.MultiScanId = multiScanId
log.Debug(fmt.Sprintf("Created xsc git info successfully. multi_scan_id %s", multiScanId))
if err = os.Setenv("JF_MSI", multiScanId); err != nil {
// Not a fatal error, if not set the scan will not be shown at the XSC UI, should not fail the scan.
log.Debug(fmt.Sprintf("failed setting MSI as environment variable. Cause: %s", err.Error()))
}
if graphScanParams.XscVersion == "" || graphScanParams.MultiScanId != "" {
// XSC is not enabled or multiScanId already provided.
return
}
// Generate multiScanId and set it to the scan params.
multiScanId, err := xrayManager.SendXscGitInfoRequest(graphScanParams.XscGitInfoContext)
if err != nil {
return fmt.Errorf("failed sending Git Info request to XSC service, error: %s ", err.Error())
}
graphScanParams.MultiScanId = multiScanId
log.Debug(fmt.Sprintf("Created xsc git info successfully. multi_scan_id %s", multiScanId))
if err = os.Setenv("JF_MSI", multiScanId); err != nil {
// Not a fatal error, if not set the scan will not be shown at the XSC UI, should not fail the scan.
log.Debug(fmt.Sprintf("failed setting MSI as environment variable. Cause: %s", err.Error()))
}
return nil
}

0 comments on commit e66f775

Please sign in to comment.