| 1 | # from fastapi import APIRouter |
| 2 | # from fastapi import Depends |
| 3 | # from fastapi import HTTPException |
| 4 | # from fastapi import Security |
| 5 | # from loguru import logger |
| 6 | # from sqlalchemy.ext.asyncio import AsyncSession |
| 7 | |
| 8 | # from app.auth.utils import AuthHandler |
| 9 | # from app.db.db_session import get_db |
| 10 | # from app.integrations.ask_socfortress.schema.ask_socfortress import ( |
| 11 | # AskSocfortressRequest, |
| 12 | # ) |
| 13 | # from app.integrations.ask_socfortress.schema.ask_socfortress import ( |
| 14 | # AskSocfortressSigmaResponse, |
| 15 | # ) |
| 16 | # from app.integrations.ask_socfortress.services.ask_socfortress import ( |
| 17 | # ask_socfortress_lookup, |
| 18 | # ) |
| 19 | # from app.utils import get_connector_attribute |
| 20 | |
| 21 | # # App specific imports |
| 22 | |
| 23 | # ask_socfortress_router = APIRouter() |
| 24 | |
| 25 | |
| 26 | # async def ensure_api_key_exists(session: AsyncSession = Depends(get_db)) -> bool: |
| 27 | # """ |
| 28 | # Ensures that the Ask SocFortress API key exists in the database. |
| 29 | |
| 30 | # Args: |
| 31 | # session (AsyncSession): The database session. |
| 32 | |
| 33 | # Raises: |
| 34 | # HTTPException: Raised if the SocFortress API key is not found. |
| 35 | |
| 36 | # Returns: |
| 37 | # bool: True if the API key exists, otherwise raises HTTPException. |
| 38 | # """ |
| 39 | # api_key = await get_connector_attribute( |
| 40 | # connector_id=10, |
| 41 | # column_name="connector_api_key", |
| 42 | # session=session, |
| 43 | # ) |
| 44 | # # Close the session |
| 45 | # await session.close() |
| 46 | # if not api_key: |
| 47 | # raise HTTPException( |
| 48 | # status_code=500, |
| 49 | # detail="Ask SocFortress API key not found in the database.", |
| 50 | # ) |
| 51 | # return True |
| 52 | |
| 53 | |
| 54 | # @ask_socfortress_router.post( |
| 55 | # "/sigma", |
| 56 | # response_model=AskSocfortressSigmaResponse, |
| 57 | # description="Ask SOCFortress for a Sigma rule.", |
| 58 | # dependencies=[Security(AuthHandler().require_any_scope("admin", "analyst"))], |
| 59 | # ) |
| 60 | # async def ask_socfortress_sigma( |
| 61 | # alert: AskSocfortressRequest, |
| 62 | # session: AsyncSession = Depends(get_db), |
| 63 | # _key_exists: bool = Depends(ensure_api_key_exists), |
| 64 | # ): |
| 65 | # """ |
| 66 | # Endpoint to ask SOCFortress for a Sigma rule. |
| 67 | |
| 68 | # Args: |
| 69 | # alert (AskSocfortressRequest): The alert data. |
| 70 | # session (AsyncSession, optional): The database session. Defaults to Depends(get_db). |
| 71 | # _key_exists (bool, optional): The API key existence flag. Defaults to Depends(ensure_api_key_exists). |
| 72 | |
| 73 | # Returns: |
| 74 | # AskSocfortressSigmaResponse: The response from SOCFortress. |
| 75 | # """ |
| 76 | # logger.info("Running Ask SOCFortress Sigma lookup.") |
| 77 | |
| 78 | # ask_socfortress_result = await ask_socfortress_lookup(alert, session=session) |
| 79 | # return ask_socfortress_result |