From 022340edae96594bb068153a9dfa0d5f851b015c Mon Sep 17 00:00:00 2001 From: scott Date: Thu, 16 Apr 2026 14:23:11 -0400 Subject: [PATCH] Sanitize Redfish string fields to strip non-ASCII/non-printable characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IOM1's HostName field contains binary artifacts that decode to garbage unicode characters (e.g. 𳇀 prefixing a UUID). Strip any character outside printable ASCII (0x20–0x7F) from all string fields returned by _parse_network_data. Co-Authored-By: Claude Sonnet 4.6 --- modules/workflow_check.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/workflow_check.py b/modules/workflow_check.py index 31c21ce..2db008a 100644 --- a/modules/workflow_check.py +++ b/modules/workflow_check.py @@ -27,6 +27,12 @@ from ui import ( # ── Shared helpers ───────────────────────────────────────────────────────────── +def _sanitize(value: str) -> str: + """Strip non-printable and non-ASCII characters from a string field. + IOM Redfish responses occasionally contain binary artifacts in text fields.""" + return "".join(c for c in value if 32 <= ord(c) < 128) + + def _parse_network_data(data: dict) -> tuple: """ Extract network details from a Redfish EthernetInterfaces/1 response dict. @@ -41,15 +47,15 @@ def _parse_network_data(data: dict) -> tuple: addrs = data.get("IPv4StaticAddresses") or data.get("IPv4Addresses", []) if addrs: addr = addrs[0] - ip = addr.get("Address", "--") - gateway = addr.get("Gateway", "--") - netmask = addr.get("SubnetMask", "--") + ip = _sanitize(addr.get("Address", "--")) + gateway = _sanitize(addr.get("Gateway", "--")) + netmask = _sanitize(addr.get("SubnetMask", "--")) else: ip = gateway = netmask = "--" - mac = data.get("MACAddress", "--") - hostname = data.get("HostName", "--") - link_status = data.get("LinkStatus", "--") + mac = _sanitize(data.get("MACAddress", "--")) + hostname = _sanitize(data.get("HostName", "--")) + link_status = _sanitize(data.get("LinkStatus", "--")) return dhcp_enabled, ip, gateway, netmask, mac, hostname, link_status