fix: módulos faltantes wikipedia scraper + docs actualizados
- WIKIPEDIA/main.py: import buscar_articulos y obtener_contenido_wikipedia - myenv: instalados wikipedia, wikipedia-api, deep-translator - PIPELINE_MAESTRO.md: tabla de errores conocidos, Nice/CPUQuota, timer 2d - SEGURIDAD.md: tabla de fixes aplicados en producción Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f04ab5fa74
commit
778db90d78
3 changed files with 47 additions and 5 deletions
|
|
@ -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 <modulo>
|
||||
```
|
||||
No usar `pip` directamente (el ejecutable `pip` del venv puede estar roto; usar `python3 -m pip`).
|
||||
|
||||
---
|
||||
|
||||
## Dependencias Python
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue