1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 22:18:40 +00:00

Improve DHCP + Zeroconf manifest validation (#49321)

This commit is contained in:
Paulus Schoutsen
2021-04-16 16:32:12 -07:00
committed by GitHub
parent f464663732
commit 984962d985
3 changed files with 19 additions and 8 deletions

View File

@@ -148,6 +148,13 @@ def verify_version(value: str):
return value
def verify_wildcard(value: str):
"""Verify the matcher contains a wildcard."""
if "*" not in value:
raise vol.Invalid(f"'{value}' needs to contain a wildcard matcher")
return value
MANIFEST_SCHEMA = vol.Schema(
{
vol.Required("domain"): str,
@@ -160,7 +167,9 @@ MANIFEST_SCHEMA = vol.Schema(
vol.Schema(
{
vol.Required("type"): str,
vol.Optional("macaddress"): vol.All(str, verify_uppercase),
vol.Optional("macaddress"): vol.All(
str, verify_uppercase, verify_wildcard
),
vol.Optional("manufacturer"): vol.All(str, verify_lowercase),
vol.Optional("name"): vol.All(str, verify_lowercase),
}
@@ -174,7 +183,9 @@ MANIFEST_SCHEMA = vol.Schema(
vol.Optional("dhcp"): [
vol.Schema(
{
vol.Optional("macaddress"): vol.All(str, verify_uppercase),
vol.Optional("macaddress"): vol.All(
str, verify_uppercase, verify_wildcard
),
vol.Optional("hostname"): vol.All(str, verify_lowercase),
}
)