@cryptotaxi247 / CoPilot / commits / 6fd183e5

precommit fixes (#372)

taylor_socfortress committed Dec 13, 2024 at 09:09 UTC 6fd183e528665e3f0c5e6e1cd60d648c1328b0e4
3 files changed +9 -5
backend/app/connectors/wazuh_indexer/routes/sigma.py
+3 -2
@@ -1,3 +1,4 @@
1 +import asyncio
2 import os
3 from datetime import datetime
4
@@ -7,7 +8,6 @@ from fastapi import File
8 from fastapi import HTTPException
9 from fastapi import Query
10 from fastapi import UploadFile
10 -import asyncio
11 from loguru import logger
12 from sqlalchemy.ext.asyncio import AsyncSession
13
@@ -321,6 +321,7 @@ async def deactivate_all_sigma_queries_endpoint(
321 # message="Successfully ran the active Sigma queries.",
322 # )
323
324 +
325 @wazuh_indexer_sigma_router.post("/run-active-queries", response_model=SigmaQueryOutResponse)
326 async def run_active_sigma_queries_endpoint(
327 index_name: str = Query(default="wazuh*"),
@@ -363,7 +364,7 @@ async def run_active_sigma_queries_endpoint(
364 query.last_execution_time = current_time
365
366 # Run all tasks concurrently
366 - results = await asyncio.gather(*tasks)
367 + await asyncio.gather(*tasks)
368
369 # Commit the changes to the database
370 await db.commit()
backend/app/connectors/wazuh_indexer/services/sigma/execute_query.py
+3 -2
@@ -4,10 +4,11 @@ from typing import List
4 from fastapi import HTTPException
5 from loguru import logger
6 from sqlalchemy.ext.asyncio import AsyncSession
7 -import asyncio
7
8 from app.connectors.wazuh_indexer.schema.sigma import RunActiveSigmaQueries
10 -from app.connectors.wazuh_indexer.utils.universal import create_wazuh_indexer_client, create_wazuh_indexer_client_async
9 +from app.connectors.wazuh_indexer.utils.universal import (
10 + create_wazuh_indexer_client_async,
11 +)
12 from app.incidents.schema.incident_alert import CreatedAlertPayload
13 from app.incidents.services.incident_alert import add_asset_to_copilot_alert
14 from app.incidents.services.incident_alert import build_alert_context_payload
backend/app/connectors/wazuh_indexer/utils/universal.py
+3 -1
@@ -6,7 +6,8 @@ from typing import Dict
6 from typing import Iterable
7 from typing import Tuple
8
9 -from elasticsearch7 import Elasticsearch, AsyncElasticsearch
9 +from elasticsearch7 import AsyncElasticsearch
10 +from elasticsearch7 import Elasticsearch
11 from fastapi import HTTPException
12 from loguru import logger
13
@@ -112,6 +113,7 @@ async def create_wazuh_indexer_client(connector_name: str = "Wazuh-Indexer") ->
113 detail=f"Failed to create Elasticsearch client: {e}",
114 )
115
116 +
117 async def create_wazuh_indexer_client_async(connector_name: str = "Wazuh-Indexer") -> AsyncElasticsearch:
118 """
119 Returns an Elasticsearch client for the Wazuh Indexer service.