From 55f81de986322d149b9c312ec8703cd3682c76f1 Mon Sep 17 00:00:00 2001 From: Admin MPCZ Date: Wed, 15 Apr 2026 12:25:27 +0200 Subject: [PATCH] Qualys sync: fallback matching par IP integrer si hostname ne match pas --- app/services/qualys_service.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/services/qualys_service.py b/app/services/qualys_service.py index 03eecd6..872b5a6 100644 --- a/app/services/qualys_service.py +++ b/app/services/qualys_service.py @@ -670,6 +670,14 @@ def _refresh_all_agents_impl(db): srv = db.execute(text("SELECT id FROM servers WHERE LOWER(hostname)=LOWER(:h)"), {"h": hostname}).fetchone() server_id = srv.id if srv else None + # Fallback : matching par IP si hostname ne match pas + if not server_id and address: + ip_match = db.execute(text( + "SELECT s.id FROM servers s JOIN server_ips si ON si.server_id=s.id " + "WHERE si.ip_address = CAST(:ip AS inet) LIMIT 1" + ), {"ip": address}).fetchone() + if ip_match: + server_id = ip_match.id if server_id and fqdn: db.execute(text("UPDATE servers SET fqdn=:fqdn WHERE id=:sid AND (fqdn IS NULL OR fqdn='')"), {"fqdn": fqdn, "sid": server_id})