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(compose): make full stack boot — quote reserved "window" column + ship pydantic[email] (#227)

Beenu Arora4a4d01742e49
diff --git a/services/api/Dockerfile b/services/api/Dockerfile
index fb3d76cac..0205c1232 100644
--- a/services/api/Dockerfile
+++ b/services/api/Dockerfile
@@ -36,7 +36,7 @@ RUN set -eux; \
pip install --no-cache-dir \
"fastapi>=0.111,<0.112" \
"uvicorn[standard]>=0.29,<0.30" \
- "pydantic>=2.7,<2.11" \
+ "pydantic[email]>=2.7,<2.14" \
"pydantic-settings>=2.2,<3" \
"sqlalchemy[asyncio]>=2.0.30,<3" \
"asyncpg>=0.29,<0.32" \
diff --git a/services/api/app/api/v1/endpoints/attack_chain.py b/services/api/app/api/v1/endpoints/attack_chain.py
index 118d92fac..3bb57317c 100644
--- a/services/api/app/api/v1/endpoints/attack_chain.py
+++ b/services/api/app/api/v1/endpoints/attack_chain.py
@@ -140,7 +140,7 @@ async def get_attack_chain(
text(
"""
INSERT INTO aisoc_attack_chains (
- tenant_id, seed_alert_id, case_id, window,
+ tenant_id, seed_alert_id, case_id, "window",
chain, entity_graph, chain_signature, confidence,
updated_at
) VALUES (
@@ -148,7 +148,7 @@ async def get_attack_chain(
CAST(:chain AS JSONB), CAST(:entity_graph AS JSONB),
:signature, :confidence, NOW()
)
- ON CONFLICT (tenant_id, seed_alert_id, window, chain_signature)
+ ON CONFLICT (tenant_id, seed_alert_id, "window", chain_signature)
DO UPDATE SET
case_id = EXCLUDED.case_id,
chain = EXCLUDED.chain,
diff --git a/services/api/migrations/041_attack_chains.sql b/services/api/migrations/041_attack_chains.sql
index 5d43525ba..a3593307d 100644
--- a/services/api/migrations/041_attack_chains.sql
+++ b/services/api/migrations/041_attack_chains.sql
@@ -56,7 +56,10 @@ CREATE TABLE IF NOT EXISTS aisoc_attack_chains (
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
seed_alert_id UUID NOT NULL,
case_id UUID,
- window VARCHAR(8) NOT NULL,
+ -- "window" is a reserved keyword in Postgres; it must be quoted
+ -- everywhere it is used as an identifier (column def, constraints,
+ -- and in the application's INSERT/ON CONFLICT statements).
+ "window" VARCHAR(8) NOT NULL,
chain JSONB NOT NULL DEFAULT '[]'::jsonb,
entity_graph JSONB NOT NULL DEFAULT '{}'::jsonb,
chain_signature VARCHAR(64) NOT NULL,
@@ -64,9 +67,9 @@ CREATE TABLE IF NOT EXISTS aisoc_attack_chains (
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT aisoc_attack_chains_window_check
- CHECK (window IN ('1h', '6h', '24h', '72h', '7d', '30d')),
+ CHECK ("window" IN ('1h', '6h', '24h', '72h', '7d', '30d')),
CONSTRAINT aisoc_attack_chains_unique_signature
- UNIQUE (tenant_id, seed_alert_id, window, chain_signature)
+ UNIQUE (tenant_id, seed_alert_id, "window", chain_signature)
);
CREATE INDEX IF NOT EXISTS aisoc_attack_chains_seed_idx
diff --git a/services/api/pyproject.toml b/services/api/pyproject.toml
index b73fc6f20..f06482008 100644
--- a/services/api/pyproject.toml
+++ b/services/api/pyproject.toml
@@ -10,7 +10,10 @@ readme = "README.md"
python = "^3.11"
fastapi = ">=0.111,<0.137"
uvicorn = { version = ">=0.29,<0.49", extras = ["standard"] }
-pydantic = ">=2.7,<2.14"
+# EmailStr (used in auth/passkeys/tenants endpoints) requires the optional
+# email-validator package, which is only pulled in via the "email" extra.
+# Without it the API crashes on import with "email-validator is not installed".
+pydantic = { version = ">=2.7,<2.14", extras = ["email"] }
pydantic-settings = "^2.2.1"
sqlalchemy = { version = "^2.0.30", extras = ["asyncio"] }
asyncpg = ">=0.29.0,<0.32"