@@ -200,17 +200,6 @@ func (sc *CmdResultsSarifConverter) validateBeforeParse() (err error) {
200200
201201func (sc * CmdResultsSarifConverter ) DeprecatedParseScaVulnerabilities (descriptors []string , scaResponse results.ScanResult [services.ScanResponse ], applicableScan ... results.ScanResult [[]* sarif.Run ]) (err error ) {
202202 return sc .parseScaVulnerabilities (sc .currentTargetConvertedRuns .currentTarget , descriptors , scaResponse , applicableScan ... )
203-
204- // if violations {
205- // if err = sc.parseScaViolations(target, descriptors, scaResponse, applicableScan...); err != nil {
206- // return
207- // }
208- // return
209- // }
210- // if err = sc.parseScaVulnerabilities(target, descriptors, scaResponse, applicableScan...); err != nil {
211- // return
212- // }
213- // return
214203}
215204
216205func (sc * CmdResultsSarifConverter ) ParseViolations (violationsScanResults results.ScanResult [violationutils.Violations ]) (err error ) {
@@ -305,127 +294,6 @@ func (sc *CmdResultsSarifConverter) ParseViolations(violationsScanResults result
305294 return
306295}
307296
308- // func parseCveViolation() {
309-
310- // }
311-
312- // func (sc *CmdResultsSarifConverter) parseScaViolations(target results.ScanTarget, descriptors []string, scanResponse results.ScanResult[services.ScanResponse], applicableScan ...results.ScanResult[[]*sarif.Run]) (err error) {
313- // if err = sc.validateBeforeParse(); err != nil {
314- // return
315- // }
316- // if sc.currentTargetConvertedRuns.scaCurrentRun == nil {
317- // sc.currentTargetConvertedRuns.scaCurrentRun = sc.createScaRun(target, len(sc.currentErrors))
318- // }
319- // // Parse violations
320- // sarifResults, sarifRules, err := PrepareSarifScaViolations(sc.currentCmdType, target, descriptors, scanResponse.Scan.Violations, sc.entitledForJas, results.ScanResultsToRuns(applicableScan)...)
321- // if err != nil || len(sarifRules) == 0 || len(sarifResults) == 0 {
322- // return
323- // }
324- // sc.addScaResultsToCurrentRun(sarifRules, sarifResults...)
325- // return
326- // }
327-
328- // func PrepareSarifScaViolations(cmdType utils.CommandType, target results.ScanTarget, descriptors []string, violations []services.Violation, entitledForJas bool, applicabilityRuns ...*sarif.Run) ([]*sarif.Result, map[string]*sarif.ReportingDescriptor, error) {
329- // sarifResults := []*sarif.Result{}
330- // rules := map[string]*sarif.ReportingDescriptor{}
331- // _, _, err := local.ForEachScanGraphViolation(
332- // target,
333- // descriptors,
334- // violations,
335- // entitledForJas,
336- // applicabilityRuns,
337- // addSarifScaSecurityViolation(cmdType, &sarifResults, &rules),
338- // addSarifScaLicenseViolation(cmdType, &sarifResults, &rules),
339- // // Operational risks violations are not supported in Sarif format
340- // nil,
341- // )
342- // return sarifResults, rules, err
343- // }
344-
345- // func addSarifScaSecurityViolation(cmdType utils.CommandType, sarifResults *[]*sarif.Result, rules *map[string]*sarif.ReportingDescriptor) local.ParseScanGraphViolationFunc {
346- // return func(violation services.Violation, cves []formats.CveRow, applicabilityStatus jasutils.ApplicabilityStatus, severity severityutils.Severity, impactedPackagesId string, fixedVersions []string, directComponents []formats.ComponentRow, impactPaths [][]formats.ComponentRow) error {
347- // maxCveScore, err := results.FindMaxCVEScore(severity, applicabilityStatus, cves)
348- // if err != nil {
349- // return err
350- // }
351- // markdownDescription, err := getScaIssueMarkdownDescription(directComponents, maxCveScore, applicabilityStatus, fixedVersions)
352- // if err != nil {
353- // return err
354- // }
355- // impactedPackagesName, impactedPackagesVersion, _ := techutils.SplitComponentId(impactedPackagesId)
356- // currentResults, currentRule := parseScaToSarifFormat(scaParseParams{
357- // CmdType: cmdType,
358- // IssueId: violation.IssueId,
359- // Watch: violation.WatchName,
360- // Summary: violation.Summary,
361- // MarkdownDescription: markdownDescription,
362- // CveScore: maxCveScore,
363- // GenerateTitleFunc: getScaSecurityViolationSarifHeadline,
364- // Cves: cves,
365- // Severity: severity,
366- // ApplicabilityStatus: applicabilityStatus,
367- // ImpactedPackagesName: impactedPackagesName,
368- // ImpactedPackagesVersion: impactedPackagesVersion,
369- // FixedVersions: fixedVersions,
370- // DirectComponents: directComponents,
371- // ImpactPaths: impactPaths,
372- // Violation: &violationContext{
373- // Watch: violation.WatchName,
374- // Policies: results.ConvertPolicesToString(violation.Policies),
375- // },
376- // })
377- // cveImpactedComponentRuleId := results.GetScaIssueId(impactedPackagesName, impactedPackagesVersion, results.GetIssueIdentifier(cves, violation.IssueId, "_"))
378- // if _, ok := (*rules)[cveImpactedComponentRuleId]; !ok {
379- // // New Rule
380- // (*rules)[cveImpactedComponentRuleId] = currentRule
381- // }
382- // *sarifResults = append(*sarifResults, currentResults...)
383- // return nil
384- // }
385- // }
386-
387- // func addSarifScaLicenseViolation(cmdType utils.CommandType, sarifResults *[]*sarif.Result, rules *map[string]*sarif.ReportingDescriptor) local.ParseScanGraphViolationFunc {
388- // return func(violation services.Violation, cves []formats.CveRow, applicabilityStatus jasutils.ApplicabilityStatus, severity severityutils.Severity, impactedPackagesId string, fixedVersions []string, directComponents []formats.ComponentRow, impactPaths [][]formats.ComponentRow) error {
389- // maxCveScore, err := results.FindMaxCVEScore(severity, applicabilityStatus, cves)
390- // if err != nil {
391- // return err
392- // }
393- // impactedPackagesName, impactedPackagesVersion, _ := techutils.SplitComponentId(impactedPackagesId)
394- // markdownDescription, err := getScaLicenseViolationMarkdown(impactedPackagesName, impactedPackagesVersion, violation.LicenseKey, directComponents)
395- // if err != nil {
396- // return err
397- // }
398- // currentResults, currentRule := parseScaToSarifFormat(scaParseParams{
399- // CmdType: cmdType,
400- // Watch: violation.WatchName,
401- // IssueId: violation.LicenseKey,
402- // Summary: getLicenseViolationSummary(impactedPackagesName, impactedPackagesVersion, violation.LicenseKey),
403- // MarkdownDescription: markdownDescription,
404- // CveScore: maxCveScore,
405- // GenerateTitleFunc: getXrayLicenseSarifHeadline,
406- // Cves: cves,
407- // Severity: severity,
408- // ApplicabilityStatus: applicabilityStatus,
409- // ImpactedPackagesName: impactedPackagesName,
410- // ImpactedPackagesVersion: impactedPackagesVersion,
411- // FixedVersions: fixedVersions,
412- // DirectComponents: directComponents,
413- // ImpactPaths: impactPaths,
414- // Violation: &violationutils.Violation{
415- // Watch: violation.WatchName,
416- // Policies: results.ConvertPolicesToString(violation.Policies),
417- // },
418- // })
419- // cveImpactedComponentRuleId := results.GetScaIssueId(impactedPackagesName, impactedPackagesVersion, results.GetIssueIdentifier(cves, violation.LicenseKey, "_"))
420- // if _, ok := (*rules)[cveImpactedComponentRuleId]; !ok {
421- // // New Rule
422- // (*rules)[cveImpactedComponentRuleId] = currentRule
423- // }
424- // *sarifResults = append(*sarifResults, currentResults...)
425- // return nil
426- // }
427- // }
428-
429297func (sc * CmdResultsSarifConverter ) parseScaVulnerabilities (target results.ScanTarget , descriptors []string , scanResponse results.ScanResult [services.ScanResponse ], applicableScan ... results.ScanResult [[]* sarif.Run ]) (err error ) {
430298 if err = sc .validateBeforeParse (); err != nil {
431299 return
@@ -923,27 +791,6 @@ func patchSarifRuns(params PatchSarifParams, runs ...*sarif.Run) []*sarif.Run {
923791 return patchedRuns
924792}
925793
926- // func patchRunsToPassIngestionRules(baseJfrogUrl string, cmdType utils.CommandType, subScanType utils.SubScanType, patchBinaryPaths, isViolations bool, target results.ScanTarget, runs ...*sarif.Run) []*sarif.Run {
927- // patchedRuns := []*sarif.Run{}
928- // // Patch changes may alter the original run, so we will create a new run for each
929- // for _, run := range runs {
930- // patched := sarifutils.CopyRun(run)
931- // // Since we run in temp directories files should be relative
932- // // Patch by converting the file paths to relative paths according to the invocations
933- // convertPaths(cmdType, subScanType, patched)
934- // if cmdType.IsTargetBinary() && subScanType == utils.SecretsScan {
935- // // Patch the tool name in case of binary scan
936- // sarifutils.SetRunToolName(BinarySecretScannerToolName, patched)
937- // }
938- // if patched.Tool.Driver != nil {
939- // patched.Tool.Driver.Rules = patchRules(baseJfrogUrl, cmdType, subScanType, isViolations, patched.Tool.Driver.Rules...)
940- // }
941- // patched.Results = patchResults(cmdType, subScanType, patchBinaryPaths, isViolations, target, patched, patched.Results...)
942- // patchedRuns = append(patchedRuns, patched)
943- // }
944- // return patchedRuns
945- // }
946-
947794func patchPaths (params PatchSarifParams , runs ... * sarif.Run ) {
948795 if ! params .ConvertPaths {
949796 return
@@ -978,20 +825,6 @@ func pathTool(params PatchSarifParams, runs ...*sarif.Run) {
978825 }
979826}
980827
981- // func convertPaths(commandType utils.CommandType, subScanType utils.SubScanType, runs ...*sarif.Run) {
982- // // Convert base on invocation for source code
983- // sarifutils.ConvertRunsPathsToRelative(runs...)
984- // if !(commandType == utils.DockerImage && subScanType == utils.SecretsScan) {
985- // return
986- // }
987- // for _, run := range runs {
988- // for _, result := range run.Results {
989- // // For Docker secret scan, patch the logical location if not exists
990- // patchDockerSecretLocations(result)
991- // }
992- // }
993- // }
994-
995828// Patch the URI to be the file path from sha<number>/<hash>/
996829// Extract the layer from the location URI, adds it as a logical location kind "layer"
997830func patchDockerSecretLocations (result * sarif.Result ) {
0 commit comments