Skip to content

Commit

Permalink
Update fields
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Aug 21, 2023
1 parent 94e1af2 commit b6162da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion xray/manager/xsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (xsc *XscServicesManger) ScanGraph(params scan.XrayGraphScanParams) (scanId
scanService := scan.NewXscScanService(xsc.client, xsc.config.GetServiceDetails())
if params.MultiScanId, err = scanService.SendScanContext(params.XscGitInfoContext); err != nil {
// Don't fail the entire scan when failed to send XscGitInfoContext
log.Warn("failed to send xsc git info context with the foloowing error: ", err.Error())
log.Warn("failed to send xsc git info context with the following error: ", err.Error())
}
return scanService.ScanGraph(params)
}
Expand Down
34 changes: 18 additions & 16 deletions xray/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,14 @@ func createScanGraphQueryParams(scanParams XrayGraphScanParams) string {
params = append(params, watchesQueryParam+watch)
}
}
case scanParams.XscGitInfoContext != nil && scanParams.MultiScanId != "":
params = append(params, multiScanIdParam+scanParams.MultiScanId)
case scanParams.XscGitInfoContext != nil:
if scanParams.MultiScanId != "" {
params = append(params, multiScanIdParam+scanParams.MultiScanId)
}
if len(scanParams.XscGitInfoContext.Technologies) > 0 {
params = append(params, scanTechQueryParam+scanParams.XscGitInfoContext.Technologies[0])
}
}

if scanParams.ScanType != "" {
params = append(params, scanTypeQueryParam+string(scanParams.ScanType))
}
Expand Down Expand Up @@ -326,17 +330,15 @@ type JfrogResearchSeverityReason struct {
}

type XscGitInfoContext struct {
GitRepoUrl string `json:"git_repo_url"`
GitRepoName string `json:"git_repo_name"`
GitTargetRepoName string `json:"git_target_repo_name"`
GitProject string `json:"git_project"`
GitProvider string `json:"git_provider"`
Technologies []string `json:"technologies"`
BranchName string `json:"branch_name"`
TargetBranchName string `json:"target_branch_name"`
LastCommit string `json:"last_commit"`
CommitHash string `json:"commit_hash"`
CommitMessage string `json:"commit_message"`
CommitAuthor string `json:"commit_author"`
Date string `json:"date"`
GitRepoUrl string `json:"git_repo_url"`
GitRepoName string `json:"git_repo_name"`
GitProject string `json:"git_project"`
GitProvider string `json:"git_provider"`
Technologies []string `json:"technologies"`
BranchName string `json:"branch_name"`
LastCommit string `json:"last_commit"`
CommitHash string `json:"commit_hash"`
CommitMessage string `json:"commit_message"`
CommitAuthor string `json:"commit_author"`
Date string `json:"date"`
}
15 changes: 4 additions & 11 deletions xray/scan/xscScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const (

multiScanIdParam = "multi_scan_id="

scanTechQueryParam = "tech="

XscVersionAPI = "/api/v1/system/version"
)

Expand Down Expand Up @@ -93,21 +95,12 @@ func (xsc *XscScanService) ScanGraph(scanParams XrayGraphScanParams) (string, er
return scanResponse.ScanId, err
}

func (xsc *XscScanService) GetScanGraphResults(scanId string, includeVulnerabilities, includeLicenses bool) (*ScanResponse, error) {
func (xsc *XscScanService) GetScanGraphResults(scanId string, _, _ bool) (*ScanResponse, error) {
httpClientsDetails := xsc.XrayDetails.CreateHttpClientDetails()
utils.SetContentType("application/json", &httpClientsDetails.Headers)

// The scan request may take some time to complete. We expect to receive a 202 response, until the completion.
// TODO multi scan should be removed here but caused api to crash so dummy value inserted.
endPoint := xsc.XrayDetails.GetXscUrl() + scanGraphAPI + "/" + scanId + "?multi_scan_id=a"
if includeVulnerabilities {
endPoint += includeVulnerabilitiesParam
if includeLicenses {
endPoint += andIncludeLicensesParam
}
} else if includeLicenses {
endPoint += includeLicensesParam
}
endPoint := xsc.XrayDetails.GetXscUrl() + scanGraphAPI + "/" + scanId + "?multi_scan_id=dummpyIdRemoveme"
log.Info("Waiting for scan to complete on JFrog Xray...")
pollingAction := func() (shouldStop bool, responseBody []byte, err error) {
resp, body, _, err := xsc.client.SendGet(endPoint, true, &httpClientsDetails)
Expand Down

0 comments on commit b6162da

Please sign in to comment.