diff --git a/supervisor/addons/options.py b/supervisor/addons/options.py index 45a2f9951..ec81e6619 100644 --- a/supervisor/addons/options.py +++ b/supervisor/addons/options.py @@ -138,7 +138,7 @@ class AddonOptions(CoreSysAttributes): range_args[group_name[2:]] = float(group_value) if typ.startswith(_STR) or typ.startswith(_PASSWORD): - if typ.startswith(_PASSWORD): + if typ.startswith(_PASSWORD) and value: self.pwned.add(hashlib.sha1(str(value).encode()).hexdigest()) return vol.All(str(value), vol.Range(**range_args))(value) elif typ.startswith(_INT): diff --git a/supervisor/utils/pwned.py b/supervisor/utils/pwned.py index 5693c0946..c8addd4a7 100644 --- a/supervisor/utils/pwned.py +++ b/supervisor/utils/pwned.py @@ -22,7 +22,7 @@ async def check_pwned_password(websession: aiohttp.ClientSession, sha1_pw: str) data = await request.text() buffer = io.StringIO(data) - for line in buffer.readline(): + for line in buffer: if sha1_pw != line.split(":")[0]: continue return True diff --git a/tests/addons/test_options.py b/tests/addons/test_options.py index ca58a82e2..ed6c2a04a 100644 --- a/tests/addons/test_options.py +++ b/tests/addons/test_options.py @@ -181,6 +181,11 @@ def test_simple_schema_password(coresys): assert validate.pwned == {"7110eda4d09e062aa5e4a390b0a572ac0d2c0220"} + validate.pwned.clear() + assert validate({"name": "Pascal", "password": "", "fires": True, "alias": "test"}) + + assert not validate.pwned + def test_ui_simple_schema(coresys): """Test with simple schema."""