From 0dc0fc764316e1fc51a236e76494dd6680c8e98e Mon Sep 17 00:00:00 2001 From: Khalid MOUTAOUAKIL Date: Mon, 6 Apr 2026 22:51:50 +0200 Subject: [PATCH] =?UTF-8?q?Vulns:=20parser=20results=20en=20tableau=20Pack?= =?UTF-8?q?age/Version=20install=C3=A9e/Version=20requise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- app/routers/qualys.py | 44 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/app/routers/qualys.py b/app/routers/qualys.py index 55b50f4..7d3d593 100644 --- a/app/routers/qualys.py +++ b/app/routers/qualys.py @@ -535,15 +535,47 @@ async def qualys_vulns_detail(request: Request, ip: str, db=Depends(get_db)): html += '' # Ligne detail - diag = k.get("diagnosis", "")[:300] - results = d.get("results", "")[:200] html += f'' + + # Parser le results pour en faire un tableau packages + results = d.get("results", "") + if results and ("Installed Version" in results or "Required Version" in results): + # Format: "Package Installed Version Required Version\npkg1 ver1 ver2\npkg2..." + lines = [l.strip() for l in results.replace("\t", " ").split("\n") if l.strip()] + # Retirer la ligne header + pkg_lines = [l for l in lines if not l.startswith("Package") and not l.startswith("Installed")] + if pkg_lines: + html += '' + html += '' + html += '' + html += '' + for line in pkg_lines: + parts = line.split() + if len(parts) >= 3: + pkg = parts[0] + installed = parts[1] + required = " ".join(parts[2:]) + html += f'' + html += f'' + html += f'' + elif len(parts) >= 1: + html += f'' + html += '
PackageVersion installéeVersion requise
{pkg}{installed}{required}
{line}
' + else: + html += f'Résultat : {results[:300]}
' + elif results: + html += f'Résultat : {results[:300]}
' + + # Diagnosis (nettoyé des tags HTML) + diag = k.get("diagnosis", "") if diag: - html += f'Detection : {diag}
' - if results: - html += f'Resultat : {results}
' + diag_clean = _re.sub(r'<[^>]+>', ' ', diag).strip()[:300] + html += f'Détection : {diag_clean}
' + if k.get("solution"): - html += f'Solution : {k["solution"][:200]}' + sol_clean = _re.sub(r'<[^>]+>', ' ', k["solution"]).strip()[:200] + html += f'Solution : {sol_clean}' + html += '' html += ''