[FEAT] Simulazioni Demo + Audit Trail Certificato SHA-256
- 5 scenari reali: Onboarding, Ransomware Art.23, Data Breach Supply Chain, Whistleblowing SCADA, Audit Hash Chain Verification - simulate-nis2.php: 3 aziende (DataCore/MedClinic/EnerNet), 10 fasi, CLI+SSE - AuditService.php: hash chain SHA-256 stile lg231 (prev_hash+entry_hash) - Migration 010: prev_hash, entry_hash, severity, performed_by su audit_logs - AuditController: GET chain-verify + GET export-certified - reset-demo.sql: reset dati demo idempotente - public/simulate.html: web runner SSE con console dark-theme - Sidebar: link Simulazione Demo + Integrazioni Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b23bbc55fd
commit
874eabb6fc
@@ -0,0 +1,106 @@
|
||||
-- ============================================================
|
||||
-- NIS2 Agile — Reset Dati Demo
|
||||
-- Cancella tutti i dati generati dalla simulazione, mantenendo
|
||||
-- solo le organizzazioni seed (id <= 4) e i loro utenti.
|
||||
--
|
||||
-- Eseguire su Hetzner:
|
||||
-- ssh -i docs/credentials/hetzner_key root@135.181.149.254
|
||||
-- mysql -u nis2_agile_user -p nis2_agile_db < /var/www/nis2-agile/docs/sql/reset-demo.sql
|
||||
-- ============================================================
|
||||
|
||||
USE nis2_agile_db;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ── Dati operativi generati dalla simulazione ─────────────────────────────
|
||||
|
||||
-- Notifiche incidenti / timeline
|
||||
DELETE FROM incident_timeline WHERE organization_id > 4;
|
||||
DELETE FROM incidents WHERE organization_id > 4;
|
||||
|
||||
-- Rischi e trattamenti
|
||||
DELETE FROM risk_treatments WHERE risk_id IN (SELECT id FROM risks WHERE organization_id > 4);
|
||||
DELETE FROM risks WHERE organization_id > 4;
|
||||
|
||||
-- Assessment e risposte
|
||||
DELETE FROM assessment_responses WHERE assessment_id IN (SELECT id FROM assessments WHERE organization_id > 4);
|
||||
DELETE FROM assessments WHERE organization_id > 4;
|
||||
|
||||
-- Policy
|
||||
DELETE FROM policies WHERE organization_id > 4;
|
||||
|
||||
-- Fornitori
|
||||
DELETE FROM suppliers WHERE organization_id > 4;
|
||||
|
||||
-- Training
|
||||
DELETE FROM training_assignments WHERE course_id IN (SELECT id FROM training_courses WHERE organization_id > 4);
|
||||
DELETE FROM training_courses WHERE organization_id > 4;
|
||||
|
||||
-- Asset
|
||||
DELETE FROM assets WHERE organization_id > 4;
|
||||
|
||||
-- Controlli compliance
|
||||
DELETE FROM compliance_controls WHERE organization_id > 4;
|
||||
|
||||
-- Evidenze
|
||||
DELETE FROM evidence_files WHERE organization_id > 4;
|
||||
|
||||
-- Non conformità e CAPA
|
||||
DELETE FROM corrective_actions WHERE non_conformity_id IN (SELECT id FROM non_conformities WHERE organization_id > 4);
|
||||
DELETE FROM non_conformities WHERE organization_id > 4;
|
||||
|
||||
-- Whistleblowing
|
||||
DELETE FROM whistleblowing_timeline
|
||||
WHERE report_id IN (SELECT id FROM whistleblowing_reports WHERE organization_id > 4);
|
||||
DELETE FROM whistleblowing_reports WHERE organization_id > 4;
|
||||
|
||||
-- Normativa ACK
|
||||
DELETE FROM normative_ack WHERE organization_id > 4;
|
||||
|
||||
-- API keys e webhook
|
||||
DELETE FROM webhook_deliveries
|
||||
WHERE subscription_id IN (SELECT id FROM webhook_subscriptions WHERE organization_id > 4);
|
||||
DELETE FROM webhook_subscriptions WHERE organization_id > 4;
|
||||
DELETE FROM api_keys WHERE organization_id > 4;
|
||||
|
||||
-- Audit log (solo dati demo, non i record di sistema id <= 100)
|
||||
DELETE FROM audit_logs WHERE organization_id > 4;
|
||||
DELETE FROM audit_exports WHERE organization_id > 4;
|
||||
DELETE FROM audit_violations WHERE organization_id > 4;
|
||||
|
||||
-- AI interactions
|
||||
DELETE FROM ai_interactions WHERE organization_id > 4;
|
||||
|
||||
-- Email log
|
||||
DELETE FROM email_log WHERE organization_id > 4;
|
||||
|
||||
-- ── Membership utenti ─────────────────────────────────────────────────────
|
||||
|
||||
-- Rimuove le associazioni utente-organizzazione demo
|
||||
DELETE FROM user_organizations WHERE organization_id > 4;
|
||||
|
||||
-- Rimuove token refresh degli utenti demo
|
||||
DELETE rt FROM refresh_tokens rt
|
||||
JOIN users u ON rt.user_id = u.id
|
||||
WHERE u.email LIKE '%.demo%';
|
||||
|
||||
-- Rimuove utenti demo (email terminano con .demo)
|
||||
DELETE FROM users WHERE email LIKE '%.demo%';
|
||||
|
||||
-- ── Organizzazioni demo ───────────────────────────────────────────────────
|
||||
DELETE FROM organizations WHERE id > 4;
|
||||
|
||||
-- ── Ripristino FK ─────────────────────────────────────────────────────────
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
-- ── Verifica stato ────────────────────────────────────────────────────────
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM organizations) AS organizations,
|
||||
(SELECT COUNT(*) FROM users) AS users,
|
||||
(SELECT COUNT(*) FROM incidents) AS incidents,
|
||||
(SELECT COUNT(*) FROM risks) AS risks,
|
||||
(SELECT COUNT(*) FROM audit_logs) AS audit_logs,
|
||||
(SELECT COUNT(*) FROM whistleblowing_reports) AS whistleblowing
|
||||
;
|
||||
|
||||
SELECT 'Reset demo completato. Dati seed mantenuti (id <= 4).' AS stato;
|
||||
Reference in New Issue
Block a user