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:
@ -0,0 +1,55 @@
|
||||
-- === 05_fleet_metrics_tables.sql — Tables fleet_detections et ml_performance_metrics ===
|
||||
--
|
||||
-- fleet_detections : résultats du détecteur de flottes §5.2 (JA4×ASN bipartite graph)
|
||||
-- ml_performance_metrics : métriques de performance du pipeline ML par cycle
|
||||
--
|
||||
-- Appliquer avec :
|
||||
-- clickhouse-client --multiquery < 05_fleet_metrics_tables.sql
|
||||
|
||||
-- --- fleet_detections ---
|
||||
CREATE TABLE IF NOT EXISTS ja4_processing.fleet_detections
|
||||
(
|
||||
detected_at DateTime,
|
||||
community_id UInt32,
|
||||
ja4_set Array(String),
|
||||
asn_set Array(String),
|
||||
fleet_score Float32,
|
||||
n_ips UInt32,
|
||||
ip_sample Array(String), -- échantillon des 20 premières IPs
|
||||
model_name LowCardinality(String) DEFAULT ''
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toDate(detected_at)
|
||||
ORDER BY (detected_at, community_id)
|
||||
TTL detected_at + INTERVAL 7 DAY
|
||||
SETTINGS ttl_only_drop_parts = 1;
|
||||
|
||||
-- --- ml_performance_metrics ---
|
||||
CREATE TABLE IF NOT EXISTS ja4_processing.ml_performance_metrics
|
||||
(
|
||||
cycle_at DateTime,
|
||||
model_name LowCardinality(String),
|
||||
total_sessions UInt64,
|
||||
correlated_rate Float32,
|
||||
anomaly_rate Float32,
|
||||
critical_count UInt32,
|
||||
high_count UInt32,
|
||||
medium_count UInt32,
|
||||
low_count UInt32,
|
||||
known_bot_count UInt32,
|
||||
anubis_deny_count UInt32,
|
||||
legit_browser_count UInt32,
|
||||
drift_rate Float32,
|
||||
drift_alert UInt8,
|
||||
cycle_latency_ms UInt32,
|
||||
features_valid UInt16,
|
||||
features_total UInt16,
|
||||
baseline_size UInt32,
|
||||
threshold Float32,
|
||||
meta_learner_active UInt8 DEFAULT 0
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PARTITION BY toDate(cycle_at)
|
||||
ORDER BY (cycle_at, model_name)
|
||||
TTL cycle_at + INTERVAL 90 DAY
|
||||
SETTINGS ttl_only_drop_parts = 1;
|
||||
Reference in New Issue
Block a user