diff --git a/.replit b/.replit index 3dc4618..828b3b0 100644 --- a/.replit +++ b/.replit @@ -14,6 +14,10 @@ run = ["npm", "run", "start"] localPort = 5000 externalPort = 80 +[[ports]] +localPort = 39403 +externalPort = 3001 + [[ports]] localPort = 41303 externalPort = 3002 diff --git a/attached_assets/Pasted--Aggiornamento-dipendenze-Python-Defaulting-to-user-installation-because-normal-site-packages--1764002209926_1764002209926.txt b/attached_assets/Pasted--Aggiornamento-dipendenze-Python-Defaulting-to-user-installation-because-normal-site-packages--1764002209926_1764002209926.txt new file mode 100644 index 0000000..b547ca6 --- /dev/null +++ b/attached_assets/Pasted--Aggiornamento-dipendenze-Python-Defaulting-to-user-installation-because-normal-site-packages--1764002209926_1764002209926.txt @@ -0,0 +1,43 @@ + +πŸ“¦ Aggiornamento dipendenze Python... +Defaulting to user installation because normal site-packages is not writeable +Requirement already satisfied: fastapi==0.104.1 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 1)) (0.104.1) +Requirement already satisfied: uvicorn==0.24.0 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 2)) (0.24.0) +Requirement already satisfied: pandas==2.1.3 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 3)) (2.1.3) +Requirement already satisfied: numpy==1.26.2 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 4)) (1.26.2) +Requirement already satisfied: scikit-learn==1.3.2 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 5)) (1.3.2) +Requirement already satisfied: psycopg2-binary==2.9.9 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 6)) (2.9.9) +Requirement already satisfied: python-dotenv==1.0.0 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 7)) (1.0.0) +Requirement already satisfied: pydantic==2.5.0 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 8)) (2.5.0) +Requirement already satisfied: httpx==0.25.1 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 9)) (0.25.1) +Collecting Cython==3.0.5 + Downloading Cython-3.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 8.9 MB/s eta 0:00:00 +Collecting xgboost==2.0.3 + Using cached xgboost-2.0.3-py3-none-manylinux2014_x86_64.whl (297.1 MB) +Collecting joblib==1.3.2 + Using cached joblib-1.3.2-py3-none-any.whl (302 kB) +Collecting eif==2.0.2 + Using cached eif-2.0.2.tar.gz (1.6 MB) + Preparing metadata (setup.py) ... error + error: subprocess-exited-with-error + + Γ— python setup.py egg_info did not run successfully. + β”‚ exit code: 1 + ╰─> [6 lines of output] + Traceback (most recent call last): + File "", line 2, in + File "", line 34, in + File "/tmp/pip-install-843eies2/eif_72b54a0861444b02867269ed1670c0ce/setup.py", line 4, in + from Cython.Distutils import build_ext + ModuleNotFoundError: No module named 'Cython' + [end of output] + + note: This error originates from a subprocess, and is likely not a problem with pip. +error: metadata-generation-failed + +Γ— Encountered error while generating package metadata. +╰─> See above for output. + +note: This is an issue with the package mentioned above, not pip. +hint: See above for details. \ No newline at end of file diff --git a/deployment/CHECKLIST_ML_HYBRID.md b/deployment/CHECKLIST_ML_HYBRID.md index c3551ed..572e74d 100644 --- a/deployment/CHECKLIST_ML_HYBRID.md +++ b/deployment/CHECKLIST_ML_HYBRID.md @@ -14,26 +14,33 @@ Sistema ML avanzato per riduzione falsi positivi 80-90% con Extended Isolation F ## πŸ”§ Step 1: Installazione Dipendenze +⚠️ **IMPORTANTE**: Usare lo script dedicato per risolvere dipendenza Cython + ```bash # SSH al server ssh user@ids.alfacom.it -# Attiva venv -cd /opt/ids/python_ml -source venv/bin/activate +# Esegui script installazione ML dependencies +cd /opt/ids +chmod +x deployment/install_ml_deps.sh +./deployment/install_ml_deps.sh -# Installa nuove librerie -pip install -r requirements.txt - -# Verifica installazione -python -c "import xgboost; import eif; import joblib; print('βœ… Dipendenze OK')" +# Output atteso: +# βœ… Cython installato con successo +# βœ… Dipendenze ML installate con successo +# βœ… eif importato correttamente +# βœ… TUTTO OK! Hybrid ML Detector pronto per l'uso ``` **Dipendenze nuove**: +- `Cython==3.0.5` - Build dependency per eif (installato per primo) - `xgboost==2.0.3` - Gradient Boosting per ensemble classifier -- `eif==2.0.0` - Extended Isolation Forest +- `eif==2.0.2` - Extended Isolation Forest - `joblib==1.3.2` - Model persistence +**PerchΓ© lo script separato?** +`eif` richiede Cython per compilare il codice durante l'installazione. Lo script installa Cython PRIMA, poi le altre dipendenze. + --- ## πŸ§ͺ Step 2: Quick Test (Dataset Sintetico) diff --git a/deployment/install_ml_deps.sh b/deployment/install_ml_deps.sh new file mode 100644 index 0000000..44f86dc --- /dev/null +++ b/deployment/install_ml_deps.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Script per installare dipendenze ML Hybrid Detector +# Risolve il problema di Cython richiesto come build dependency da eif + +set -e + +echo "╔═══════════════════════════════════════════════╗" +echo "β•‘ INSTALLAZIONE DIPENDENZE ML HYBRID β•‘" +echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•" +echo "" + +# Vai alla directory python_ml +cd "$(dirname "$0")/../python_ml" || exit 1 + +echo "πŸ“ Directory corrente: $(pwd)" +echo "" + +# STEP 1: Installa Cython PRIMA (build dependency per eif) +echo "πŸ“¦ Step 1/2: Installazione Cython (richiesto per compilare eif)..." +pip install --user Cython==3.0.5 + +if [ $? -eq 0 ]; then + echo "βœ… Cython installato con successo" +else + echo "❌ Errore durante installazione Cython" + exit 1 +fi + +echo "" + +# STEP 2: Installa tutte le altre dipendenze +echo "πŸ“¦ Step 2/2: Installazione dipendenze ML (xgboost, joblib, eif)..." +pip install --user xgboost==2.0.3 joblib==1.3.2 eif==2.0.2 + +if [ $? -eq 0 ]; then + echo "βœ… Dipendenze ML installate con successo" +else + echo "❌ Errore durante installazione dipendenze ML" + exit 1 +fi + +echo "" +echo "βœ… INSTALLAZIONE COMPLETATA!" +echo "" +echo "πŸ§ͺ Test import eif..." +python3 -c "from eif import iForest; print('βœ… eif importato correttamente')" + +if [ $? -eq 0 ]; then + echo "" + echo "βœ… TUTTO OK! Hybrid ML Detector pronto per l'uso" +else + echo "❌ Errore durante test import eif" + exit 1 +fi diff --git a/replit.md b/replit.md index 02040b1..680b2ea 100644 --- a/replit.md +++ b/replit.md @@ -103,6 +103,8 @@ The IDS employs a React-based frontend for real-time monitoring, detection visua - **Backward Compatibility**: USE_HYBRID_DETECTOR env var (default=true) - **Target Metrics**: Precisionβ‰₯90%, Recallβ‰₯80%, FPR≀5%, F1β‰₯85% - **Deploy**: Vedere `deployment/CHECKLIST_ML_HYBRID.md` -- **Fix Deploy (24 Nov 2025 - 19:15)**: +- **Fix Deploy (24 Nov 2025 - 19:30)**: - Corretto `eif==2.0.0` β†’ `eif==2.0.2` (versione 2.0.0 non disponibile) - - Aggiunto `Cython==3.0.5` come dipendenza (richiesto per compilare eif da source) \ No newline at end of file + - Aggiunto `Cython==3.0.5` come build dependency (eif richiede compilazione) + - Creato `deployment/install_ml_deps.sh` per installazione in 2 fasi (Cython β†’ eif) + - **Soluzione**: pip non installa Cython in tempo per eif β†’ script separa installazione \ No newline at end of file