|
19 | 19 | from modules.serverless_computing import ServerlessComputing |
20 | 20 | from modules.microservices_architecture import MicroservicesArchitecture |
21 | 21 | from modules.cloud_native_applications import CloudNativeApplications |
| 22 | +from database.models import DocumentAnalysis |
| 23 | +from sqlalchemy import create_engine |
| 24 | +from sqlalchemy.orm import sessionmaker |
22 | 25 |
|
23 | 26 | app = Flask(__name__) |
24 | 27 | app.secret_key = 'your_secret_key' |
25 | 28 |
|
| 29 | +DATABASE_URL = "sqlite:///document_analysis.db" |
| 30 | +engine = create_engine(DATABASE_URL) |
| 31 | +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) |
| 32 | + |
26 | 33 | # Dummy user data for RBAC |
27 | 34 | users = { |
28 | 35 | "admin": {"password": "admin123", "role": "admin"}, |
@@ -94,6 +101,44 @@ def dashboard(): |
94 | 101 | monitoring.microservices_architecture = microservices_architecture |
95 | 102 | monitoring.cloud_native_applications = cloud_native_applications |
96 | 103 |
|
| 104 | + # Save dashboard data to the database |
| 105 | + session = SessionLocal() |
| 106 | + try: |
| 107 | + dashboard_data = DocumentAnalysis( |
| 108 | + source="dashboard", |
| 109 | + title="Dashboard Data", |
| 110 | + links=str({ |
| 111 | + "threats_detected": 5, |
| 112 | + "exploits_deployed": 3, |
| 113 | + "malware_analysis": malware_analysis.render(), |
| 114 | + "social_engineering": social_engineering.render(), |
| 115 | + "threat_intelligence": threat_intelligence.render(), |
| 116 | + "monitoring": monitoring.render(), |
| 117 | + "advanced_threat_intelligence": advanced_threat_intelligence.render(), |
| 118 | + "predictive_analytics": predictive_analytics.render(), |
| 119 | + "automated_incident_response": automated_incident_response.render(), |
| 120 | + "ai_red_teaming": ai_red_teaming.render(), |
| 121 | + "apt_simulation": apt_simulation.render(), |
| 122 | + "machine_learning_ai": machine_learning_ai.render(), |
| 123 | + "data_visualization": data_visualization.render(), |
| 124 | + "blockchain_logger": blockchain_logger.render(), |
| 125 | + "cloud_exploitation": cloud_exploitation.render(), |
| 126 | + "iot_exploitation": iot_exploitation.render(), |
| 127 | + "quantum_computing": quantum_computing.render(), |
| 128 | + "edge_computing": edge_computing.render(), |
| 129 | + "serverless_computing": serverless_computing.render(), |
| 130 | + "microservices_architecture": microservices_architecture.render(), |
| 131 | + "cloud_native_applications": cloud_native_applications.render() |
| 132 | + }), |
| 133 | + error=None |
| 134 | + ) |
| 135 | + session.add(dashboard_data) |
| 136 | + session.commit() |
| 137 | + except Exception as e: |
| 138 | + print(f"Error saving dashboard data to database: {e}") |
| 139 | + finally: |
| 140 | + session.close() |
| 141 | + |
97 | 142 | return render_template("dashboard.html", data={ |
98 | 143 | "threats_detected": 5, |
99 | 144 | "exploits_deployed": 3, |
|
0 commit comments