Skip to content

Commit

Permalink
Fix pathlib resolve (home-assistant#8311)
Browse files Browse the repository at this point in the history
* Fix pathlib resolve

* fix test
  • Loading branch information
pvizeli authored Jul 3, 2017
1 parent 3a6434f commit ee7d471
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ def is_allowed_path(self, path: str) -> bool:
"""Check if the path is valid for access from outside."""
parent = pathlib.Path(path).parent
try:
parent.resolve() # pylint: disable=no-member
parent = parent.resolve() # pylint: disable=no-member
except (FileNotFoundError, RuntimeError, PermissionError):
return False

Expand Down
4 changes: 2 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,13 +821,13 @@ def test_is_allowed_path(self):
for path in valid:
assert self.config.is_allowed_path(path)

self.config.whitelist_external_dirs = set(('/home',))
self.config.whitelist_external_dirs = set(('/home', '/var'))

unvalid = [
"/hass/config/secure",
"/etc/passwd",
"/root/secure_file",
"/hass/config/test/../../../etc/passwd",
"/var/../etc/passwd",
test_file,
]
for path in unvalid:
Expand Down

0 comments on commit ee7d471

Please sign in to comment.