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: add connectors schema migration and allow 'network' category in tests

Beenu Arorabdbb7a6b085e
diff --git a/services/api/migrations/025_connectors_click_and_connect.sql b/services/api/migrations/025_connectors_click_and_connect.sql
new file mode 100644
index 000000000..1aa65b4ef
--- /dev/null
+++ b/services/api/migrations/025_connectors_click_and_connect.sql
@@ -0,0 +1,31 @@
+-- 025_connectors_click_and_connect.sql
+-- Align the connectors DDL with the evolved ORM model (Connector in
+-- services/api/app/models/connector.py) used by the click-and-connect feature.
+
+BEGIN;
+
+-- Rename columns that changed semantics
+ALTER TABLE connectors RENAME COLUMN config TO connector_config;
+ALTER TABLE connectors RENAME COLUMN credentials_enc TO auth_config;
+ALTER TABLE connectors RENAME COLUMN status TO health_status;
+ALTER TABLE connectors RENAME COLUMN last_sync_at TO last_sync;
+
+-- Resize the health_status column to match the ORM (VARCHAR 20)
+ALTER TABLE connectors ALTER COLUMN health_status TYPE VARCHAR(20);
+ALTER TABLE connectors ALTER COLUMN health_status SET DEFAULT 'unknown';
+
+-- Add new columns introduced by the ORM
+ALTER TABLE connectors ADD COLUMN IF NOT EXISTS category VARCHAR(50) NOT NULL DEFAULT '';
+ALTER TABLE connectors ADD COLUMN IF NOT EXISTS last_health_check TIMESTAMPTZ;
+ALTER TABLE connectors ADD COLUMN IF NOT EXISTS error_count INTEGER DEFAULT 0;
+ALTER TABLE connectors ADD COLUMN IF NOT EXISTS tags JSONB DEFAULT '[]';
+
+-- Drop columns the ORM no longer uses
+ALTER TABLE connectors DROP COLUMN IF EXISTS vendor;
+ALTER TABLE connectors DROP COLUMN IF EXISTS description;
+ALTER TABLE connectors DROP COLUMN IF EXISTS last_error;
+
+-- Index on connector_type for catalog lookups
+CREATE INDEX IF NOT EXISTS idx_connectors_type ON connectors(connector_type);
+
+COMMIT;
diff --git a/services/connectors/tests/test_schemas.py b/services/connectors/tests/test_schemas.py
index 456a7a4c0..032d65b61 100644
--- a/services/connectors/tests/test_schemas.py
+++ b/services/connectors/tests/test_schemas.py
@@ -12,7 +12,7 @@ import pytest
from app.connectors import CONNECTOR_REGISTRY, list_connector_schemas
from app.connectors.base import BaseConnector, ConnectorSchema, Field
-ALLOWED_CATEGORIES = {"siem", "edr", "cloud", "iam", "saas", "audit", "vcs", "ndr"}
+ALLOWED_CATEGORIES = {"siem", "edr", "cloud", "iam", "saas", "audit", "vcs", "ndr", "network"}
ALLOWED_FIELD_TYPES = {"string", "secret", "select", "textarea", "boolean", "number"}