mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use xml.etree through defusedxml (#19640)
This commit is contained in:
parent
32eb4e518b
commit
f925d9ca6b
@ -6,7 +6,6 @@ https://home-assistant.io/components/ihc/
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import xml.etree.ElementTree
|
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -24,7 +23,7 @@ from homeassistant.helpers import discovery
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
|
|
||||||
REQUIREMENTS = ['ihcsdk==2.2.0']
|
REQUIREMENTS = ['ihcsdk==2.2.0', 'defusedxml==0.5.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -217,11 +216,13 @@ def get_manual_configuration(
|
|||||||
def autosetup_ihc_products(hass: HomeAssistantType, config, ihc_controller,
|
def autosetup_ihc_products(hass: HomeAssistantType, config, ihc_controller,
|
||||||
controller_id):
|
controller_id):
|
||||||
"""Auto setup of IHC products from the IHC project file."""
|
"""Auto setup of IHC products from the IHC project file."""
|
||||||
|
from defusedxml import ElementTree
|
||||||
|
|
||||||
project_xml = ihc_controller.get_project()
|
project_xml = ihc_controller.get_project()
|
||||||
if not project_xml:
|
if not project_xml:
|
||||||
_LOGGER.error("Unable to read project from IHC controller")
|
_LOGGER.error("Unable to read project from IHC controller")
|
||||||
return False
|
return False
|
||||||
project = xml.etree.ElementTree.fromstring(project_xml)
|
project = ElementTree.fromstring(project_xml)
|
||||||
|
|
||||||
# if an auto setup file exist in the configuration it will override
|
# if an auto setup file exist in the configuration it will override
|
||||||
yaml_path = hass.config.path(AUTO_SETUP_YAML)
|
yaml_path = hass.config.path(AUTO_SETUP_YAML)
|
||||||
|
@ -14,6 +14,8 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_DOMAIN
|
|||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
REQUIREMENTS = ['defusedxml==0.5.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOMAIN = 'namecheapdns'
|
DOMAIN = 'namecheapdns'
|
||||||
@ -55,7 +57,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
async def _update_namecheapdns(session, host, domain, password):
|
async def _update_namecheapdns(session, host, domain, password):
|
||||||
"""Update namecheap DNS entry."""
|
"""Update namecheap DNS entry."""
|
||||||
import xml.etree.ElementTree as ET
|
import defusedxml.ElementTree as ET
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'host': host,
|
'host': host,
|
||||||
|
@ -6,7 +6,6 @@ https://home-assistant.io/components/sensor.ohmconnect/
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import xml.etree.ElementTree as ET
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -17,6 +16,8 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
REQUIREMENTS = ['defusedxml==0.5.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_ID = 'id'
|
CONF_ID = 'id'
|
||||||
@ -68,6 +69,8 @@ class OhmconnectSensor(Entity):
|
|||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data from OhmConnect."""
|
"""Get the latest data from OhmConnect."""
|
||||||
|
import defusedxml.ElementTree as ET
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = ("https://login.ohmconnect.com"
|
url = ("https://login.ohmconnect.com"
|
||||||
"/verify-ohm-hour/{}").format(self._ohmid)
|
"/verify-ohm-hour/{}").format(self._ohmid)
|
||||||
|
@ -295,7 +295,10 @@ datapoint==0.4.3
|
|||||||
# homeassistant.components.light.decora_wifi
|
# homeassistant.components.light.decora_wifi
|
||||||
# decora_wifi==1.3
|
# decora_wifi==1.3
|
||||||
|
|
||||||
|
# homeassistant.components.ihc
|
||||||
|
# homeassistant.components.namecheapdns
|
||||||
# homeassistant.components.device_tracker.upc_connect
|
# homeassistant.components.device_tracker.upc_connect
|
||||||
|
# homeassistant.components.sensor.ohmconnect
|
||||||
defusedxml==0.5.0
|
defusedxml==0.5.0
|
||||||
|
|
||||||
# homeassistant.components.sensor.deluge
|
# homeassistant.components.sensor.deluge
|
||||||
|
@ -52,7 +52,10 @@ caldav==0.5.0
|
|||||||
# homeassistant.components.sensor.coinmarketcap
|
# homeassistant.components.sensor.coinmarketcap
|
||||||
coinmarketcap==5.0.3
|
coinmarketcap==5.0.3
|
||||||
|
|
||||||
|
# homeassistant.components.ihc
|
||||||
|
# homeassistant.components.namecheapdns
|
||||||
# homeassistant.components.device_tracker.upc_connect
|
# homeassistant.components.device_tracker.upc_connect
|
||||||
|
# homeassistant.components.sensor.ohmconnect
|
||||||
defusedxml==0.5.0
|
defusedxml==0.5.0
|
||||||
|
|
||||||
# homeassistant.components.sensor.dsmr
|
# homeassistant.components.sensor.dsmr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user