diff --git a/full_updater/backend/scanner.py b/full_updater/backend/scanner.py
index 818a35c..f00185a 100644
--- a/full_updater/backend/scanner.py
+++ b/full_updater/backend/scanner.py
@@ -41,6 +41,29 @@ def _fetch_cve_html(cve_id: str) -> str:
return ""
+def _enrich_cve(cve_id: str) -> dict[str, str]:
+ """Récupère la sévérité et le vecteur d'attaque depuis le HTML Debian Security Tracker."""
+ html = _fetch_cve_html(cve_id)
+ if not html:
+ return {"severity": "?", "vector": "?"}
+
+ result = {"severity": "?", "vector": "?"}
+
+ # Extraction de la sévérité depuis le bloc "Vulnerable and fixed packages"
+ # Recherche du motif:
remote | ou local |
+ vector_match = re.search(r']*>\s*(remote|local)\s* | ', html, re.IGNORECASE)
+ if vector_match:
+ result["vector"] = vector_match.group(1).lower()
+
+ # Extraction de la sévérité depuis les notes ou le tableau
+ # Format courant: [low], [medium], [high], [critical] dans les notes
+ severity_match = re.search(r'\b(unimportant|low|medium|high|critical)\b', html, re.IGNORECASE)
+ if severity_match:
+ result["severity"] = severity_match.group(1).lower()
+
+ return result
+
+
def _is_cve_actionable(cve_id: str, suite: str = "bookworm") -> bool:
"""Retourne True si la CVE est marquée 'fixed' pour le suite donné dans le HTML."""
html = _fetch_cve_html(cve_id)
@@ -54,16 +77,20 @@ def _is_cve_actionable(cve_id: str, suite: str = "bookworm") -> bool:
return bool(pattern.search(html))
-def filter_actionable_cves(cves: list[dict]) -> tuple[list[dict], int]:
- """Filtre la liste des CVE pour ajouter un flag 'fixable'.
- Retourne (cve_avec_flag, nombre_actionnables)."""
+def enrich_cves(cves: list[dict]) -> tuple[list[dict], int]:
+ """Enrichit les CVEs avec fixable, severity, vector via l'API Debian.
+ Retourne (cve_enrichies, nombre_actionnables)."""
if not cves:
return [], 0
def check(cve: dict) -> dict:
try:
- is_fixable = _is_cve_actionable(cve["id"])
- cve["fixable"] = is_fixable
+ # Vérifie si corrigeable
+ cve["fixable"] = _is_cve_actionable(cve["id"])
+ # Enrichit avec severity et vector
+ enriched = _enrich_cve(cve["id"])
+ cve["severity"] = enriched["severity"]
+ cve["vector"] = enriched["vector"]
return cve
except Exception:
cve["fixable"] = False
@@ -148,40 +175,27 @@ def scan_os(target: Target) -> str:
line = line.strip()
if "=" in line:
key, val = line.split("=", 1)
- # Supprimer les guillemets
val = val.strip().strip('"').strip("'")
os_data[key] = val
# 2. Extraire les champs
- version_id = os_data.get("DEBIAN_VERSION_FULL", "")
- if not version_id:
- version_id = os_data.get("VERSION", "")
- if not version_id:
- version_id = os_data.get("VERSION_ID", "")
-
+ name = os_data.get("NAME", "")
codename = os_data.get("VERSION_CODENAME", "")
- pretty_name = os_data.get("PRETTY_NAME", "")
- os_name = os_data.get("NAME", "")
+ debian_version_full = os_data.get("DEBIAN_VERSION_FULL", "")
+ version_id = os_data.get("VERSION_ID", "")
- # 3. Fallback sur /etc/debian_version si tout vide
- if not version_id:
- ok, ver_out, _ = run_cmd(prefix + ["cat", "/etc/debian_version"], timeout=30)
- version_id = ver_out.strip() if ok else ""
+ # 3. Construire le libellé final
+ # Avec DEBIAN_VERSION_FULL : NAME DEBIAN_VERSION_FULL (VERSION_CODENAME)
+ # Sans : NAME VERSION_ID (VERSION_CODENAME)
+ version = debian_version_full if debian_version_full else version_id
- # 4. Fallback sur lsb_release pour le nom
- if not os_name:
- ok, name_out, _ = run_cmd(prefix + ["lsb_release", "-is"], timeout=30)
- os_name = name_out.strip() if ok else ""
+ if name and version and codename:
+ return f"{name} {version} ({codename})"
+ if name and version:
+ return f"{name} {version}"
- if not os_name and pretty_name:
- return pretty_name
- if not os_name or not version_id:
- return pretty_name if pretty_name else "OS inconnu"
-
- # Construire le libellé final
- if codename:
- return f"{os_name} GNU/Linux {version_id} ({codename})"
- return f"{os_name} GNU/Linux {version_id}"
+ # Fallback : PRETTY_NAME ou "OS inconnu"
+ return os_data.get("PRETTY_NAME", "OS inconnu")
def ensure_debsecan_installed(is_host: bool, vmid: str = "") -> tuple[bool, str]:
@@ -232,7 +246,8 @@ def scan_apt(target: Target) -> tuple[bool, list[dict[str, str]], str]:
def scan_cve(target: Target) -> tuple[bool, list[dict[str, str]], str]:
- cmd = ["debsecan", "--format", "report", "--suite", "bookworm"] if target.is_host else ["pct", "exec", target.target_id, "--", "debsecan", "--format", "report", "--suite", "bookworm"]
+ # Format par défaut (pas de --format) retourne: CVE-ID package
+ cmd = ["debsecan", "--suite", "bookworm"] if target.is_host else ["pct", "exec", target.target_id, "--", "debsecan", "--suite", "bookworm"]
ok, stdout, stderr = run_cmd(cmd, timeout=120)
if not ok:
return False, [], stderr or stdout
@@ -241,7 +256,13 @@ def scan_cve(target: Target) -> tuple[bool, list[dict[str, str]], str]:
for line in stdout.splitlines():
m = re.match(r"(CVE-\d{4}-\d+)\s+(\S+)", line)
if m:
- cves.append({"id": m.group(1), "package": m.group(2), "url": f"https://security-tracker.debian.org/tracker/{m.group(1)}"})
+ cves.append({
+ "id": m.group(1),
+ "package": m.group(2),
+ "vector": "?",
+ "severity": "?",
+ "url": f"https://security-tracker.debian.org/tracker/{m.group(1)}"
+ })
return True, cves, ""
@@ -270,9 +291,9 @@ def scan_target(target: Target, progress_cb: Callable) -> ScanResult:
if not cve_ok:
result.error = cve_err
- # Filtrer les CVE actionnables via l'API Debian
+ # Enrichir les CVE via l'API Debian (severity, vector, fixable)
if cve_list:
- all_cves, actionable_count = filter_actionable_cves(cve_list)
+ all_cves, actionable_count = enrich_cves(cve_list)
result.cve_list = all_cves
result.cve_count = actionable_count
result.cve_total = len(all_cves)
diff --git a/full_updater/ui/detail_screens.py b/full_updater/ui/detail_screens.py
index 78b31b4..5e95e10 100644
--- a/full_updater/ui/detail_screens.py
+++ b/full_updater/ui/detail_screens.py
@@ -90,15 +90,17 @@ class CVEListScreen(Screen):
with Horizontal(id="toolbar"):
yield Button("⬅ Retour", id="cve-back", variant="default")
table = DataTable(id="cve-table")
- table.add_columns("CVE-ID", "Paquet", "Corrigeable", "Lien")
+ table.add_columns("CVE-ID", "Paquet", "Severite", "Vecteur", "Corrigeable", "Lien")
table.cursor_type = "row"
for i, cve in enumerate(self.cves):
cve_id = cve.get("id", "?")
pkg = cve.get("package", "?")
url = cve.get("url", "")
+ severity = cve.get("severity", "?")
+ vector = cve.get("vector", "?")
fixable = "🟢 Oui" if cve.get("fixable") else "🔴 Non"
self.urls[i] = url
- table.add_row(cve_id, pkg, fixable, url)
+ table.add_row(cve_id, pkg, severity, vector, fixable, url)
yield table
def on_data_table_row_selected(self, event: DataTable.RowSelected):