From 1892eb654f2908ec49057dbf55edc6c9b0234822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B8yer=20Iversen?= Date: Tue, 15 Aug 2017 15:41:37 +0200 Subject: [PATCH] Is_allowed_path raise for None path (#8953) * is_allowed_path * Fix #8948 * assert path is not None * Update test_core.py * Update test_core.py * Update test_core.py --- homeassistant/core.py | 2 ++ tests/test_core.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/homeassistant/core.py b/homeassistant/core.py index 496bb018fbd..187dfcf1b83 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -1079,6 +1079,8 @@ class Config(object): def is_allowed_path(self, path: str) -> bool: """Check if the path is valid for access from outside.""" + assert path is not None + parent = pathlib.Path(path).parent try: parent = parent.resolve() # pylint: disable=no-member diff --git a/tests/test_core.py b/tests/test_core.py index 1d22d17f996..b7d049cb747 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -833,6 +833,9 @@ class TestConfig(unittest.TestCase): for path in unvalid: assert not self.config.is_allowed_path(path) + with self.assertRaises(AssertionError): + self.config.is_allowed_path(None) + @patch('homeassistant.core.monotonic') def test_create_timer(mock_monotonic, loop):