P0+P1 fixes: RCE sandbox, SQL injection, RLS tenant isolation, DB roles, test syntax, attachment, permission registry, membership check
Check Cross-Plugin Imports / check (push) Has been cancelled

This commit is contained in:
Agent Zero
2026-07-29 12:28:08 +02:00
parent 81ae5b7cb6
commit 26bf8d3a31
12 changed files with 423 additions and 39 deletions
+10
View File
@@ -47,8 +47,18 @@ async def save_attachment(
filename: str,
file_content: bytes,
mime_type: str,
is_system_admin: bool = False,
) -> dict[str, Any]:
"""Save a file to storage and create an Attachment record."""
# Check access on parent entity
if not is_system_admin:
from app.core.visibility import check_single_entity_access
has_access = await check_single_entity_access(
db, entity_type, entity_id, user_id, tenant_id, "write", is_system_admin
)
if not has_access:
raise PermissionError(f"No write access to {entity_type} {entity_id}")
# Generate unique filename and relative storage path
unique_filename = _generate_unique_filename(filename)
file_path = f"{entity_type}/{entity_id}/{unique_filename}"