From bec23def1f7a0a85da1c23ba25adb257d542e1eb Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 21:12:59 -0600 Subject: [PATCH] sanitize filenames everywhere a URI is used to derive the filename --- internal/exec/vendor_component_utils.go | 2 +- internal/exec/vendor_model.go | 2 +- internal/exec/vendor_model_component.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/exec/vendor_component_utils.go b/internal/exec/vendor_component_utils.go index 419617e59..ad2f18e08 100644 --- a/internal/exec/vendor_component_utils.go +++ b/internal/exec/vendor_component_utils.go @@ -180,7 +180,7 @@ func copyComponentToDestination(atmosConfig schema.AtmosConfiguration, tempDir, componentPath2 := componentPath if sourceIsLocalFile { if filepath.Ext(componentPath) == "" { - componentPath2 = filepath.Join(componentPath, filepath.Base(uri)) + componentPath2 = filepath.Join(componentPath, sanitizeFileName(uri)) } } diff --git a/internal/exec/vendor_model.go b/internal/exec/vendor_model.go index 7171f73ec..1209e6805 100644 --- a/internal/exec/vendor_model.go +++ b/internal/exec/vendor_model.go @@ -298,7 +298,7 @@ func downloadAndInstall(p *pkgAtmosVendor, dryRun bool, atmosConfig schema.Atmos OnSymlink: func(src string) cp.SymlinkAction { return cp.Deep }, } if p.sourceIsLocalFile { - tempDir = filepath.Join(tempDir, filepath.Base(p.uri)) + tempDir = filepath.Join(tempDir, sanitizeFileName(p.uri)) } if err := cp.Copy(p.uri, tempDir, copyOptions); err != nil { return installedPkgMsg{ diff --git a/internal/exec/vendor_model_component.go b/internal/exec/vendor_model_component.go index 213140a64..38671b190 100644 --- a/internal/exec/vendor_model_component.go +++ b/internal/exec/vendor_model_component.go @@ -124,7 +124,7 @@ func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfigurati switch p.pkgType { case pkgTypeRemote: - tempDir = filepath.Join(tempDir, filepath.Base(p.uri)) + tempDir = filepath.Join(tempDir, sanitizeFileName(p.uri)) client := &getter.Client{ Ctx: context.Background(), @@ -159,7 +159,7 @@ func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfigurati tempDir2 := tempDir if p.sourceIsLocalFile { - tempDir2 = filepath.Join(tempDir, filepath.Base(p.uri)) + tempDir2 = filepath.Join(tempDir, sanitizeFileName(p.uri)) } if err = cp.Copy(p.uri, tempDir2, copyOptions); err != nil {