Skip to content

Commit

Permalink
loader: fix relative parent paths by searching for repository_root
Browse files Browse the repository at this point in the history
  • Loading branch information
aszs committed Sep 15, 2023
1 parent b23be22 commit 119e151
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions unfurl/yamlloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ def get_remote_tags(self, url, pattern="*") -> List[str]:
url = add_user_to_url(url, candidate_parts.username, password)
return memoized_remote_tags(url, pattern="*")

def _find_repository_root(self, base):
for repo_view in self.manifest.repositories.values():
if Path(base).is_relative_to(repo_view.working_dir):
return repo_view.working_dir
return base

def resolve_url(
self,
importsLoader: toscaparser.imports.ImportsLoader,
Expand All @@ -470,8 +476,8 @@ def resolve_url(
repository_root = None # default to checking if its in the project
if importsLoader.repository_root:
if toscaparser.imports.is_url(importsLoader.repository_root):
# just make sure we didn't break out of the base
repository_root = base
# at least make sure we didn't break out of the base
repository_root = self._find_repository_root(base)
else:
repository_root = importsLoader.repository_root
if self._has_path_escaped(url, base=repository_root):
Expand Down

0 comments on commit 119e151

Please sign in to comment.