From 79037efe66cc361c7b68fdcb16f06c1b633f40cf Mon Sep 17 00:00:00 2001 From: attiasas Date: Wed, 20 Sep 2023 10:17:32 +0300 Subject: [PATCH] reposition override --- xray/utils/resultwriter.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xray/utils/resultwriter.go b/xray/utils/resultwriter.go index efc3a8c72..d1ef8f6a8 100644 --- a/xray/utils/resultwriter.go +++ b/xray/utils/resultwriter.go @@ -263,10 +263,6 @@ func addXrayCveIssueToSarifRun(cves []formats.CveRow, issueId, severity, file st // Non path - should not be used as location func getXrayIssueLocationIfValidExists(file string, run *sarif.Run, override bool) (location *sarif.Location, err error) { location = sarif.NewLocation().WithPhysicalLocation(sarif.NewPhysicalLocation().WithArtifactLocation(sarif.NewArtifactLocation().WithUri(file))) - if override { - // Use the content as is - return - } // Check if full path exists, err := fileutils.IsFileExists(file, false) if err != nil || exists { @@ -274,8 +270,12 @@ func getXrayIssueLocationIfValidExists(file string, run *sarif.Run, override boo } // Check if relative path fullPath := GetFullLocationFileName(file, run.Invocations) - location = sarif.NewLocation().WithPhysicalLocation(sarif.NewPhysicalLocation().WithArtifactLocation(sarif.NewArtifactLocation().WithUri("file://" + fullPath))) if exists, err = fileutils.IsFileExists(fullPath, false); err != nil || exists { + location = sarif.NewLocation().WithPhysicalLocation(sarif.NewPhysicalLocation().WithArtifactLocation(sarif.NewArtifactLocation().WithUri("file://" + fullPath))) + return + } + if override { + // Use the content as is return } // Not usable content