Skip to content

Commit

Permalink
fix: fail when the paths sent are parent to another (#1023)
Browse files Browse the repository at this point in the history
Signed-off-by: Mehant Kammakomati <mehant.kammakomati2@ibm.com>
  • Loading branch information
kmehant authored Apr 11, 2023
1 parent bf29542 commit dea5d6e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common/pathconverters/pathconverters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dea5d6e

Please sign in to comment.