Skip to content

Commit

Permalink
Ensure we do not return relative paths outside the project (ansible#2492
Browse files Browse the repository at this point in the history
)

Makes normpath match normpath_path one and avoid returning relative
paths outside current working directory / project.

This should fix the WSL job, which was running the testing outside
user home directory, and that produced different file paths.
  • Loading branch information
ssbarnea authored and davedittrich committed Sep 27, 2022
1 parent b18a687 commit 88feef8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ansiblelint/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def normpath(path: str | BasePathLike) -> str:
# we avoid returning relative paths that end-up at root level
if path_absolute in relpath:
return path_absolute
if relpath.startswith("../"):
return path_absolute
return relpath


Expand Down

0 comments on commit 88feef8

Please sign in to comment.