🛡️ Dashboard complet pour l'analyse et la classification des menaces Fonctionnalités principales: - Visualisation des détections en temps réel (24h) - Investigation multi-entités (IP, JA4, ASN, Host, User-Agent) - Analyse de corrélation pour classification SOC - Clustering automatique par subnet/JA4/UA - Export des classifications pour ML Composants: - Backend: FastAPI (Python) + ClickHouse - Frontend: React + TypeScript + TailwindCSS - 6 routes API: metrics, detections, variability, attributes, analysis, entities - 7 types d'entités investigables Documentation ajoutée: - NAVIGATION_GRAPH.md: Graph complet de navigation - SOC_OPTIMIZATION_PROPOSAL.md: Proposition d'optimisation pour SOC • Réduction de 7 à 2 clics pour classification • Nouvelle vue /incidents clusterisée • Panel latéral d'investigation • Quick Search (Cmd+K) • Timeline interactive • Graph de corrélations Sécurité: - .gitignore configuré (exclut .env, secrets, node_modules) - Credentials dans .env (à ne pas committer) ⚠️ Audit sécurité réalisé - Voir recommandations dans SOC_OPTIMIZATION_PROPOSAL.md Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
245 lines
8.0 KiB
Markdown
245 lines
8.0 KiB
Markdown
# 🧪 Rapport de Tests - Bot Detector Dashboard
|
|
|
|
**Date:** 2026-03-14 19:57 UTC
|
|
**Version:** 1.0
|
|
**Testeur:** MCP Playwright + Shell
|
|
|
|
---
|
|
|
|
## 📊 Résumé Exécutif
|
|
|
|
| Catégorie | Tests Passés | Tests Échoués | Total | Taux de Réussite |
|
|
|-----------|--------------|---------------|-------|------------------|
|
|
| **Backend API** | 9 | 1 | 10 | 90% |
|
|
| **Frontend (Playwright)** | 5 | 0 | 5 | 100% |
|
|
| **ClickHouse** | 0 | 0 | 0 | N/A ⚠️ |
|
|
| **TOTAL** | **14** | **1** | **15** | **93%** |
|
|
|
|
---
|
|
|
|
## 1. Tests Backend API (9/10 ✅)
|
|
|
|
### ✅ Tests Réussis
|
|
|
|
| ID | Test | Résultat | Détails |
|
|
|----|------|----------|---------|
|
|
| H1 | Health check | ✅ PASS | `{"status": "healthy", "clickhouse": "connected"}` |
|
|
| M1 | Métriques globales | ✅ PASS | 23,879 détections, 4 niveaux de menace |
|
|
| M2 | Série temporelle 24h | ✅ PASS | 24 points horaires retournés |
|
|
| D1 | Liste détections | ✅ PASS | 23,879 détections, pagination fonctionnelle |
|
|
| D3 | Tri par score | ✅ PASS | Score: -0.147 (croissant) |
|
|
| VI1 | IPs associées (Country CN) | ✅ PASS | 1,530 IPs |
|
|
| VU1 | User-Agents par IP | ✅ PASS | 1 user-agent |
|
|
| AS1 | Analysis subnet | ✅ PASS | 57 IPs dans le subnet |
|
|
| AC1 | Analysis country | ✅ PASS | CN (China) |
|
|
| ET1 | Classifications | ✅ PASS | 2 classifications |
|
|
| F1 | Frontend accessible | ✅ PASS | Dashboard HTML servi |
|
|
|
|
### ❌ Tests Échoués
|
|
|
|
| ID | Test | Erreur | Cause Racine |
|
|
|----|------|--------|--------------|
|
|
| V1 | Variability IP | ❌ FAIL | **Bug Pydantic v2** - Erreur de sérialisation des `AttributeValue` dans les champs `ja4`, `countries`, `asns`, `hosts`, `threat_levels`, `model_names` |
|
|
|
|
**Détail de l'erreur:**
|
|
```
|
|
6 validation errors for VariabilityAttributes
|
|
ja4.0: Input should be a valid dictionary or instance of AttributeValue
|
|
countries.0: Input should be a valid dictionary or instance of AttributeValue
|
|
asns.0: Input should be a valid dictionary or instance of AttributeValue
|
|
hosts.0: Input should be a valid dictionary or instance of AttributeValue
|
|
threat_levels.0: Input should be a valid dictionary or instance of AttributeValue
|
|
model_names.0: Input should be a valid dictionary or instance of AttributeValue
|
|
```
|
|
|
|
**Recommandation:** Corriger le modèle Pydantic `VariabilityResponse` dans `backend/api/variability.py` pour utiliser la bonne sérialisation des objets `AttributeValue`.
|
|
|
|
---
|
|
|
|
## 2. Tests Frontend (5/5 ✅)
|
|
|
|
### Navigation et Routing
|
|
|
|
| ID | Test | Résultat | Détails |
|
|
|----|------|----------|---------|
|
|
| N1 | Page d'accueil | ✅ PASS | Dashboard affiché avec 4 cartes de métriques |
|
|
| N2 | Navigation Détections | ✅ PASS | Tableau avec 15 lignes, pagination (956 pages) |
|
|
| N5 | URL directe | ✅ PASS | http://192.168.1.2:3000/detections fonctionnel |
|
|
|
|
### Dashboard Principal
|
|
|
|
| ID | Test | Résultat | Détails |
|
|
|----|------|----------|---------|
|
|
| DH1 | Métriques affichées | ✅ PASS | Total: 23,879, Bots: 7,001, IPs: 17,607 |
|
|
| DH2 | Graphique temporel | ✅ PASS | Évolution 24h avec 24 points |
|
|
| DH3 | Distribution par menace | ✅ PASS | CRITICAL: 0, HIGH: 0, MEDIUM: 5,221, LOW: 11,657 |
|
|
|
|
### Liste des Détections
|
|
|
|
| ID | Test | Résultat | Détails |
|
|
|----|------|----------|---------|
|
|
| DL1 | Tableau affiché | ✅ PASS | 9 colonnes (IP/JA4, Host, Modèle, Score, Hits, Velocity, ASN, Pays, Date) |
|
|
| DL2 | Pagination | ✅ PASS | Page 1/956, boutons Précédent/Suivant |
|
|
| DL3 | Tri colonnes | ✅ PASS | Headers cliquables avec indicateurs ⇅ |
|
|
|
|
---
|
|
|
|
## 3. Tests ClickHouse (N/A ⚠️)
|
|
|
|
| ID | Test | Statut | Commentaire |
|
|
|----|------|--------|-------------|
|
|
| DB1-DB7 | Tables et vues | ⚠️ N/A | ClickHouse local non démarré (service distant: test-sdv-anubis.sdv.fr) |
|
|
| DQ1-DQ5 | Qualité données | ⚠️ N/A | Nécessite accès direct au serveur distant |
|
|
| DP1-DP5 | Performance | ⚠️ N/A | Nécessite accès direct au serveur distant |
|
|
|
|
**Recommandation:** Exécuter les tests SQL manuellement via:
|
|
```bash
|
|
docker compose exec clickhouse clickhouse-client -d mabase_prod < test_dashboard_entities.sql
|
|
```
|
|
|
|
---
|
|
|
|
## 4. Performance API
|
|
|
|
| Endpoint | Temps de Réponse | Statut |
|
|
|----------|------------------|--------|
|
|
| GET /health | < 100ms | ✅ Excellent |
|
|
| GET /api/metrics | < 500ms | ✅ Bon |
|
|
| GET /api/detections?page=1 | < 1s | ✅ Bon |
|
|
| GET /api/analysis/subnet | < 500ms | ✅ Bon |
|
|
|
|
---
|
|
|
|
## 5. Bugs Identifiés
|
|
|
|
### 🔴 Bug Critique: Sérialisation Pydantic
|
|
|
|
**Fichier:** `backend/api/variability.py`
|
|
**Endpoint:** `/api/variability/ip/{ip}`
|
|
**Impact:** Investigation IP indisponible (erreur 500)
|
|
|
|
**Solution recommandée:**
|
|
```python
|
|
# Dans VariabilityAttributes, utiliser dict au lieu de AttributeValue
|
|
# Ou implémenter un custom serializer
|
|
from pydantic import field_serializer
|
|
|
|
class VariabilityAttributes(BaseModel):
|
|
ja4: List[Dict]
|
|
countries: List[Dict]
|
|
# ...
|
|
|
|
@field_serializer('ja4', 'countries', 'asns', 'hosts', 'threat_levels', 'model_names')
|
|
def serialize_attributes(self, value):
|
|
return [v.model_dump() if hasattr(v, 'model_dump') else v for v in value]
|
|
```
|
|
|
|
---
|
|
|
|
## 6. Couverture des Tests (vs TEST_PLAN.md)
|
|
|
|
### Endpoints API Testés
|
|
|
|
| Routeur | Endpoints dans le Plan | Tests Exécutés | Couverture |
|
|
|---------|------------------------|----------------|------------|
|
|
| `/health` | H1-H3 | H1 | 33% |
|
|
| `/api/metrics` | M1-M5, MT1-MT2 | M1, M2 | 25% |
|
|
| `/api/detections` | D1-D11, DD1-DD3 | D1, D3 | 14% |
|
|
| `/api/variability` | V1-V8, VI1-VI3, VA1-VA3, VU1-VU2 | V1❌, VI1, VU1 | 25% |
|
|
| `/api/analysis` | AS1-AS4, AC1-AC2 | AS1, AC1 | 33% |
|
|
| `/api/entities` | E1-E10, ER1, EU1-EU4, ET1 | ET1 | 7% |
|
|
|
|
**Couverture API actuelle:** ~23% (3/13 endpoints principaux testés)
|
|
|
|
### Frontend Testés
|
|
|
|
| Fonctionnalité | Tests dans le Plan | Tests Exécutés | Couverture |
|
|
|----------------|-------------------|----------------|------------|
|
|
| Navigation | N1-N5 | N1, N2, N5 | 60% |
|
|
| Dashboard | DH1-DH7 | DH1, DH2, DH3 | 43% |
|
|
| Détections | DL1-DL8 | DL1, DL2, DL3 | 38% |
|
|
| Investigation | DV1-DV8 | 0 (bug backend) | 0% |
|
|
|
|
**Couverture Frontend actuelle:** ~35%
|
|
|
|
---
|
|
|
|
## 7. Recommandations
|
|
|
|
### Priorité 1 (Critique) 🔴
|
|
|
|
1. **Corriger le bug Pydantic** dans `backend/api/variability.py`
|
|
- Impact: Investigation IP/JA4/Country/ASN indisponible
|
|
- Effort estimé: 1-2 heures
|
|
|
|
2. **Ajouter des tests unitaires backend** avec pytest
|
|
- Structure: `backend/tests/test_variability.py`
|
|
- Couvrir les modèles Pydantic
|
|
|
|
### Priorité 2 (Important) 🟡
|
|
|
|
3. **Exécuter les tests ClickHouse** sur le serveur distant
|
|
- Commande: `docker compose exec clickhouse clickhouse-client -h test-sdv-anubis.sdv.fr -d mabase_prod < test_dashboard_entities.sql`
|
|
|
|
4. **Ajouter des tests E2E Playwright**
|
|
- Scénarios: Navigation, Filtres, Recherche
|
|
- Fichier: `tests/e2e/dashboard.spec.ts`
|
|
|
|
### Priorité 3 (Secondaire) 🟢
|
|
|
|
5. **Améliorer la couverture des tests API**
|
|
- Endpoints manquants: `/api/entities/*`, `/api/analysis/{ip}/recommendation`
|
|
- Tests de filtres: threat_level, model_name, country_code, search
|
|
|
|
6. **Tests de performance**
|
|
- Load testing avec locust
|
|
- Objectif: < 2s pour tous les endpoints
|
|
|
|
---
|
|
|
|
## 8. Commandes Utiles
|
|
|
|
```bash
|
|
# Exécuter les tests API
|
|
./test_dashboard.sh
|
|
|
|
# Vérifier la santé du dashboard
|
|
curl http://localhost:3000/health | jq
|
|
|
|
# Tester un endpoint spécifique
|
|
curl "http://localhost:3000/api/detections?page=1&page_size=25" | jq
|
|
|
|
# Logs en temps réel
|
|
docker compose logs -f dashboard_web
|
|
|
|
# Redémarrer le dashboard
|
|
docker compose restart dashboard_web
|
|
```
|
|
|
|
---
|
|
|
|
## 9. Conclusion
|
|
|
|
**État général:** ✅ **Bon** (93% de tests passés)
|
|
|
|
**Points forts:**
|
|
- Dashboard fonctionnel avec données en temps réel
|
|
- API performante (< 1s pour la plupart des endpoints)
|
|
- Frontend React responsive et navigable
|
|
- 23,879 détections analysées sur 24h
|
|
|
|
**Points d'amélioration:**
|
|
- Bug critique sur l'investigation (variability endpoint)
|
|
- Couverture de tests insuffisante (~30%)
|
|
- Tests ClickHouse non automatisés
|
|
|
|
**Prochaines étapes:**
|
|
1. Corriger le bug Pydantic (Priorité 1)
|
|
2. Ajouter des tests unitaires backend
|
|
3. Automatiser les tests E2E avec Playwright
|
|
|
|
---
|
|
|
|
**Rapport généré par:** MCP Playwright + Shell
|
|
**Date:** 2026-03-14 19:57 UTC
|