Security fixes: P0-P2 complete (22 fixes)
P0 (7): Auth-bypass removed, migrations fixed, plugin-upload disabled, RLS FORCE+WITH CHECK, plugin double-registration fixed, persistent volume, domain removed P1 (11): User/tenant model, Redis centralized, worker separated, transactional outbox, XSS fixed, DMS chunked streaming, permissions unified, password reset, metrics secured, config/docs fixed, cross-tenant FK P2 (4): Contact model normalized, cross-imports reduced 94%, commands+state machines for contacts/dms/mail/calendar, SPA path-traversal 8 new migrations, 99 unit tests, 13 commands, 8 contracts, 72 files changed
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""Public contract for the mail plugin.
|
||||
|
||||
Exposes only the symbols that other builtins plugins need.
|
||||
Currently the only cross-plugin consumer is ai_proactive, which imports
|
||||
the ``Mail`` model for querying recent emails by contact.
|
||||
|
||||
Importers should use::
|
||||
|
||||
from app.plugins.builtins.contracts import get_contract
|
||||
mail = get_contract("mail")
|
||||
if mail:
|
||||
result = await db.execute(select(mail.Mail).where(...))
|
||||
|
||||
instead of importing from internal modules directly.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.plugins.builtins.contracts import get_contract_registry
|
||||
from app.plugins.builtins.mail.models import Mail
|
||||
|
||||
|
||||
class MailContract:
|
||||
"""Public API surface for the mail plugin.
|
||||
|
||||
Exposes the ``Mail`` ORM model so that other plugins can query the
|
||||
mails table without importing from ``mail.models`` directly.
|
||||
"""
|
||||
|
||||
contract_name = "mail"
|
||||
|
||||
# ─── models ───
|
||||
Mail = Mail
|
||||
|
||||
|
||||
# ─── self-registration ───
|
||||
|
||||
_contract = MailContract()
|
||||
get_contract_registry().register("mail", _contract)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"MailContract",
|
||||
"Mail",
|
||||
]
|
||||
@@ -1477,7 +1477,10 @@ async def create_event_from_mail(
|
||||
account = await _get_account(db, mail.account_id, tenant_id, user_id)
|
||||
await _check_delegate_access(db, account, user_id, "write")
|
||||
try:
|
||||
from app.plugins.builtins.calendar.models import Calendar, CalendarEntry
|
||||
from app.plugins.builtins.calendar.contracts import get_contract as get_calendar_contract
|
||||
_cal = get_calendar_contract()
|
||||
Calendar = _cal.Calendar
|
||||
CalendarEntry = _cal.CalendarEntry
|
||||
except ImportError:
|
||||
return {"created": False, "error": "Calendar plugin not available"}
|
||||
cal_id = _parse_uuid(data.calendar_id, "calendar_id")
|
||||
|
||||
Reference in New Issue
Block a user