Qualys hostname: retour a priorite name (sauf IP/localhost/vide), fqdn/netbios en fallback

This commit is contained in:
Pierre & Lumière 2026-04-15 01:38:56 +02:00
parent c7291d3e6d
commit 105a756008

View File

@ -627,8 +627,18 @@ def _refresh_all_agents_impl(db):
fqdn = (parse_xml(block, "fqdn") or [""])[0] fqdn = (parse_xml(block, "fqdn") or [""])[0]
netbios = (parse_xml(block, "netbiosName") or [""])[0] netbios = (parse_xml(block, "netbiosName") or [""])[0]
os_val = (parse_xml(block, "os") or [""])[0] os_val = (parse_xml(block, "os") or [""])[0]
# Priorite FQDN > NetBIOS > name (display Qualys peut etre tronque) # Priorite name (Qualys display) sauf si c'est une IP ou vide -> FQDN -> NetBIOS
hostname_src = fqdn or netbios or name import re as _re
def _valid(h):
if not h:
return False
h = h.strip().lower()
if h in ("localhost", ""):
return False
if _re.match(r"^\d+\.\d+\.\d+\.\d+$", h):
return False
return True
hostname_src = name if _valid(name.split(".")[0]) else (fqdn if _valid(fqdn.split(".")[0]) else netbios)
hostname = hostname_src.split(".")[0].lower() if hostname_src else "" hostname = hostname_src.split(".")[0].lower() if hostname_src else ""
agent_status = "" agent_status = ""