diff --git a/simulate-nis2-big.php b/simulate-nis2-big.php index 86125bf..2c91d37 100644 --- a/simulate-nis2-big.php +++ b/simulate-nis2-big.php @@ -391,13 +391,31 @@ function createSupplier(string $jwt, int $orgId, array $data): ?int function createAsset(string $jwt, int $orgId, array $data): ?int { + // Mappa type → asset_type (colonna DB) e normalizza ENUM + // ENUM DB: hardware, software, network, data, service, personnel, facility + $typeMap = [ + 'ot_system' => 'hardware', + 'server' => 'hardware', + 'datacenter' => 'facility', + 'network' => 'network', + 'software' => 'software', + 'hardware' => 'hardware', + 'data' => 'data', + 'service' => 'service', + 'facility' => 'facility', + 'personnel' => 'personnel', + ]; + $rawType = $data['type'] ?? $data['asset_type'] ?? 'hardware'; + $data['asset_type'] = $typeMap[$rawType] ?? 'hardware'; + unset($data['type']); + $res = api('POST', '/assets/create', $data, $jwt, $orgId); if (!empty($res['data']['id'])) { $id = (int) $res['data']['id']; ok("Asset creato [{$data['criticality']}]: {$data['name']} #{$id}"); return $id; } - warn("Asset fallito: {$data['name']} — " . ($res['error'] ?? '')); + warn("Asset fallito: {$data['name']} — " . ($res['error'] ?? $res['message'] ?? '')); return null; } @@ -1423,7 +1441,7 @@ if (!empty($S['orgs']['infratech']['id'])) { 'title' => 'DDoS volumetrico su piattaforma DNS primaria e secondaria', 'description' => 'Attacco DDoS 380 Gbps su infrastruttura DNS. Risoluzione nomi degradata per 4 ore. Peak traffic: 38M query/sec.', 'severity' => 'high', - 'classification' => 'availability', + 'classification' => 'system_failure', 'affected_services' => 'DNS primario, DNS secondario, risoluzione nomi', 'affected_users_count' => 850000, 'is_significant' => 1, @@ -1445,7 +1463,7 @@ if (!empty($S['orgs']['infratech']['id'])) { 'title' => 'Insider threat — dipendente NOC con accesso abusivo a dati clienti', 'description' => 'Accesso abusivo rilevato dopo 48h da dipendente reparto NOC. 12.400 record clienti enterprise consultati senza autorizzazione. Scoperto tramite UEBA alert.', 'severity' => 'medium', - 'classification' => 'unauthorized_access', + 'classification' => 'other', 'affected_services' => 'CRM enterprise, database clienti NOC', 'affected_users_count' => 12400, 'is_significant' => 1, @@ -1499,7 +1517,7 @@ if (!empty($S['orgs']['distribuzione']['id'])) { 'title' => 'Anomalia SCADA — accesso non autorizzato sottostazione', 'description' => 'Rilevata anomalia sui sistemi SCADA della sottostazione Moncalieri. Comandi inusuali inviati alle RTU. Sistema isolato preventivamente. Possibile compromissione.', 'severity' => 'critical', - 'classification' => 'availability', + 'classification' => 'cyber_attack', 'affected_services' => 'SCADA distribuzione, RTU sottostazione Moncalieri', 'is_significant' => 1, 'detected_at' => date('Y-m-d H:i:s', strtotime('-12 hours')), @@ -1524,7 +1542,7 @@ if (!empty($S['orgs']['bancaregionale']['id'])) { 'title' => 'Tentativo frode bonifici via BEC — 8 conti enterprise', 'description' => 'Business Email Compromise rilevata. 8 bonifici fraudolenti per 2.4M€ bloccati da sistema anti-frode real-time. Conti mittenti compromessi via phishing.', 'severity' => 'high', - 'classification' => 'fraud', + 'classification' => 'other', 'affected_services' => 'Internet banking, bonifici SEPA, monitoraggio transazioni', 'is_significant' => 1, 'detected_at' => date('Y-m-d H:i:s', strtotime('-6 hours')), @@ -1553,7 +1571,7 @@ $ncrOrgs = [ ], [ 'title' => 'Gestione patch firmware OT incompleta — Art.21.2.e NIS2', - 'severity' => 'high', + 'severity' => 'major', 'source' => 'audit', 'capa' => ['description'=>'Processo patch management OT: inventario, test lab, deploy in 60gg. Vendor agreement per aggiornamenti garantiti.', 'due_date'=>date('Y-m-d',strtotime('+60 days')), @@ -1563,7 +1581,7 @@ $ncrOrgs = [ 'medsalute' => [ [ 'title' => 'Log accessi cartelle cliniche incompleto — Art.21.2.j NIS2', - 'severity' => 'high', + 'severity' => 'major', 'source' => 'assessment', 'capa' => ['description'=>'Implementazione SIEM con correlazione log HIS/LIS. Audit trail completo su tutte le cartelle cliniche entro 45gg.', 'due_date'=>date('Y-m-d',strtotime('+45 days')),