fix: add virus scanning to WorkspaceManager.write_file()

Defense in depth - scan content at the persistence layer regardless of
caller. Previously scanning was only at entry points (store_media_file,
WriteWorkspaceFileTool), which created a trust boundary.

Closes OPEN-2993
This commit is contained in:
Nick Tindle
2026-02-05 22:15:28 -06:00
parent 85b6520710
commit 0f5ac68b92

View File

@@ -22,6 +22,7 @@ from backend.data.workspace import (
soft_delete_workspace_file,
)
from backend.util.settings import Config
from backend.util.virus_scanner import scan_content_safe
from backend.util.workspace_storage import compute_file_checksum, get_workspace_storage
logger = logging.getLogger(__name__)
@@ -187,6 +188,9 @@ class WorkspaceManager:
f"{Config().max_file_size_mb}MB limit"
)
# Virus scan content before persisting (defense in depth)
await scan_content_safe(content, filename=filename)
# Determine path with session scoping
if path is None:
path = f"/{filename}"