Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for known Hue vulnerability #31494

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions homeassistant/components/hue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import voluptuous as vol

from homeassistant import config_entries, core
from homeassistant.components import persistent_notification
from homeassistant.const import CONF_HOST
from homeassistant.helpers import config_validation as cv, device_registry as dr

Expand Down Expand Up @@ -142,8 +143,20 @@ async def async_setup_entry(
sw_version=config.swversion,
)

if config.swupdate2_bridge_state == "readytoinstall":
err = "Please check for software updates of the bridge in the Philips Hue App."
if config.modelid == "BSB002" and config.swversion < "1935144040":
persistent_notification.async_create(
hass,
"Your Hue hub has a known security vulnerability ([CVE-2020-6007](https://cve.circl.lu/cve/CVE-2020-6007)). Go to the Hue app and check for software updates.",
"Signify Hue",
"hue_hub_firmware",
)

elif config.swupdate2_bridge_state == "readytoinstall":
err = (
"Please check for software updates of the bridge in the Philips Hue App.",
"Signify Hue",
"hue_hub_firmware",
)
_LOGGER.warning(err)

return True
Expand Down
34 changes: 33 additions & 1 deletion tests/components/hue/test_init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test Hue setup process."""
from unittest.mock import Mock, patch
from unittest.mock import Mock

from asynctest import CoroutineMock, patch

from homeassistant.components import hue
from homeassistant.setup import async_setup_component
Expand Down Expand Up @@ -184,3 +186,33 @@ async def test_setting_unique_id(hass):
assert await async_setup_component(hass, hue.DOMAIN, {}) is True

assert entry.unique_id == "mock-id"


async def test_security_vuln_check(hass):
"""Test that we report security vulnerabilities."""
assert await async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(domain=hue.DOMAIN, data={"host": "0.0.0.0"})
entry.add_to_hass(hass)

with patch.object(
hue,
"HueBridge",
Mock(
return_value=Mock(
async_setup=CoroutineMock(return_value=True),
api=Mock(
config=Mock(
bridgeid="", mac="", modelid="BSB002", swversion="1935144020"
)
),
)
),
):

assert await async_setup_component(hass, "hue", {})

await hass.async_block_till_done()

state = hass.states.get("persistent_notification.hue_hub_firmware")
assert state is not None
assert "CVE-2020-6007" in state.attributes["message"]