feat: roadmap détection bots §2-9 — HTTP/2, cohérence, drift, flotte, Jaccard, ExIFFI, méta-learner, métriques
Étape 2 — Fingerprinting HTTP/2 dans le pipeline ML : - Ajout du dictionnaire dict_browser_h2 (11 familles de navigateurs) dans 05_aggregation_tables.sql - Ajout du CTE h2_agg et 4 features HTTP/2 dans 07_ai_features_view.sql : h2_settings_known, h2_pseudo_order_match, h2_ja4_coherence, h2_settings_rare - Calcul du fingerprint_coherence_score (5 axes pondérés) dans la vue - Ajout du 6e axe axis_h2_coherence dans browser.py (poids rééquilibrés) - browser_h2.csv : 11 fingerprints Akamai → famille navigateur Étape 3 — Pré-filtre de cohérence sur la baseline humaine : - pipeline.py exclut les sessions avec fingerprint_coherence_score < seuil de la baseline d'entraînement - FINGERPRINT_COHERENCE_THRESHOLD configurable via env (défaut 0.25) - Log des sessions exclues pour analyse SOC Étape 4 — Détection de drift améliorée : - scoring.py : passage de 5 à 9 quantiles (p5…p95) - Ajout de la divergence KL en complément du test KS - Détection de drift adversarial (≥80% des features dérivent dans la même direction) - Split temporel strict pour la validation Étape 5 — Graphe bipartite JA4×ASN (§5.2) : - fleet.py : détection de flottes via NetworkX + Louvain (imports optionnels) - enrich_with_fleet_score() : ajout fleet_score + fleet_campaign_flag au DataFrame - cycle.py : appel après preprocess_df avec log du nombre de sessions en flotte - SQL migration 05_fleet_metrics_tables.sql : table fleet_detections (TTL 7j) - Dashboard : /fleet + /api/fleet (communautés détectées) + template fleet.html Étape 6 — Cross-domain Jaccard §5.8 : - 12_thesis_features.sql : CTE jaccard_paths → cross_domain_path_similarity - Signal : même chemins (/admin, /wp-login) sur plusieurs hosts = scanner Étape 7 — ExIFFI + erreurs AE par feature : - scoring.py : compute_exiffi_importance() par permutation, compute_ae_feature_errors() - pipeline.py : calcul ExIFFI sur X_test, mapping index → dict pour anomalies - build_reason() enrichi avec exiffi_top quand SHAP inactif Étape 8 — Méta-learner pour la pondération de l'ensemble : - scoring.py : classe MetaLearner (LogisticRegression, fallback poids fixes <1000 labels) - Collecte des labels depuis le cycle courant (known_bots, légitimes, Anubis) - pipeline.py : remplacement des poids fixes par MetaLearner.predict() Étape 9 — Métriques de performance et monitoring : - metrics.py : record_cycle_metrics() — taux anomalie, drift, corrélation, latence - SQL migration 05_fleet_metrics_tables.sql : table ml_performance_metrics (TTL 90j) - Dashboard : /health + /api/health + template health.html - cycle.py : appel record_cycle_metrics en fin de cycle (Complet + Applicatif) Tests : 36/36 bot-detector tests passent Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@ -21,14 +21,16 @@ _BROWSER_JA4_PROFILES = {
|
||||
'ciphers': range(14, 18), 'exts': range(12, 17)},
|
||||
}
|
||||
|
||||
# Pondération des 5 axes pour le score browser_confidence.
|
||||
# Pondération des 6 axes pour le score browser_confidence.
|
||||
# Favorise les signaux TLS (difficiles à falsifier) sur HTTP.
|
||||
# L'axe H2 complète la cohérence TLS avec les paramètres HTTP/2.
|
||||
_AXIS_WEIGHTS = {
|
||||
'ja4_known': 0.30, # Axe 1 — Signature JA4 dans dict_browser_ja4 (TLS fingerprint)
|
||||
'ja4_known': 0.25, # Axe 1 — Signature JA4 dans dict_browser_ja4 (TLS fingerprint)
|
||||
'ja4_struct': 0.15, # Axe 2 — Structure JA4 (TLS1.3, h2, nb ciphers/ext)
|
||||
'http_modern': 0.20, # Axe 3 — Client Hints + Sec-Fetch-* (PAS de User-Agent)
|
||||
'nav_behavior': 0.15, # Axe 4 — Comportement de navigation (assets, referers)
|
||||
'tls_coherence': 0.20, # Axe 5 — Cohérence TLS/TCP (pas de mismatch)
|
||||
'tls_coherence': 0.15, # Axe 5 — Cohérence TLS/TCP (pas de mismatch)
|
||||
'h2_coherence': 0.10, # Axe 6 — Cohérence HTTP/2 (SETTINGS↔JA4, pseudo-headers) §2
|
||||
}
|
||||
|
||||
|
||||
@ -124,6 +126,21 @@ def _compute_browser_axes(df: pd.DataFrame) -> pd.DataFrame:
|
||||
+ (iam == 0).astype(float) * 0.20
|
||||
)
|
||||
|
||||
# ── Axe 6 — Cohérence HTTP/2 (§2) ──
|
||||
# Signaux : fingerprint SETTINGS connu, cohérence H2↔JA4, pseudo-headers corrects.
|
||||
# Quand les données H2 sont absentes (HTTP/1.x), l'axe est neutre (0.5).
|
||||
h2k = df.get('h2_settings_known', pd.Series(-1, index=df.index)).fillna(-1)
|
||||
h2c = df.get('h2_ja4_coherence', pd.Series(-1, index=df.index)).fillna(-1)
|
||||
h2p = df.get('h2_pseudo_order_match', pd.Series(-1, index=df.index)).fillna(-1)
|
||||
# Sessions sans données H2 → axe neutre à 0.5 (ne pénalise pas les sites HTTP/1.x)
|
||||
h2_present = ((h2k >= 0) | (h2c >= 0)).astype(float)
|
||||
h2_score = (
|
||||
h2k.clip(0).astype(float) * 0.40
|
||||
+ h2c.clip(0).astype(float) * 0.35
|
||||
+ h2p.clip(0).astype(float) * 0.25
|
||||
)
|
||||
axes['axis_h2_coherence'] = h2_present * h2_score + (1 - h2_present) * 0.5
|
||||
|
||||
# ── Score combiné pondéré ──
|
||||
axes['browser_confidence'] = sum(
|
||||
axes[f'axis_{k}'] * w for k, w in _AXIS_WEIGHTS.items()
|
||||
|
||||
Reference in New Issue
Block a user