Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from fastapi.responses import HTMLResponse | |
| from fastapi.staticfiles import StaticFiles | |
| from pydantic import BaseModel | |
| from typing import List | |
| app = FastAPI() | |
| app.mount("/static", StaticFiles(directory="."), name="static") | |
| class DomainScore(BaseModel): | |
| name: str | |
| score: int | |
| class AnalysisRequest(BaseModel): | |
| overall: int | |
| domains: List[DomainScore] | |
| async def analyze(data: AnalysisRequest): | |
| analysis = f""" | |
| 🔒 **ANÁLISIS AVANZADO DE CIBERSEGURIDAD - DOCTOR LINUX** | |
| **PUNTAJE GLOBAL:** {data.overall}% | |
| **EVALUACIÓN ESTRATÉGICA:** | |
| {"✅ POSTURA SÓLIDA - Controles robustos implementados" if data.overall >= 80 else | |
| "⚠️ POSTURA MEDIA - Se requieren mejoras en controles críticos" if data.overall >= 60 else | |
| "🚨 RIESGO ELEVADO - Atención inmediata requerida en múltiples áreas"} | |
| **ANÁLISIS DETALLADO POR DOMINIO:** | |
| {chr(10).join([f"• {domain.name}: {domain.score}% - {get_domain_analysis(domain.name, domain.score)}" for domain in data.domains])} | |
| **RIESGOS IDENTIFICADOS:** | |
| {get_risk_analysis(data.domains)} | |
| **RECOMENDACIONES PRIORITARIAS:** | |
| 1. Implementar controles básicos en áreas críticas | |
| 2. Establecer monitoreo continuo 24/7 | |
| 3. Desarrollar plan de respuesta a incidentes | |
| 4. Realizar auditoría de seguridad profunda | |
| 5. Capacitar equipo en mejores prácticas | |
| **ROADMAP SUGERIDO:** | |
| • SEMANA 1: Contención de riesgos críticos | |
| • SEMANA 2-4: Implementación controles básicos | |
| • MES 2-3: Mejora de madurez operacional | |
| • MES 4-6: Optimización y automatización | |
| --- | |
| *Análisis generado por Doctor Linux - Expertos en Ciberseguridad Operativa* | |
| """ | |
| return {"analysis": analysis} | |
| def get_domain_analysis(name, score): | |
| if score >= 80: | |
| return "Control robusto - Mantener y documentar" | |
| elif score >= 60: | |
| return "Control aceptable - Mejorar procesos" | |
| else: | |
| return "Control crítico - Acción inmediata requerida" | |
| def get_risk_analysis(domains): | |
| critical = [d for d in domains if d.score < 60] | |
| medium = [d for d in domains if 60 <= d.score < 80] | |
| analysis = "" | |
| if critical: | |
| analysis += "🚨 RIESGOS CRÍTICOS:\n" | |
| analysis += chr(10).join([f" - {d.name} ({d.score}%): Exposición alta\n" for d in critical]) | |
| if medium: | |
| analysis += "⚠️ RIESGOS MEDIOS:\n" | |
| analysis += chr(10).join([f" - {d.name} ({d.score}%): Mejora necesaria\n" for d in medium]) | |
| return analysis | |
| async def read_root(): | |
| try: | |
| with open("index.html", "r", encoding="utf-8") as f: | |
| return HTMLResponse(content=f.read()) | |
| except: | |
| return HTMLResponse(content="<h1>Error: Archivo index.html no encontrado</h1>") | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |