[DOCS] CLAUDE.md: documentazione AuditService, simulazioni, migration 010

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile 2026-03-07 13:58:29 +01:00
parent 874eabb6fc
commit 0fcc69ee85

View File

@ -2,8 +2,8 @@
## PRIMA DI INIZIARE
- Leggi sempre questo file prima di iniziare qualsiasi lavoro
- Il progetto e' al **100% di completamento + Sprint Services/Webhook/Whistleblowing** (~30.000 righe, 75+ file sorgente)
- 9 commit su main, tutto deployato e testato su Hetzner
- Il progetto e' al **100% di completamento + Sprint Simulazioni + Audit Chain** (~32.000 righe, 80+ file sorgente)
- 11 commit su main, tutto deployato e testato su Hetzner
- E2E test completati, bug fixing, Docker verificato, UI polished
> 3. `docs/CONTEXT_LAST_SESSION.md` - **Contesto ultima sessione (continuita cross-browser)**
>
@ -187,7 +187,12 @@ nis2.agile/
│ ├── 003_voluntary_compliance.sql # ALTER organizations: voluntary_compliance
│ ├── 004_ncr_capa.sql # Tabelle non_conformities, corrective_actions
│ ├── 005_consultant_support.sql # ALTER user_organizations: ruolo consultant
│ └── 006_security_improvements.sql # Indici performance + soft delete + trigger audit immutabile
│ ├── 006_security_improvements.sql # Indici performance + soft delete + trigger audit immutabile
│ ├── 007_services_api.sql # api_keys, webhook_subscriptions, webhook_deliveries
│ ├── 008_whistleblowing.sql # whistleblowing_reports, whistleblowing_timeline
│ ├── 009_normative_updates.sql # normative_updates, normative_ack (seed 5 aggiornamenti)
│ ├── 010_audit_hash_chain.sql # prev_hash, entry_hash, severity su audit_logs
│ └── reset-demo.sql # Reset dati demo (mantiene id<=4)
├── context/
│ └── CONTEXT_SCHEMA_DB.md
├── prompts/
@ -242,6 +247,23 @@ Schema: `docs/sql/` (9 migrazioni: 001→009)
- Fetch dati da CertiSource API (GET /api/company/enrich?vat=)
- Mapping ATECO → settore NIS2
### AuditService.php (NUOVO)
- Hash chain SHA-256: ogni record include prev_hash → entry_hash linkato
- `log()`: inserisce con hash catena, auto-severity (info/warning/critical)
- `verifyChain()`: verifica integrità per org, rileva record manomessi
- `exportCertified()`: export JSON con SHA-256 del contenuto, salva in audit_exports
- Adattato da lg231-agile/shared/audit-lib/src/AuditTrailService.php
### WebhookService.php (NUOVO)
- Delivery HMAC-SHA256 Stripe-like, header X-NIS2-Signature
- Retry 3x backoff (0s/5min/30min), log in webhook_deliveries
### simulate-nis2.php (ROOT — NUOVO)
- Script simulazione demo 3 aziende × 5 scenari (CLI + SSE streaming)
- Aziende: DataCore (IT/Essential), MedClinic (Sanità/Important), EnerNet (Energia/Critical)
- Scenari: Onboarding + Assessment | Ransomware Art.23 | Data Breach | Whistleblowing | Audit Chain
- Reset: docs/sql/reset-demo.sql (cancella org/utenti con id>4 e email %.demo%)
## Deploy
- **SSH**: `ssh -i docs/credentials/hetzner_key root@135.181.149.254`
- **Path server**: `/var/www/nis2-agile/`