| 1 | from fastapi import APIRouter |
| 2 | from fastapi import Security |
| 3 | from loguru import logger |
| 4 | |
| 5 | from app.auth.utils import AuthHandler |
| 6 | from app.threat_intel.schema.epss import EpssThreatIntelRequest |
| 7 | from app.threat_intel.schema.epss import EpssThreatIntelResponse |
| 8 | from app.threat_intel.services.epss import collect_epss_score |
| 9 | |
| 10 | # App specific imports |
| 11 | |
| 12 | threat_intel_epss_router = APIRouter() |
| 13 | |
| 14 | |
| 15 | @threat_intel_epss_router.post( |
| 16 | "/epss", |
| 17 | response_model=EpssThreatIntelResponse, |
| 18 | description="Threat Intel EPSS Score", |
| 19 | dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))], |
| 20 | ) |
| 21 | async def threat_intel_epss( |
| 22 | request: EpssThreatIntelRequest, |
| 23 | ): |
| 24 | """ |
| 25 | Endpoint for SocFortress Threat Intel. |
| 26 | |
| 27 | This endpoint allows authorized users with 'admin' or 'analyst' scope to perform SocFortress threat intelligence lookup. |
| 28 | |
| 29 | Parameters: |
| 30 | - request: SocfortressThreatIntelRequest - The request payload containing the necessary information for the lookup. |
| 31 | - session: AsyncSession (optional) - The database session to use for the lookup. |
| 32 | - _key_exists: bool (optional) - A dependency to ensure the API key exists. |
| 33 | |
| 34 | Returns: |
| 35 | - IoCResponse: The response model containing the results of the SocFortress threat intelligence lookup. |
| 36 | """ |
| 37 | logger.info(f"Received request for EPSS score: {request}") |
| 38 | return await collect_epss_score(request) |