diff --git a/cmd/checkmarxOneExecuteScan.go b/cmd/checkmarxOneExecuteScan.go index c457372c65..4eec98baf6 100644 --- a/cmd/checkmarxOneExecuteScan.go +++ b/cmd/checkmarxOneExecuteScan.go @@ -8,6 +8,7 @@ import ( "io" "maps" "math" + "net/url" "os" "path/filepath" "regexp" @@ -803,7 +804,7 @@ func (c *checkmarxOneExecuteScanHelper) getDetailedResults(scan *checkmarxOne.Sc } resultMap["Preset"] = scanmeta.PresetName - resultMap["DeepLink"] = fmt.Sprintf("%v/projects/%v/overview?branch=%v", c.config.ServerURL, c.Project.ProjectID, scan.Branch) + resultMap["DeepLink"] = fmt.Sprintf("%v/projects/%v/overview?branch=%v", c.config.ServerURL, c.Project.ProjectID, url.QueryEscape(scan.Branch)) resultMap["ReportCreationTime"] = time.Now().String() resultMap["High"] = map[string]int{} resultMap["Medium"] = map[string]int{} diff --git a/pkg/checkmarxone/checkmarxone.go b/pkg/checkmarxone/checkmarxone.go index 705aea76da..6d5d14ab54 100644 --- a/pkg/checkmarxone/checkmarxone.go +++ b/pkg/checkmarxone/checkmarxone.go @@ -759,7 +759,7 @@ func (sys *SystemInstance) GetProjectsByName(projectName string) ([]Project, err var err error body := url.Values{} - body.Add("name", projectName) + body.Add("names", projectName) data, err = sendRequest(sys, http.MethodGet, fmt.Sprintf("/projects/?%v", body.Encode()), nil, header, []int{404}) diff --git a/pkg/checkmarxone/cxjson_to_sarif.go b/pkg/checkmarxone/cxjson_to_sarif.go index 7560eaebe5..345924ad56 100644 --- a/pkg/checkmarxone/cxjson_to_sarif.go +++ b/pkg/checkmarxone/cxjson_to_sarif.go @@ -67,6 +67,10 @@ func ConvertCxJSONToSarif(sys System, serverURL string, scanResults *[]ScanResul for k := 0; k < len(r.Data.Nodes); k++ { loc := *new(format.Location) loc.PhysicalLocation.ArtifactLocation.URI = r.Data.Nodes[0].FileName + // remove absolute path of file name (coming from JSON format) + if len(r.Data.Nodes[0].FileName) > 0 && r.Data.Nodes[0].FileName[0:1] == "/" { + loc.PhysicalLocation.ArtifactLocation.URI = r.Data.Nodes[0].FileName[1:] + } loc.PhysicalLocation.Region.StartLine = r.Data.Nodes[k].Line loc.PhysicalLocation.Region.EndLine = r.Data.Nodes[k].Line loc.PhysicalLocation.Region.StartColumn = r.Data.Nodes[k].Column @@ -91,6 +95,10 @@ func ConvertCxJSONToSarif(sys System, serverURL string, scanResults *[]ScanResul threadFlowLocation := *new(format.Locations) tfloc := new(format.Location) tfloc.PhysicalLocation.ArtifactLocation.URI = r.Data.Nodes[0].FileName + // remove absolute path of file name (coming from JSON format) + if len(r.Data.Nodes[0].FileName) > 0 && r.Data.Nodes[0].FileName[0:1] == "/" { + loc.PhysicalLocation.ArtifactLocation.URI = r.Data.Nodes[0].FileName[1:] + } tfloc.PhysicalLocation.Region.StartLine = r.Data.Nodes[k].Line tfloc.PhysicalLocation.Region.EndLine = r.Data.Nodes[k].Line tfloc.PhysicalLocation.Region.StartColumn = r.Data.Nodes[k].Column @@ -244,7 +252,7 @@ func ConvertCxJSONToSarif(sys System, serverURL string, scanResults *[]ScanResul log.Entry().Debug("[SARIF] Now handling driver object.") tool := *new(format.Tool) tool.Driver = *new(format.Driver) - tool.Driver.Name = "CheckmarxOne SCA" + tool.Driver.Name = "Checkmarx One" // TODO: a way to fetch/store the version tool.Driver.Version = "1" //strings.Split(cxxml.CheckmarxVersion, "V ")