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.

chore(ai-estate): regenerate the published spec and satisfy the lint pins

Beenu Arora7a31ba99171a
diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index 36056e700..eeeb2caa2 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -7035,6 +7035,139 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
+ /api/v1/ai-assets:
+ get:
+ tags:
+ - ai-estate
+ summary: List Ai Assets
+ description: The estate, newest sighting first.
+ operationId: list_ai_assets_api_v1_ai_assets_get
+ security:
+ - HTTPBearer: []
+ parameters:
+ - name: kind
+ in: query
+ required: false
+ schema:
+ anyOf:
+ - type: string
+ - type: 'null'
+ description: Filter to one asset kind.
+ title: Kind
+ description: Filter to one asset kind.
+ - name: unlinked
+ in: query
+ required: false
+ schema:
+ type: boolean
+ description: Only assets with no person linked.
+ default: false
+ title: Unlinked
+ description: Only assets with no person linked.
+ - name: limit
+ in: query
+ required: false
+ schema:
+ type: integer
+ maximum: 200
+ minimum: 1
+ default: 50
+ title: Limit
+ - name: offset
+ in: query
+ required: false
+ schema:
+ type: integer
+ minimum: 0
+ default: 0
+ title: Offset
+ responses:
+ '200':
+ description: Successful Response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AiAssetListResponse'
+ '422':
+ description: Validation Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/HTTPValidationError'
+ /api/v1/ai-assets/{asset_id}:
+ get:
+ tags:
+ - ai-estate
+ summary: Get Ai Asset
+ operationId: get_ai_asset_api_v1_ai_assets__asset_id__get
+ security:
+ - HTTPBearer: []
+ parameters:
+ - name: asset_id
+ in: path
+ required: true
+ schema:
+ type: string
+ format: uuid
+ title: Asset Id
+ responses:
+ '200':
+ description: Successful Response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AiAssetModel'
+ '422':
+ description: Validation Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/HTTPValidationError'
+ /api/v1/ai-assets/{asset_id}/sanction:
+ post:
+ tags:
+ - ai-estate
+ summary: Sanction Ai Asset
+ description: 'Approve an asset, refuse it, or put it back to undecided.
+
+
+ The risk score is recomputed here rather than left stale, through the
+
+ same `score_risk` the recorder calls, because the sanction decision is
+
+ one of its inputs: an asset that has just been refused and is still
+
+ running is a different exposure from one nobody had looked at.'
+ operationId: sanction_ai_asset_api_v1_ai_assets__asset_id__sanction_post
+ security:
+ - HTTPBearer: []
+ parameters:
+ - name: asset_id
+ in: path
+ required: true
+ schema:
+ type: string
+ format: uuid
+ title: Asset Id
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/SanctionRequest'
+ responses:
+ '200':
+ description: Successful Response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AiAssetModel'
+ '422':
+ description: Validation Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/HTTPValidationError'
/api/v1/tenant-skills:
get:
tags:
@@ -20340,6 +20473,104 @@ components:
and it is the more flattering of the two to print by accident in the
abstention column and the more damning in the agreement column.'
+ AiAssetListResponse:
+ properties:
+ items:
+ items:
+ $ref: '#/components/schemas/AiAssetModel'
+ type: array
+ title: Items
+ total:
+ type: integer
+ title: Total
+ observedSources:
+ items:
+ type: string
+ type: array
+ title: Observedsources
+ type: object
+ required:
+ - items
+ - total
+ title: AiAssetListResponse
+ AiAssetModel:
+ properties:
+ id:
+ type: string
+ title: Id
+ kind:
+ type: string
+ title: Kind
+ externalId:
+ type: string
+ title: Externalid
+ displayName:
+ anyOf:
+ - type: string
+ - type: 'null'
+ title: Displayname
+ vendor:
+ anyOf:
+ - type: string
+ - type: 'null'
+ title: Vendor
+ discoverySource:
+ type: string
+ title: Discoverysource
+ principal:
+ anyOf:
+ - type: string
+ - type: 'null'
+ title: Principal
+ device:
+ anyOf:
+ - type: string
+ - type: 'null'
+ title: Device
+ effectivePermissions:
+ anyOf:
+ - additionalProperties: true
+ type: object
+ - type: 'null'
+ title: Effectivepermissions
+ attributes:
+ additionalProperties: true
+ type: object
+ title: Attributes
+ risk:
+ type: integer
+ title: Risk
+ riskReasons:
+ items:
+ type: string
+ type: array
+ title: Riskreasons
+ sanctioned:
+ anyOf:
+ - type: boolean
+ - type: 'null'
+ title: Sanctioned
+ firstSeen:
+ type: string
+ title: Firstseen
+ lastSeen:
+ type: string
+ title: Lastseen
+ observationCount:
+ type: integer
+ title: Observationcount
+ type: object
+ required:
+ - id
+ - kind
+ - externalId
+ - discoverySource
+ - risk
+ - firstSeen
+ - lastSeen
+ - observationCount
+ title: AiAssetModel
+ description: One asset as the console sees it.
AirgapStatus:
properties:
ready:
@@ -34591,6 +34822,25 @@ components:
- scenarios
- note
title: SampleDataResponse
+ SanctionRequest:
+ properties:
+ sanctioned:
+ anyOf:
+ - type: boolean
+ - type: 'null'
+ title: Sanctioned
+ description: true = approved, false = reviewed and refused, null = back
+ to undecided. The three are distinct.
+ note:
+ anyOf:
+ - type: string
+ maxLength: 500
+ - type: 'null'
+ title: Note
+ type: object
+ required:
+ - sanctioned
+ title: SanctionRequest
SandboxResultResponse:
properties:
outcome:
diff --git a/scripts/check_ai_asset_inventory.py b/scripts/check_ai_asset_inventory.py
index fa7e4ea8f..a96cabd70 100644
--- a/scripts/check_ai_asset_inventory.py
+++ b/scripts/check_ai_asset_inventory.py
@@ -338,8 +338,7 @@ def _check_graph(root: Path) -> list[str]:
failures.append(f"GRAPH: NodeAIAsset is not in AllNodeLabels in {GRAPH_GO}, so no consumer enumerates it.")
if "NodeAIAsset" not in extractor:
failures.append(
- f"GRAPH: {EXTRACTOR_GO} never emits an {GRAPH_LABEL} node. The label would exist in the vocabulary "
- f"and in no database."
+ f"GRAPH: {EXTRACTOR_GO} never emits an {GRAPH_LABEL} node. The label would exist in the vocabulary and in no database."
)
return failures
@@ -521,7 +520,11 @@ def main() -> int:
print(f"\n{len(failures)} problem(s) across {len(RULES)} rule(s).", file=sys.stderr)
return 1
- print(f"OK — {TABLE} created with forced RLS, authorized routes, a writer on the fusion path, {len(REQUIRED_KINDS)} asset kinds, a graph label emitted at ingest, and a console page.")
+ print(
+ f"OK — {TABLE} created with forced RLS, authorized routes, a writer on the "
+ f"fusion path, {len(REQUIRED_KINDS)} asset kinds, a graph label emitted at "
+ f"ingest, and a console page."
+ )
return 0
diff --git a/services/api/app/api/v1/endpoints/ai_assets.py b/services/api/app/api/v1/endpoints/ai_assets.py
index 64a6878a9..a3f92bcbe 100644
--- a/services/api/app/api/v1/endpoints/ai_assets.py
+++ b/services/api/app/api/v1/endpoints/ai_assets.py
@@ -139,16 +139,8 @@ async def list_ai_assets(
count_stmt = count_stmt.where(AiAsset.principal.is_(None))
total = len((await db.execute(count_stmt)).scalars().all())
- sources = sorted(
- {
- s
- for s in (
- await db.execute(select(AiAsset.discovery_source).where(AiAsset.tenant_id == current_user.tenant_id).distinct())
- )
- .scalars()
- .all()
- }
- )
+ source_rows = await db.execute(select(AiAsset.discovery_source).where(AiAsset.tenant_id == current_user.tenant_id).distinct())
+ sources = sorted(set(source_rows.scalars().all()))
return AiAssetListResponse(items=[_to_model(r) for r in rows], total=total, observedSources=sources)
diff --git a/services/fusion/app/main.py b/services/fusion/app/main.py
index 33a68cd64..b0d511ecc 100644
--- a/services/fusion/app/main.py
+++ b/services/fusion/app/main.py
@@ -12,6 +12,7 @@ from app.core.config import settings
from app.core.logging import configure_logging, logger
from app.memory.provider import MemoryPriorProvider
from app.services import ioc_match
+from app.services.ai_asset_recorder import AiAssetRecorder
from app.services.alert_enricher import AlertEnricher
from app.services.alert_sink import AlertSink
from app.services.attack_chain_grouper import AttackChainGrouper
@@ -21,7 +22,6 @@ from app.services.deduplicator import Deduplicator
from app.services.detection_engine import DetectionEngine
from app.services.dlq_sink import PostgresDLQ
from app.services.entity_risk import EntityRiskEngine
-from app.services.ai_asset_recorder import AiAssetRecorder
from app.services.first_seen import FirstSeenStore
from app.services.fusion_engine import FusionEngine
from app.services.ioc_match import TenantIocMatcher
diff --git a/services/fusion/tests/test_ai_asset_recorder.py b/services/fusion/tests/test_ai_asset_recorder.py
index c6bacffa2..0f4b69618 100644
--- a/services/fusion/tests/test_ai_asset_recorder.py
+++ b/services/fusion/tests/test_ai_asset_recorder.py
@@ -21,8 +21,8 @@ from app.services.ai_asset_recorder import (
ALL_KINDS,
CODING_AGENT_PROCESSES,
AiAssetRecorder,
- _Sighting,
_score,
+ _Sighting,
classify,
)
@@ -105,9 +105,7 @@ def test_an_unrecognised_agent_binary_is_an_ai_app_not_a_coding_agent():
An agent we cannot place is an `ai_app`. Calling it a coding agent would
put a vendor name on a row we have no evidence for.
"""
- event = runtime_event(
- actor={"process": {"name": "svc-42", "path": "/opt/inhouse/summariser"}, "user": {"name": "[email protected]"}}
- )
+ event = runtime_event(actor={"process": {"name": "svc-42", "path": "/opt/inhouse/summariser"}, "user": {"name": "[email protected]"}})
agents = [s for s in classify(event) if s.kind in ("coding_agent", "ai_app")]
assert [s.kind for s in agents] == ["ai_app"]
assert agents[0].vendor == "anthropic"