Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(lint): resolve all ruff errors — F401 unused imports, C416 list comprehension, UP037 deprecated type annotation, E501 long lines

Beenu Aroraed015dba6969
diff --git a/services/actions/app/services/maturity.py b/services/actions/app/services/maturity.py
index d320cff1a..8de165aa0 100644
--- a/services/actions/app/services/maturity.py
+++ b/services/actions/app/services/maturity.py
@@ -17,7 +17,7 @@ from dataclasses import dataclass, field
from enum import IntEnum
from typing import Any
-from app.models.action import ACTION_BLAST_RADIUS, ActionRequest, ActionType, BlastRadius
+from app.models.action import ACTION_BLAST_RADIUS, ActionRequest, BlastRadius
class MaturityTier(IntEnum):
diff --git a/services/agents/app/api/copilot.py b/services/agents/app/api/copilot.py
index 3b67ac8cd..433e621ba 100644
--- a/services/agents/app/api/copilot.py
+++ b/services/agents/app/api/copilot.py
@@ -70,11 +70,31 @@ class CopilotConversation(BaseModel):
_CONVERSATIONS: dict[str, dict[str, Any]] = {}
_SYNTHETIC_REPLIES = [
- "I've analysed the alert context. The activity matches T1078 (Valid Accounts) combined with T1021.002 (SMB/Windows Admin Shares) lateral movement. Recommend isolating the host and reviewing recent authentication logs.",
- "Based on the indicators, this looks like credential-access activity. The parent process chain suggests a LOLBin pattern. Consider adding a detection rule for this specific chain.",
- "The entity risk score is elevated due to multiple failed authentications followed by a successful login from an unusual geolocation. I recommend triggering a step-up MFA challenge.",
- "Correlation across the last 24 hours shows this IP was seen in 3 other alerts. The MITRE mapping points to T1110 (Brute Force). Blocking the IP at the perimeter is the fastest remediation.",
- "I've reviewed the case timeline. The attacker dwell time appears short (< 2 hours), suggesting this may be an automated credential-stuffing campaign rather than a targeted intrusion.",
+ (
+ "I've analysed the alert context. The activity matches T1078 (Valid Accounts) combined"
+ " with T1021.002 (SMB/Windows Admin Shares) lateral movement. Recommend isolating the"
+ " host and reviewing recent authentication logs."
+ ),
+ (
+ "Based on the indicators, this looks like credential-access activity. The parent process"
+ " chain suggests a LOLBin pattern. Consider adding a detection rule for this specific"
+ " chain."
+ ),
+ (
+ "The entity risk score is elevated due to multiple failed authentications followed by a"
+ " successful login from an unusual geolocation. I recommend triggering a step-up MFA"
+ " challenge."
+ ),
+ (
+ "Correlation across the last 24 hours shows this IP was seen in 3 other alerts. The MITRE"
+ " mapping points to T1110 (Brute Force). Blocking the IP at the perimeter is the fastest"
+ " remediation."
+ ),
+ (
+ "I've reviewed the case timeline. The attacker dwell time appears short (< 2 hours),"
+ " suggesting this may be an automated credential-stuffing campaign rather than a targeted"
+ " intrusion."
+ ),
]
_reply_idx = 0
diff --git a/services/api/app/api/v1/endpoints/assets.py b/services/api/app/api/v1/endpoints/assets.py
index 17463a9cf..f07002fe0 100644
--- a/services/api/app/api/v1/endpoints/assets.py
+++ b/services/api/app/api/v1/endpoints/assets.py
@@ -12,7 +12,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.api.v1.endpoints.auth import get_current_user
from app.db.database import get_db
-from app.models.asset import AlertAssetCorrelation, Asset, AssetVulnerability
+from app.models.asset import Asset, AssetVulnerability
from app.models.tenant import User
router = APIRouter(prefix="/assets", tags=["assets"])
diff --git a/services/api/app/api/v1/endpoints/mssp.py b/services/api/app/api/v1/endpoints/mssp.py
index 2eda9fd80..0792dce22 100644
--- a/services/api/app/api/v1/endpoints/mssp.py
+++ b/services/api/app/api/v1/endpoints/mssp.py
@@ -4,11 +4,10 @@ from __future__ import annotations
import uuid
from datetime import UTC, datetime
-from typing import Any
from fastapi import APIRouter, Depends, HTTPException, Query, status
from pydantic import BaseModel
-from sqlalchemy import select, update
+from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.api.v1.endpoints.auth import get_current_user
@@ -224,7 +223,7 @@ async def list_metrics(
children_result = await db.execute(
select(Tenant.id).where(Tenant.parent_tenant_id == current_user.tenant_id)
)
- child_ids = [r for r in children_result.scalars().all()]
+ child_ids = list(children_result.scalars().all())
if not child_ids:
return []
diff --git a/services/api/app/models/asset.py b/services/api/app/models/asset.py
index 298b08c3d..4b5f33c9c 100644
--- a/services/api/app/models/asset.py
+++ b/services/api/app/models/asset.py
@@ -39,7 +39,7 @@ class Asset(Base):
onupdate=lambda: datetime.now(UTC),
)
- vulnerabilities: Mapped[list["AssetVulnerability"]] = relationship(
+ vulnerabilities: Mapped[list[AssetVulnerability]] = relationship(
"AssetVulnerability", back_populates="asset", lazy="noload"
)
@@ -66,7 +66,7 @@ class AssetVulnerability(Base):
metadata: Mapped[dict] = mapped_column(JSONB, default=dict)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(UTC))
- asset: Mapped["Asset"] = relationship("Asset", back_populates="vulnerabilities")
+ asset: Mapped[Asset] = relationship("Asset", back_populates="vulnerabilities")
class AlertAssetCorrelation(Base):
diff --git a/services/api/app/models/insider_threat.py b/services/api/app/models/insider_threat.py
index 638a2c8a5..9650500f5 100644
--- a/services/api/app/models/insider_threat.py
+++ b/services/api/app/models/insider_threat.py
@@ -45,7 +45,7 @@ class UserRiskProfile(Base):
onupdate=lambda: datetime.now(UTC),
)
- indicators: Mapped[list["InsiderIndicator"]] = relationship(
+ indicators: Mapped[list[InsiderIndicator]] = relationship(
"InsiderIndicator", back_populates="profile", lazy="noload"
)
@@ -70,7 +70,7 @@ class InsiderIndicator(Base):
acknowledged_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(UTC))
- profile: Mapped["UserRiskProfile"] = relationship("UserRiskProfile", back_populates="indicators")
+ profile: Mapped[UserRiskProfile] = relationship("UserRiskProfile", back_populates="indicators")
class InsiderPeerGroup(Base):
diff --git a/services/api/app/models/mssp.py b/services/api/app/models/mssp.py
index a0eab4a17..341c3ad5e 100644
--- a/services/api/app/models/mssp.py
+++ b/services/api/app/models/mssp.py
@@ -5,9 +5,9 @@ from __future__ import annotations
import uuid
from datetime import UTC, datetime
-from sqlalchemy import Boolean, DateTime, Float, ForeignKey, Integer, String, Text
+from sqlalchemy import DateTime, Float, ForeignKey, Integer, String, Text
from sqlalchemy.dialects.postgresql import JSONB, UUID
-from sqlalchemy.orm import Mapped, mapped_column, relationship
+from sqlalchemy.orm import Mapped, mapped_column
from app.db.database import Base