Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix: let a macOS temp path through the live image URL check (#1066)

Ruben Lütkee868464216e8
diff --git a/tests/unit/live/test_composer_routes.py b/tests/unit/live/test_composer_routes.py
index 4fd5e072c7..539da5fdef 100644
--- a/tests/unit/live/test_composer_routes.py
+++ b/tests/unit/live/test_composer_routes.py
@@ -1,6 +1,7 @@
"""Live composer reuses uploads and targets only the selected active call."""
from types import SimpleNamespace
+from urllib.parse import parse_qs, unquote
import pytest
from fastapi import FastAPI
@@ -14,22 +15,53 @@ def attachment(tmp_path, name="note.txt", kind="text", detail="Attached document
folder = tmp_path / ".jarvis" / "drops"
folder.mkdir(parents=True, exist_ok=True)
(folder / name).write_bytes(b"image" if kind == "image" else b"document")
- return {"name": name, "reference": f'".jarvis/drops/{name}"', "kind": kind,
- "detail": detail, "described_by": "extraction", "note": ""}
+ return {
+ "name": name,
+ "reference": f'".jarvis/drops/{name}"',
+ "kind": kind,
+ "detail": detail,
+ "described_by": "extraction",
+ "note": "",
+ }
def test_live_uploads_keep_images_and_extract_documents_in_one_content_path(tmp_path):
- rows = _composer_attachments(str(tmp_path), [
- attachment(tmp_path), attachment(tmp_path, "shot.png", "image", "Screenshot"),
- ])
+ rows = _composer_attachments(
+ str(tmp_path),
+ [
+ attachment(tmp_path),
+ attachment(tmp_path, "shot.png", "image", "Screenshot"),
+ ],
+ )
assert len(rows) == 2
assert "Attached document contents" in rows[0][1][0]["text"]
assert rows[1][1][1]["type"] == "input_image"
assert rows[1][1][1]["image_url"].startswith("data:image/png;base64,")
assert rows[0][3]["name"] == "note.txt" and "url" not in rows[0][3]
assert rows[1][3]["name"] == "shot.png"
- assert rows[1][3]["url"].startswith("/api/agent-chat/attachments/file?")
- assert "private" not in rows[1][3]["url"]
+ url = rows[1][3]["url"]
+ assert url.startswith("/api/agent-chat/attachments/file?")
+ query = parse_qs(url.split("?", 1)[1])
+ assert query["reference"] == ['".jarvis/drops/shot.png"']
+ # The chat folder is the cwd. macOS keeps that folder under /private/var,
+ # so a ban on the word "private" fails there. The absolute image path stays out.
+ shown = unquote(url)
+ image = tmp_path / ".jarvis" / "drops" / "shot.png"
+ assert str(image) not in shown
+ assert str(image.resolve()) not in shown
+
+
+def test_live_image_url_allows_a_chat_folder_named_private(tmp_path):
+ """macOS temp lives under /private/var. That folder name is not a leaked file."""
+ root = tmp_path / "private" / "var"
+ root.mkdir(parents=True)
+ rows = _composer_attachments(str(root), [attachment(root, "shot.png", "image", "Screenshot")])
+ url = rows[0][3]["url"]
+ shown = unquote(url)
+ assert "private" in shown
+ image = root / ".jarvis" / "drops" / "shot.png"
+ assert str(image) not in shown
+ assert str(image.resolve()) not in shown
def test_live_upload_never_reads_a_foreign_file(tmp_path):
@@ -73,8 +105,12 @@ def test_route_delivers_on_the_existing_session_loop_and_rejects_stale_ids(tmp_p
with TestClient(app) as client:
client.portal.call(runtime.register, session)
assert client.get("/api/live/composer").json() == {"session_id": "existing-call"}
- body = {"session_id": "existing-call", "request_id": "request-one", "text": "Read it",
- "attachments": [attachment(tmp_path)]}
+ body = {
+ "session_id": "existing-call",
+ "request_id": "request-one",
+ "text": "Read it",
+ "attachments": [attachment(tmp_path)],
+ }
response = client.post("/api/live/composer", json=body)
assert response.status_code == 200, response.text
assert len(delivered) == 1 and delivered[0]["text"] == "Read it"
@@ -96,7 +132,9 @@ async def test_composer_uses_and_pins_existing_chat_binding_across_view_changes(
pinned = []
target = SimpleNamespace(session_id="bound-chat", surface="jarvis", cwd=str(tmp_path))
svc = SimpleNamespace(
- voice_session_continued=None, voice_chat_id="bound-chat", voice_chat_fresh=False,
+ voice_session_continued=None,
+ voice_chat_id="bound-chat",
+ voice_chat_fresh=False,
voice_call_chat=lambda call: None,
pin_voice_call=lambda call, chat: pinned.append((call, chat)),
store=SimpleNamespace(get_session=lambda identifier: target),