import { useState, useEffect, useMemo } from 'react'; import { useNavigate } from 'react-router-dom'; import DataTable, { Column } from './ui/DataTable'; // ─── Types ──────────────────────────────────────────────────────────────────── interface TcpSpoofingOverview { total_entries: number; unique_ips: number; no_tcp_data: number; with_tcp_data: number; linux_fingerprint: number; windows_fingerprint: number; ttl_distribution: { ttl: number; count: number; ips: number }[]; window_size_distribution: { window_size: number; count: number }[]; } interface TcpSpoofingItem { ip: string; ja4: string; tcp_ttl: number; tcp_window_size: number; first_ua: string; suspected_os: string; declared_os: string; spoof_flag: boolean; } interface OsMatrixEntry { suspected_os: string; declared_os: string; count: number; is_spoof: boolean; } type ActiveTab = 'detections' | 'matrix'; // ─── Helpers ────────────────────────────────────────────────────────────────── function formatNumber(n: number): string { return n.toLocaleString('fr-FR'); } function ttlColor(ttl: number): string { if (ttl === 0) return 'text-threat-critical'; if (ttl < 48 || ttl > 200) return 'text-threat-critical'; if (ttl < 60 || (ttl > 70 && ttl <= 80)) return 'text-threat-medium'; if (ttl >= 60 && ttl <= 70) return 'text-threat-low'; return 'text-text-secondary'; } // ─── Sub-components ─────────────────────────────────────────────────────────── function StatCard({ label, value, accent }: { label: string; value: string | number; accent?: string }) { return (
Détection des incohérences entre TTL/fenêtre TCP et l'OS déclaré.
Aucune donnée disponible.
) : (| Suspecté \ Déclaré | {declaredOSes.map((os) => ({os} | ))}Total |
|---|---|---|
| {sos} | {rowEntries.map((count, ci) => { const dos = declaredOSes[ci]; const entry = matrix.find((e) => e.suspected_os === sos && e.declared_os === dos); const isSpoofCell = entry?.is_spoof ?? false; return (0 ? 'bg-threat-critical/25 text-threat-critical font-bold' : matrixCellColor(count) + (count > 0 ? ' text-text-primary' : ' text-text-disabled') }`} title={isSpoofCell ? '🚨 OS mismatch confirmé' : undefined} > {count > 0 ? (isSpoofCell ? `🚨 ${formatNumber(count)}` : formatNumber(count)) : '—'} | ); })}{formatNumber(rowTotal)} |
| Total | {declaredOSes.map((dos) => { const colTotal = matrix .filter((e) => e.declared_os === dos) .reduce((s, e) => s + e.count, 0); return ({formatNumber(colTotal)} | ); })}{formatNumber(matrix.reduce((s, e) => s + e.count, 0))} |