From 60cd1563866e445d1d47fefc247fe19b832d4d60 Mon Sep 17 00:00:00 2001 From: Mehant Kammakomati Date: Mon, 10 Apr 2023 23:58:33 +0530 Subject: [PATCH] fix: fail when the paths sent are parent to another Signed-off-by: Mehant Kammakomati --- common/pathconverters/pathconverters.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/pathconverters/pathconverters.go b/common/pathconverters/pathconverters.go index fb347606f..a19883bb4 100644 --- a/common/pathconverters/pathconverters.go +++ b/common/pathconverters/pathconverters.go @@ -189,6 +189,17 @@ func MakePlanPathsAbsolute(obj interface{}, sourcePath, assetsPath string) (err // ChangePaths changes paths which are based out of one root to another root func ChangePaths(obj interface{}, mapping map[string]string) error { + for parent := range mapping { + for child := range mapping { + if parent != child { + if common.IsParent(child, parent) { + err := fmt.Errorf("the provided source paths %s is child of %s.", child, parent) + logrus.Errorf("%s", err) + return err + } + } + } + } function := func(path string) (string, error) { if path == "" { return path, nil