Add database tables for storing detection, training, and whitelist information
Create SQL schemas for `detections`, `training_history`, and `whitelist` tables to manage IDS data, model training logs, and trusted IPs. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: f93295bb-74e9-4b67-b3d7-05437cb8c23f Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/MkBJZ0L
This commit is contained in:
parent
d345a24572
commit
0ab5e45413
4
.replit
4
.replit
@ -14,6 +14,10 @@ run = ["npm", "run", "start"]
|
||||
localPort = 5000
|
||||
externalPort = 80
|
||||
|
||||
[[ports]]
|
||||
localPort = 45045
|
||||
externalPort = 3000
|
||||
|
||||
[env]
|
||||
PORT = "5000"
|
||||
|
||||
|
||||
35
database-schema/create_detections.sql
Normal file
35
database-schema/create_detections.sql
Normal file
@ -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;
|
||||
30
database-schema/create_training_history.sql
Normal file
30
database-schema/create_training_history.sql
Normal file
@ -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;
|
||||
29
database-schema/create_whitelist.sql
Normal file
29
database-schema/create_whitelist.sql
Normal file
@ -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;
|
||||
Loading…
Reference in New Issue
Block a user