diff --git a/agentic_security/core/app.py b/agentic_security/core/app.py index f97f380..3cb306e 100644 --- a/agentic_security/core/app.py +++ b/agentic_security/core/app.py @@ -5,17 +5,14 @@ from fastapi import FastAPI from fastapi.responses import ORJSONResponse from agentic_security.http_spec import LLMSpec -from typing import Any, Dict tools_inbox: Queue = Queue() stop_event: Event = Event() current_run: str = {"spec": "", "id": ""} _secrets: dict[str, str] = {} -current_run: Dict[str, int | LLMSpec] = { - "spec": "", - "id": "" -} +current_run: dict[str, int | LLMSpec] = {"spec": "", "id": ""} + def create_app() -> FastAPI: """Create and configure the FastAPI application.""" @@ -33,12 +30,12 @@ def get_stop_event() -> Event: return stop_event -def get_current_run() -> Dict[str, int | LLMSpec]: +def get_current_run() -> dict[str, int | LLMSpec]: """Get the current run id.""" return current_run -def set_current_run(spec : LLMSpec) -> Dict[str, int | LLMSpec]: +def set_current_run(spec: LLMSpec) -> dict[str, int | LLMSpec]: """Set the current run id.""" current_run["id"] = hash(id(spec)) current_run["spec"] = spec @@ -49,13 +46,13 @@ def get_secrets() -> dict[str, str]: return _secrets -def set_secrets(secrets : dict[str, str]) -> dict[str, str]: +def set_secrets(secrets: dict[str, str]) -> dict[str, str]: _secrets.update(secrets) expand_secrets(_secrets) return _secrets -def expand_secrets(secrets : dict[str, str]) -> None: +def expand_secrets(secrets: dict[str, str]) -> None: for key in secrets: val = secrets[key] if val.startswith("$"): diff --git a/agentic_security/misc/banner.py b/agentic_security/misc/banner.py index 308d42a..45edba5 100644 --- a/agentic_security/misc/banner.py +++ b/agentic_security/misc/banner.py @@ -1,6 +1,6 @@ + from pyfiglet import Figlet, FontNotFound from termcolor import colored -from typing import Optional try: from importlib.metadata import version @@ -15,7 +15,7 @@ def generate_banner( tagline: str = "Proactive Threat Detection & Automated Security Protocols", author: str = "Developed by: [Security Team]", website: str = "Website: https://github.com/msoedov/agentic_security", - warning: Optional[str] = "", # Using Optional for warning since it might be None + warning: str | None = "", # Using Optional for warning since it might be None ) -> str: """Generate a visually enhanced banner with dynamic width and borders.""" # Define the text elements diff --git a/agentic_security/report_chart.py b/agentic_security/report_chart.py index 4f13ae9..45387cb 100644 --- a/agentic_security/report_chart.py +++ b/agentic_security/report_chart.py @@ -1,6 +1,5 @@ import io import string -from typing import List import matplotlib.pyplot as plt import numpy as np @@ -10,6 +9,7 @@ from matplotlib.colors import LinearSegmentedColormap, Normalize from .primitives import Table + def plot_security_report(table: Table) -> io.BytesIO: # Data preprocessing data = pd.DataFrame(table) @@ -143,7 +143,7 @@ def plot_security_report(table: Table) -> io.BytesIO: return buf -def generate_identifiers(data : pd.DataFrame) -> List[str]: +def generate_identifiers(data: pd.DataFrame) -> list[str]: data_length = len(data) alphabet = string.ascii_uppercase num_letters = len(alphabet) diff --git a/agentic_security/routes/scan.py b/agentic_security/routes/scan.py index b4400f1..8313702 100644 --- a/agentic_security/routes/scan.py +++ b/agentic_security/routes/scan.py @@ -1,5 +1,6 @@ +from collections.abc import Generator from datetime import datetime -from typing import Any, Generator +from typing import Any from fastapi import ( APIRouter,