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.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
fix(lake-jobs-live): run the suite as the runtime role, not the superuser
Beenu Aroraa4d8282f4325
diff --git a/.github/workflows/lake-query-jobs-live.yml b/.github/workflows/lake-query-jobs-live.ymlindex d0efbdde8..1bd012ba8 100644--- a/.github/workflows/lake-query-jobs-live.yml+++ b/.github/workflows/lake-query-jobs-live.yml@@ -50,7 +50,14 @@ jobs:--health-retries 20env:- LAKE_JOB_DSN: postgresql+asyncpg://aisoc:aisoc_ci_only@localhost:5432/aisoc+ # The runtime role, not the owner. POSTGRES_USER (aisoc) is a+ # superuser and ignores every RLS policy even under FORCE ROW LEVEL+ # SECURITY, so a suite proving a job id is tenant-scoped while+ # connected as it would pass with migration 111's policy deleted.+ LAKE_JOB_DSN: postgresql+asyncpg://aisoc_app:aisoc_app_ci_only@localhost:5432/aisoc+ # The owner, used only for migrations and to seed the fixture's two+ # tenants — rows the runtime role is correctly not allowed to write.+ LAKE_DATABASE_MIGRATION_URL: postgresql+asyncpg://aisoc:aisoc_ci_only@localhost:5432/aisocPGPASSWORD: aisoc_ci_onlyENVIRONMENT: testSECRET_KEY: ci-lake-job-signing-secret-at-least-32-chars@@ -82,6 +89,14 @@ jobs:# progress_ratio must be nullable. NOT NULL would force a zero where# the honest answer is unknown, and a progress bar that renders a# forced zero as 0% is as wrong as one that renders it as 100%.+ - name: Give the runtime role its password+ run: |+ set -euo pipefail+ psql -h localhost -U aisoc -d aisoc -v ON_ERROR_STOP=1 -q -c \+ "ALTER ROLE aisoc_app WITH PASSWORD 'aisoc_app_ci_only';"+ psql -h localhost -U aisoc -d aisoc -v ON_ERROR_STOP=1 -q -c \+ "GRANT USAGE ON SCHEMA public TO aisoc_app;"+- name: progress_ratio is nullablerun: |set -euo pipefail@@ -98,6 +113,7 @@ jobs:working-directory: services/apienv:ISOLATION_LAKE_JOB_DSN: ${{ env.LAKE_JOB_DSN }}+ ISOLATION_LAKE_JOB_ADMIN_DSN: ${{ env.LAKE_DATABASE_MIGRATION_URL }}DATABASE_URL: ${{ env.LAKE_JOB_DSN }}run: python -m pytest ../../tests/isolation/test_lake_query_jobs_live.py -v --tb=short@@ -105,6 +121,7 @@ jobs:working-directory: services/apienv:ISOLATION_LAKE_JOB_DSN: ${{ env.LAKE_JOB_DSN }}+ ISOLATION_LAKE_JOB_ADMIN_DSN: ${{ env.LAKE_DATABASE_MIGRATION_URL }}DATABASE_URL: ${{ env.LAKE_JOB_DSN }}run: |set -euo pipefail@@ -128,6 +145,7 @@ jobs:working-directory: services/apienv:ISOLATION_LAKE_JOB_DSN: ${{ env.LAKE_JOB_DSN }}+ ISOLATION_LAKE_JOB_ADMIN_DSN: ${{ env.LAKE_DATABASE_MIGRATION_URL }}DATABASE_URL: ${{ env.LAKE_JOB_DSN }}run: |set -euo pipefaildiff --git a/tests/isolation/test_lake_query_jobs_live.py b/tests/isolation/test_lake_query_jobs_live.pyindex d2d172a9f..704436558 100644--- a/tests/isolation/test_lake_query_jobs_live.py+++ b/tests/isolation/test_lake_query_jobs_live.py@@ -56,6 +56,31 @@ async def engine():await eng.dispose()+def _admin_dsn() -> str:+ """The owner connection, used only to seed and tear down fixtures.++ The suite runs as the DML-only runtime role, because a suite proving+ a job id is tenant-scoped while connected as a superuser would pass+ with the RLS policy removed. The runtime role cannot insert a+ tenant, so the fixture needs the owner and nothing else does.+ """+ value = os.environ.get("ISOLATION_LAKE_JOB_ADMIN_DSN", "").strip() or _dsn()+ if value.startswith("postgresql://"):+ return value.replace("postgresql://", "postgresql+asyncpg://", 1)+ return value+++@pytest_asyncio.fixture(scope="module", loop_scope="module")+async def admin_engine():+ from sqlalchemy.ext.asyncio import create_async_engine++ eng = create_async_engine(_admin_dsn())+ try:+ yield eng+ finally:+ await eng.dispose()++@pytest_asyncio.fixture(scope="module", loop_scope="module")async def session_factory(engine):from sqlalchemy.ext.asyncio import async_sessionmaker@@ -64,18 +89,18 @@ async def session_factory(engine):@pytest_asyncio.fixture(scope="module", loop_scope="module")-async def tenants(engine):+async def tenants(admin_engine):from sqlalchemy import texta, b = uuid.uuid4(), uuid.uuid4()- async with engine.begin() as conn:+ async with admin_engine.begin() as conn:for tid, slug in ((a, "lakejob-a"), (b, "lakejob-b")):await conn.execute(text("INSERT INTO tenants (id, name, slug) VALUES (:id, :n, :s)"),{"id": str(tid), "n": slug, "s": f"{slug}-{uuid.uuid4().hex[:8]}"},)yield a, b- async with engine.begin() as conn:+ async with admin_engine.begin() as conn:for tid in (a, b):await conn.execute(text("DELETE FROM tenants WHERE id = :id"), {"id": str(tid)})