parent
3a6434f566
commit
ee7d4710c4
|
@ -1079,7 +1079,7 @@ class Config(object):
|
||||||
"""Check if the path is valid for access from outside."""
|
"""Check if the path is valid for access from outside."""
|
||||||
parent = pathlib.Path(path).parent
|
parent = pathlib.Path(path).parent
|
||||||
try:
|
try:
|
||||||
parent.resolve() # pylint: disable=no-member
|
parent = parent.resolve() # pylint: disable=no-member
|
||||||
except (FileNotFoundError, RuntimeError, PermissionError):
|
except (FileNotFoundError, RuntimeError, PermissionError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -821,13 +821,13 @@ class TestConfig(unittest.TestCase):
|
||||||
for path in valid:
|
for path in valid:
|
||||||
assert self.config.is_allowed_path(path)
|
assert self.config.is_allowed_path(path)
|
||||||
|
|
||||||
self.config.whitelist_external_dirs = set(('/home',))
|
self.config.whitelist_external_dirs = set(('/home', '/var'))
|
||||||
|
|
||||||
unvalid = [
|
unvalid = [
|
||||||
"/hass/config/secure",
|
"/hass/config/secure",
|
||||||
"/etc/passwd",
|
"/etc/passwd",
|
||||||
"/root/secure_file",
|
"/root/secure_file",
|
||||||
"/hass/config/test/../../../etc/passwd",
|
"/var/../etc/passwd",
|
||||||
test_file,
|
test_file,
|
||||||
]
|
]
|
||||||
for path in unvalid:
|
for path in unvalid:
|
||||||
|
|
Loading…
Reference in New Issue