fix(security): isolate allowlisted execution broker
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m9s
CD Pipeline / build-and-deploy (push) Successful in 4m35s
CD Pipeline / post-deploy-checks (push) Successful in 1m49s

This commit is contained in:
ogt
2026-07-11 01:04:23 +08:00
parent 40e3e281c3
commit c185d7544b
21 changed files with 1883 additions and 331 deletions

View File

@@ -29,6 +29,7 @@ from sqlalchemy.ext.asyncio import (
create_async_engine,
)
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.pool import NullPool
from src.core.config import settings
from src.core.context import get_current_project_context
@@ -87,14 +88,21 @@ def get_engine() -> AsyncEngine:
"Set DATABASE_URL to PostgreSQL: postgresql+asyncpg://user:pass@host:5432/db"
)
_engine = create_async_engine(
database_url,
echo=settings.DEBUG,
pool_size=settings.DATABASE_POOL_SIZE,
max_overflow=settings.DATABASE_MAX_OVERFLOW,
pool_timeout=settings.DATABASE_POOL_TIMEOUT_SECONDS,
pool_pre_ping=True,
)
engine_kwargs: dict[str, object] = {
"echo": settings.DEBUG,
"pool_pre_ping": True,
}
if settings.DATABASE_NULL_POOL:
engine_kwargs["poolclass"] = NullPool
else:
engine_kwargs.update(
{
"pool_size": settings.DATABASE_POOL_SIZE,
"max_overflow": settings.DATABASE_MAX_OVERFLOW,
"pool_timeout": settings.DATABASE_POOL_TIMEOUT_SECONDS,
}
)
_engine = create_async_engine(database_url, **engine_kwargs)
return _engine