From 31a1092c4a09b4ee63e9f960c5fd9cb29b6fce4e Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Fri, 23 Sep 2022 20:13:29 +0100 Subject: [PATCH] Ensure we do not return relative paths outside the project (#2492) 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. --- src/ansiblelint/file_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ansiblelint/file_utils.py b/src/ansiblelint/file_utils.py index bf7ee74d17..2f84cc0766 100644 --- a/src/ansiblelint/file_utils.py +++ b/src/ansiblelint/file_utils.py @@ -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