feat(bot-detector): add dynamic browser profiling engine with HDBSCAN clustering
Implement offline profile building (profile_builder.py) and real-time dynamic scoring (browser_matcher_dynamic.py) using HDBSCAN-based browser fingerprint clustering. Add ClickHouse materialized view (13_h2_profiling.sql) for h2_profile_stats aggregation. Update thesis and project documentation to cover the new dynamic profiling architecture. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -12,7 +12,7 @@ la surveillance de performance par cycle.
|
||||
|
||||
## Architecture des modules
|
||||
|
||||
Le service est découpé en **12 modules** organisés ainsi :
|
||||
Le service est découpé en **16 modules** organisés ainsi :
|
||||
|
||||
```
|
||||
__main__.py Point d'entrée (python -m bot_detector)
|
||||
@ -25,6 +25,10 @@ __main__.py Point d'entrée (python -m bot_detector)
|
||||
├─ pipeline.py Orchestration : filtrage → entraînement → MetaLearner → ExIFFI → scoring → fusion
|
||||
│ ├─ models.py EIF, TrafficAutoEncoder (PyTorch), XGBoost
|
||||
│ └─ scoring.py Normalisation, MetaLearner, seuil adaptatif, ExIFFI, SHAP, HDBSCAN, dérive KS+KL
|
||||
├─ browser_matcher.py Scoring H2 statique à 7 dimensions pondérées
|
||||
│ └─ browser_signatures.py Signatures statiques Chrome/Firefox/Safari + rechargement ClickHouse
|
||||
├─ browser_matcher_dynamic.py Scoring H2 dynamique temps réel (profils auto-appris)
|
||||
├─ profile_builder.py Profiling HDBSCAN hors-ligne, centroïdes, lifecycle (cron quotidien)
|
||||
├─ fleet.py Graphe bipartite JA4×ASN (NetworkX), fleet_score, fleet_detections
|
||||
├─ metrics.py Métriques de cycle, alertes, ml_performance_metrics
|
||||
└─ (insère dans ml_all_scores + ml_detected_anomalies + fleet_detections + ml_performance_metrics)
|
||||
@ -36,6 +40,10 @@ __main__.py Point d'entrée (python -m bot_detector)
|
||||
| `log.py` | 65 | `log_info()`, `log_decision()`, `append_training_history()` — JSONL rotatif |
|
||||
| `infra.py` | 89 | Client ClickHouse (délègue à `ja4_common`), `score_to_threat_level()`, serveur de santé en thread daemon |
|
||||
| `browser.py` | 191 | Détection multifactorielle des navigateurs sur **6 axes** pondérés (ajout `axis_h2_coherence`) |
|
||||
| `browser_matcher.py` | 498 | Scoring H2 statique à 7 dimensions pondérées (SETTINGS, WINDOW_UPDATE, pseudo-order, etc.) |
|
||||
| `browser_signatures.py` | 166 | Signatures statiques Chrome/Firefox/Safari + rechargement dynamique depuis ClickHouse |
|
||||
| `browser_matcher_dynamic.py` | 387 | Scoring H2 dynamique temps réel contre profils auto-appris (`auto_browser_profiles`) |
|
||||
| `profile_builder.py` | 614 | Profiling HDBSCAN hors-ligne : clustering, centroïdes, fusion, lifecycle (cron quotidien) |
|
||||
| `scoring.py` | 564 | `MetaLearner` (régression logistique), normalisation, seuil adaptatif, ExIFFI, SHAP top-5, HDBSCAN, dérive KS+KL |
|
||||
| `models.py` | 484 | `TrafficAutoEncoder`, entraînement/chargement EIF, XGBoost, élagage de features |
|
||||
| `preprocessing.py` | 127 | `preprocess_df()` — nettoyage, typage, imputation, listes `FEATURES` / `FEATURES_COMPLET` |
|
||||
@ -512,13 +520,14 @@ Chaque anomalie reçoit un `campaign_id` (−1 = pas de cluster).
|
||||
o. Détection de dérive (KS test + KL divergence)
|
||||
p. Alerte drift adversarial (dérive simultanée multiple features → direction commune)
|
||||
8. Analyse de flotte (fleet.py) : graphe bipartite JA4×ASN → communautés Louvain → fleet_score
|
||||
9. Mode multi-fenêtre (si activé) : idem sur view_ai_features_24h
|
||||
10. Insertion → ml_all_scores (toutes les sessions scorées)
|
||||
11. Déduplication intra-cycle (garder raw_anomaly_score le plus bas par IP)
|
||||
12. Déduplication inter-cycle (TTL, skip si détecté récemment sauf aggravation ≥ 0.05)
|
||||
13. Insertion → ml_detected_anomalies (anomalies filtrées)
|
||||
14. Insertion → fleet_detections (flottes détectées avec fleet_score)
|
||||
15. Enregistrement → ml_performance_metrics (métriques de cycle + alertes)
|
||||
9. Scoring dynamique H2 (browser_matcher_dynamic.py) : profils auto-appris vs sessions entrantes
|
||||
10. Mode multi-fenêtre (si activé) : idem sur view_ai_features_24h
|
||||
11. Insertion → ml_all_scores (toutes les sessions scorées)
|
||||
12. Déduplication intra-cycle (garder raw_anomaly_score le plus bas par IP)
|
||||
13. Déduplication inter-cycle (TTL, skip si détecté récemment sauf aggravation ≥ 0.05)
|
||||
14. Insertion → ml_detected_anomalies (anomalies filtrées)
|
||||
15. Insertion → fleet_detections (flottes détectées avec fleet_score)
|
||||
16. Enregistrement → ml_performance_metrics (métriques de cycle + alertes)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user