Spaces:
Runtime error
Runtime error
Create app/main.
Browse files
app/main.
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from app.agents.threat_modeling import build_agents
|
| 4 |
+
|
| 5 |
+
app = FastAPI(title="Threat Modeling API")
|
| 6 |
+
agents = build_agents()
|
| 7 |
+
|
| 8 |
+
class ThreatRequest(BaseModel):
|
| 9 |
+
system_description: str
|
| 10 |
+
reference_text: str | None = None
|
| 11 |
+
|
| 12 |
+
@app.post("/analyze")
|
| 13 |
+
def analyze(req: ThreatRequest):
|
| 14 |
+
arch = agents["mapper"].run(req.system_description)
|
| 15 |
+
threats = agents["modeler"].run(req.system_description)
|
| 16 |
+
patterns = agents["extractor"].run(req.reference_text or "")
|
| 17 |
+
return {"architecture": arch, "threats": threats, "patterns": patterns}
|