From 71dddf08545371728a394e7b6473c80fa19b0274 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sun, 21 Jan 2024 13:25:11 -0500 Subject: [PATCH] fix: add node name regex to validation script Signed-off-by: Devin Buhl --- bootstrap/scripts/validation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bootstrap/scripts/validation.py b/bootstrap/scripts/validation.py index e7a7018e..54e65d2b 100644 --- a/bootstrap/scripts/validation.py +++ b/bootstrap/scripts/validation.py @@ -54,6 +54,8 @@ def _validate_node(node: dict, node_cidr: str, distribution: str) -> None: raise ValueError(f"Node {node.get('username')} is missing a username") if not node.get("diskSerial") and distribution in ["talos"]: raise ValueError(f"Node {node.get('diskSerial')} is missing a disk serial") + if not re.match(r"^[a-z0-9-\.]+$", node.get('name')): + raise ValueError(f"Invalid node name {node.get('name')}") ip = _validate_ip(node.get("address")) if netaddr.IPAddress(ip, 4) not in netaddr.IPNetwork(node_cidr): raise ValueError(f"Node {node.get('address')} is not in the node CIDR {node_cidr}")