From 1d3f880f8207f85777569a45405f979a9c3acfcf Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Fri, 28 Aug 2020 14:39:17 +0200 Subject: [PATCH 1/6] Bump version 238 --- supervisor/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/const.py b/supervisor/const.py index ea4127c7e..7340ded53 100644 --- a/supervisor/const.py +++ b/supervisor/const.py @@ -3,7 +3,7 @@ from enum import Enum from ipaddress import ip_network from pathlib import Path -SUPERVISOR_VERSION = "237" +SUPERVISOR_VERSION = "238" URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons" URL_HASSIO_APPARMOR = "https://version.home-assistant.io/apparmor.txt" From 8193f4363481bb0753601519e57b7a755dff3766 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 29 Aug 2020 10:54:16 +0200 Subject: [PATCH 2/6] Fix secrets with add-on validation (#1990) --- supervisor/addons/validate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/addons/validate.py b/supervisor/addons/validate.py index b07bbfaa3..62e5d2e77 100644 --- a/supervisor/addons/validate.py +++ b/supervisor/addons/validate.py @@ -387,7 +387,7 @@ def _single_validate(coresys: CoreSys, typ: str, value: Any, key: str): # Lookup secret if str(value).startswith("!secret "): secret: str = value.partition(" ")[2] - value = coresys.secrets.get(secret) + value = coresys.homeassistant.secrets.get(secret) if value is None: raise vol.Invalid(f"Unknown secret {secret}") from None From f937876a1ba215181ebaea63ffffdd6ab12e5a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sat, 29 Aug 2020 10:56:45 +0200 Subject: [PATCH 3/6] Set parse issues as critical (#1989) --- supervisor/utils/gdbus.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/supervisor/utils/gdbus.py b/supervisor/utils/gdbus.py index a5456542b..26b8b0594 100644 --- a/supervisor/utils/gdbus.py +++ b/supervisor/utils/gdbus.py @@ -153,8 +153,7 @@ class DBus: try: return json.loads(json_raw) except json.JSONDecodeError as err: - _LOGGER.error("Can't parse '%s': %s", json_raw, err) - _LOGGER.debug("GVariant data: '%s'", raw) + _LOGGER.critical("Can't parse '%s': '%s' - %s", json_raw, raw, err) raise DBusParseError() from err @staticmethod From 58b88a6919a016b2776e1c41a8be7243e3c39e3d Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 29 Aug 2020 11:35:15 +0200 Subject: [PATCH 4/6] Check if supervisor run priv (#1993) --- supervisor/core.py | 4 ++++ supervisor/supervisor.py | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/supervisor/core.py b/supervisor/core.py index 5e458acd1..8943104f4 100644 --- a/supervisor/core.py +++ b/supervisor/core.py @@ -45,6 +45,10 @@ class Core(CoreSysAttributes): _LOGGER.error( "Detected Docker running inside LXC. Running Home Assistant with the Supervisor on LXC is not supported!" ) + elif not self.sys_supervisor.instance.privileged: + self.supported = False + self.healthy = False + _LOGGER.error("Supervisor does not run in Privileged mode.") if self.sys_docker.info.check_requirements(): self.supported = False diff --git a/supervisor/supervisor.py b/supervisor/supervisor.py index 5401f065a..9fdd58b49 100644 --- a/supervisor/supervisor.py +++ b/supervisor/supervisor.py @@ -41,12 +41,6 @@ class Supervisor(CoreSysAttributes): with suppress(DockerAPIError): await self.instance.cleanup() - # Check privileged mode - if not self.instance.privileged: - _LOGGER.error( - "Supervisor does not run in Privileged mode. Hassio runs with limited functionality!" - ) - @property def ip_address(self) -> IPv4Address: """Return IP of Supervisor instance.""" From a9a2c35f06d2a320a827995e081d04f4c0db0757 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 29 Aug 2020 11:44:08 +0200 Subject: [PATCH 5/6] Sentry send env infos (#1992) --- supervisor/misc/filter.py | 2 ++ tests/misc/test_filter_data.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/supervisor/misc/filter.py b/supervisor/misc/filter.py index bafac4b7f..c76a0bcb2 100644 --- a/supervisor/misc/filter.py +++ b/supervisor/misc/filter.py @@ -34,6 +34,8 @@ def filter_data(coresys: CoreSys, event: dict, hint: dict) -> dict: if not coresys.config.diagnostics or not coresys.core.supported or dev_env: return None + event.setdefault("extra", {}).update({"os.environ": dict(os.environ)}) + # Not full startup - missing information if coresys.core.state in (CoreState.INITIALIZE, CoreState.SETUP): return event diff --git a/tests/misc/test_filter_data.py b/tests/misc/test_filter_data.py index aceab23f0..eb6dcfcf7 100644 --- a/tests/misc/test_filter_data.py +++ b/tests/misc/test_filter_data.py @@ -1,11 +1,21 @@ """Test sentry data filter.""" +import os from unittest.mock import patch +import pytest + from supervisor.const import SUPERVISOR_VERSION, CoreState from supervisor.exceptions import AddonConfigurationError from supervisor.misc.filter import filter_data -SAMPLE_EVENT = {"sample": "event"} +SAMPLE_EVENT = {"sample": "event", "extra": {"Test": "123"}} + + +@pytest.fixture +def sys_env(autouse=True): + """Fixture to inject hassio env.""" + with patch.dict(os.environ, {"Test": "123"}): + yield def test_ignored_exception(coresys): From 7e1b179cdd2c0f99a632097bd41749e68ecb00d9 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 29 Aug 2020 12:03:29 +0200 Subject: [PATCH 6/6] Fix error handling unsupported (#1994) * Try to catch unhealthy * revert --- supervisor/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/core.py b/supervisor/core.py index 8943104f4..9012c6788 100644 --- a/supervisor/core.py +++ b/supervisor/core.py @@ -149,7 +149,7 @@ class Core(CoreSysAttributes): # Check if image names from denylist exist try: if await self.sys_run_in_executor(self.sys_docker.check_denylist_images): - self.coresys.supported = False + self.supported = False self.healthy = False except DockerAPIError: self.healthy = False