Fix pathlib resolve (#8311)

* Fix pathlib resolve

* fix test
pull/8313/head
Pascal Vizeli 2017-07-03 07:24:08 +02:00 committed by GitHub
parent 3a6434f566
commit ee7d4710c4
2 changed files with 3 additions and 3 deletions

View File

@ -1079,7 +1079,7 @@ class Config(object):
"""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

View File

@ -821,13 +821,13 @@ class TestConfig(unittest.TestCase):
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: