diff --git a/FLUJOS_DATOS/WIKIPEDIA/main.py b/FLUJOS_DATOS/WIKIPEDIA/main.py index 838e8970..4b689772 100755 --- a/FLUJOS_DATOS/WIKIPEDIA/main.py +++ b/FLUJOS_DATOS/WIKIPEDIA/main.py @@ -4,6 +4,7 @@ import time from transformers import BertTokenizer from collections import Counter from tqdm import tqdm +from wikipedia_utils import buscar_articulos, obtener_contenido_wikipedia stopwords = [ "de", "la", "que", "el", "en", "y", "a", "los", "del", "se", "las", "por", "un", "para", "con", diff --git a/INFO/DOCS/CONTEXT/PIPELINE_MAESTRO.md b/INFO/DOCS/CONTEXT/PIPELINE_MAESTRO.md index 3160d7f5..02d16e8a 100644 --- a/INFO/DOCS/CONTEXT/PIPELINE_MAESTRO.md +++ b/INFO/DOCS/CONTEXT/PIPELINE_MAESTRO.md @@ -147,6 +147,8 @@ Environment=DB_NAME=FLUJOS_DATOS ExecStart=/var/www/theflows.net/flujos/FLUJOS_DATOS/myenv/bin/python3 \ /var/www/theflows.net/flujos/FLUJOS_DATOS/pipeline_maestro.py TimeoutStartSec=43200 +Nice=15 +CPUQuota=400% StandardOutput=journal StandardError=journal @@ -154,22 +156,26 @@ StandardError=journal WantedBy=multi-user.target ``` +`Nice=15` + `CPUQuota=400%` limita el pipeline a ~4 cores para no saturar el servidor (Qwen en CPU puede usar 1000%+ por instancia sin esto). + ### flujos-pipeline.timer ```ini [Unit] -Description=Timer semanal para FLUJOS Pipeline Maestro +Description=Ejecutar FLUJOS Pipeline cada 2 dias a las 03:00 +Requires=flujos-pipeline.service [Timer] -OnCalendar=Sun *-*-* 03:00:00 -Persistent=true OnBootSec=2min +OnUnitActiveSec=2d +Persistent=true +Unit=flujos-pipeline.service [Install] WantedBy=timers.target ``` -`Persistent=true` hace que si el servidor estaba apagado el domingo a las 3:00, el timer se dispara 2 minutos después del siguiente arranque (`OnBootSec=2min`). +Cambiado de semanal (`OnCalendar=Sun`) a cada 2 días (`OnUnitActiveSec=2d`) el 2026-04-22. `Persistent=true` hace que si el servidor estaba apagado cuando tocaba, el timer se dispara 2 minutos después del siguiente arranque. ### Comandos de gestión @@ -231,6 +237,23 @@ journalctl -u flujos-pipeline.service --since "2026-04-20" --- +## Errores conocidos y fixes aplicados (2026-04-22) + +| Script | Error | Fix | +|---|---|---| +| `WIKIPEDIA/main.py` | `NameError: buscar_articulos` no definida | Añadido `from wikipedia_utils import buscar_articulos, obtener_contenido_wikipedia` | +| `WIKIPEDIA/main.py` | `ModuleNotFoundError: wikipedia` | `pip install wikipedia` en myenv | +| `WIKIPEDIA/main.py` | `ModuleNotFoundError: wikipediaapi` | `pip install wikipedia-api` en myenv | +| `NOTICIAS/main_noticias.py` | `ModuleNotFoundError: deep_translator` | `pip install deep-translator` en myenv | + +Todos los módulos se instalan dentro del entorno virtual: +```bash +/var/www/theflows.net/flujos/FLUJOS_DATOS/myenv/bin/python3 -m pip install +``` +No usar `pip` directamente (el ejecutable `pip` del venv puede estar roto; usar `python3 -m pip`). + +--- + ## Dependencias Python ``` diff --git a/INFO/DOCS/CONTEXT/SEGURIDAD.md b/INFO/DOCS/CONTEXT/SEGURIDAD.md index a3b74be1..9e7d6572 100644 --- a/INFO/DOCS/CONTEXT/SEGURIDAD.md +++ b/INFO/DOCS/CONTEXT/SEGURIDAD.md @@ -164,6 +164,24 @@ app.use(helmet.contentSecurityPolicy({...})); // luego ajusta solo el CSP --- +## Fixes aplicados (2026-04-22) + +Todos los ítems críticos y altos han sido corregidos en producción: + +| # | Vulnerabilidad | Fix aplicado | +|---|---|---| +| 1 | NoSQL Injection | `sanitizeParam()` + `TEMAS_VALIDOS` whitelist | +| 2 | Puerto 3000 público | `app.listen(port, '127.0.0.1', ...)` | +| 3 | XSS stored innerHTML | `textContent` + DOM API en `output_int_sec.js` y `3dscript_eco-corp.html` | +| 4 | ReDoS palabraClave | Escape de metacaracteres + límite 100 chars | +| 5 | Helmet parcial | `app.use(helmet())` completo + CSP sin `unsafe-inline` | +| 6 | CSRF | Filtro Origin en `/api/` | +| 7 | Body flooding | `bodyParser limit: '10kb'` | + +**Pendiente sin fix:** Rate limiting (express-rate-limit no instalado). + +--- + ## Lo que está bien | Componente | Estado | @@ -171,7 +189,7 @@ app.use(helmet.contentSecurityPolicy({...})); // luego ajusta solo el CSP | HTTPS con Let's Encrypt | Activo en nginx | | MongoDB en 127.0.0.1 | No expuesto al exterior | | Límite de nodos máx. 500 | `Math.min(parseInt(nodos) || 100, 500)` | -| Helmet CSP básico | Activo | +| Helmet completo | Activo desde 2026-04-22 | | No hay SQL injection | BD es MongoDB, no SQL | | No directory listing en /wiki-images/ | Express static lo rechaza | | HTTP → HTTPS redirect | Configurado en nginx |