fix: use validate cve result
Browse files- app/main.py +10 -6
app/main.py
CHANGED
|
@@ -60,12 +60,16 @@ async def cached_report(cve_id: str, refresh: bool = Query(False)):
|
|
| 60 |
|
| 61 |
@app.get("/viewer", operation_id="viewer")
|
| 62 |
async def viewer(request: Request, cve_id: str, refresh: bool = Query(False)):
|
| 63 |
-
validate_cve_id(cve_id) # Validate CVE-ID
|
| 64 |
-
|
| 65 |
-
"
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
@app.get("/stream", operation_id="stream")
|
|
|
|
| 60 |
|
| 61 |
@app.get("/viewer", operation_id="viewer")
|
| 62 |
async def viewer(request: Request, cve_id: str, refresh: bool = Query(False)):
|
| 63 |
+
if validate_cve_id(cve_id): # Validate CVE-ID
|
| 64 |
+
cve_data = await get_cve_info(cve_id)
|
| 65 |
+
return templates.TemplateResponse("index.html", {
|
| 66 |
+
"request": request,
|
| 67 |
+
"cve_id": cve_id,
|
| 68 |
+
"refresh": refresh
|
| 69 |
+
})
|
| 70 |
+
else:
|
| 71 |
+
raise HTTPException(status_code=400, detail="Invalid CVE ID format. Expected format: CVE-YYYY-NNNNN.")
|
| 72 |
+
|
| 73 |
|
| 74 |
|
| 75 |
@app.get("/stream", operation_id="stream")
|