From 613fc25f4b2b3232fbb069efd603f5755d85ddc4 Mon Sep 17 00:00:00 2001 From: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:53:22 -0500 Subject: [PATCH] chore: convert IsAbs Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> --- syft/format/common/spdxhelpers/to_format_model.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/syft/format/common/spdxhelpers/to_format_model.go b/syft/format/common/spdxhelpers/to_format_model.go index a394666a94b..b9010d3fa67 100644 --- a/syft/format/common/spdxhelpers/to_format_model.go +++ b/syft/format/common/spdxhelpers/to_format_model.go @@ -845,9 +845,10 @@ func trimPatchVersion(semver string) string { // with the root of the package archive or directory func convertAbsoluteToRelative(absPath string) (string, error) { // Ensure the absolute path is absolute (although it should already be) - absPath, err := filepath.Abs(absPath) - if err != nil { - return "", fmt.Errorf("error converting absPath to absolute path: %v", err) + if !filepath.IsAbs(absPath) { + // already relative + log.Debugf("%s is already relative", absPath) + return absPath, nil } // we use "/" here given that we're converting absolute paths from root to relative