diff --git a/.replit b/.replit index af7007c..e303f0e 100644 --- a/.replit +++ b/.replit @@ -14,6 +14,10 @@ run = ["npm", "run", "start"] localPort = 5000 externalPort = 80 +[[ports]] +localPort = 45045 +externalPort = 3000 + [env] PORT = "5000" diff --git a/database-schema/create_detections.sql b/database-schema/create_detections.sql new file mode 100644 index 0000000..6bfcc03 --- /dev/null +++ b/database-schema/create_detections.sql @@ -0,0 +1,35 @@ +-- ========================================================= +-- SCHEMA: Tabella detections per IDS anomalie +-- ========================================================= +-- Memorizza IP rilevati come pericolosi dal ML +-- ========================================================= + +-- Drop tabella se esiste (solo per ambiente di sviluppo) +DROP TABLE IF EXISTS detections CASCADE; + +-- Crea tabella detections +CREATE TABLE detections ( + id VARCHAR PRIMARY KEY DEFAULT gen_random_uuid(), + source_ip TEXT NOT NULL, + risk_score DECIMAL(5, 2) NOT NULL, + confidence DECIMAL(5, 2) NOT NULL, + anomaly_type TEXT NOT NULL, + reason TEXT, + log_count INTEGER NOT NULL, + first_seen TIMESTAMP NOT NULL, + last_seen TIMESTAMP NOT NULL, + blocked BOOLEAN NOT NULL DEFAULT FALSE, + blocked_at TIMESTAMP, + detected_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +-- Indici per performance +CREATE INDEX IF NOT EXISTS detection_source_ip_idx ON detections(source_ip); +CREATE INDEX IF NOT EXISTS risk_score_idx ON detections(risk_score); +CREATE INDEX IF NOT EXISTS detected_at_idx ON detections(detected_at); + +-- Commento tabella +COMMENT ON TABLE detections IS 'IP pericolosi rilevati dal sistema ML (Isolation Forest)'; + +-- Verifica +SELECT 'Tabella detections creata con successo!' AS status; diff --git a/database-schema/create_training_history.sql b/database-schema/create_training_history.sql new file mode 100644 index 0000000..1725500 --- /dev/null +++ b/database-schema/create_training_history.sql @@ -0,0 +1,30 @@ +-- ========================================================= +-- SCHEMA: Tabella training_history per storico ML +-- ========================================================= +-- Memorizza storia training modelli ML +-- ========================================================= + +-- Drop tabella se esiste (solo per ambiente di sviluppo) +DROP TABLE IF EXISTS training_history CASCADE; + +-- Crea tabella training_history +CREATE TABLE training_history ( + id VARCHAR PRIMARY KEY DEFAULT gen_random_uuid(), + model_version TEXT NOT NULL, + records_processed INTEGER NOT NULL, + features_count INTEGER NOT NULL, + accuracy DECIMAL(5, 2), + training_duration INTEGER, + status TEXT NOT NULL, + notes TEXT, + trained_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +-- Indici per performance +CREATE INDEX IF NOT EXISTS trained_at_idx ON training_history(trained_at); + +-- Commento tabella +COMMENT ON TABLE training_history IS 'Storico training modelli ML per IDS'; + +-- Verifica +SELECT 'Tabella training_history creata con successo!' AS status; diff --git a/database-schema/create_whitelist.sql b/database-schema/create_whitelist.sql new file mode 100644 index 0000000..9ee8509 --- /dev/null +++ b/database-schema/create_whitelist.sql @@ -0,0 +1,29 @@ +-- ========================================================= +-- SCHEMA: Tabella whitelist per IP fidati +-- ========================================================= +-- IP che non devono mai essere bloccati +-- ========================================================= + +-- Drop tabella se esiste (solo per ambiente di sviluppo) +DROP TABLE IF EXISTS whitelist CASCADE; + +-- Crea tabella whitelist +CREATE TABLE whitelist ( + id VARCHAR PRIMARY KEY DEFAULT gen_random_uuid(), + ip_address TEXT NOT NULL UNIQUE, + comment TEXT, + reason TEXT, + created_by TEXT, + active BOOLEAN NOT NULL DEFAULT TRUE, + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +-- Indici per performance +CREATE INDEX IF NOT EXISTS whitelist_ip_idx ON whitelist(ip_address); +CREATE INDEX IF NOT EXISTS whitelist_active_idx ON whitelist(active); + +-- Commento tabella +COMMENT ON TABLE whitelist IS 'IP fidati che non devono mai essere bloccati dal sistema'; + +-- Verifica +SELECT 'Tabella whitelist creata con successo!' AS status;