Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(authorization): keep remote edits metadata-only

Maxd19e261fd67a
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index 05b97d220..d431e5e5e 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -1150,6 +1150,8 @@ def test_remote_runtime_snapshots_are_blocked_before_controller_access(monkeypat
{"model": "gpt-5"},
{"reasoning_effort": "high"},
{"scope_id": "scope-local"},
+ {"visibility": "background"},
+ {"pinned": True},
],
)
def test_remote_session_execution_settings_are_blocked_before_store_access(
@@ -1406,6 +1408,12 @@ def test_remote_session_and_project_metadata_predicates_remain_allowed():
assert not ui_server._is_remote_local_execution_request(
"PATCH", "/api/sessions/ses-local", {"title": "renamed"}
)
+ assert ui_server._is_remote_local_execution_request(
+ "PATCH", "/api/sessions/ses-local", {"visibility": "background"}
+ )
+ assert ui_server._is_remote_local_execution_request(
+ "PATCH", "/api/sessions/ses-local", {"pinned": True}
+ )
assert not ui_server._is_remote_local_execution_request(
"PATCH", "/api/projects/proj-local", {"display_name": "renamed"}
)
@@ -2014,6 +2022,52 @@ def test_remote_skill_operations_are_blocked_before_api_calls(
assert response.get_json()["code"] == "remote_execution_disabled"
+def test_remote_project_scoped_skill_reads_require_project_access(
+ monkeypatch,
+ tmp_path,
+):
+ from storage import project_access_service, projects_service
+ from storage.db import create_sqlite_engine
+ from storage.importer import ensure_sqlite_state
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _save_config(tmp_path)
+ ensure_sqlite_state()
+ engine = create_sqlite_engine()
+ folder = tmp_path / "project"
+ folder.mkdir()
+ with engine.begin() as conn:
+ project = projects_service.create_project(conn, str(folder), display_name="Restricted")
+ project_access_service.apply_project_access_intent(
+ conn,
+ {
+ "project_id": project["id"],
+ "revision": 1,
+ "mode": "restricted",
+ "bindings": [],
+ },
+ )
+ client = app.test_client()
+ client.set_cookie(
+ remote_access.SESSION_COOKIE_NAME,
+ remote_session_cookie(config, "[email protected]", "user-owner", role="editor"),
+ domain="alex.avibe.bot",
+ )
+
+ async def unexpected_list(*args, **kwargs):
+ raise AssertionError("restricted remote skill read reached the Skills API")
+
+ monkeypatch.setattr(api, "list_skills", unexpected_list)
+ response = client.get(
+ f"/api/skills?scope=project&project_id={project['id']}",
+ base_url="https://alex.avibe.bot",
+ environ_base=_remote_peer(),
+ )
+
+ assert response.status_code == 404
+ assert response.get_json()["error"]["code"] == "project_not_found"
+
+
@pytest.mark.parametrize(
("method", "path", "json_body", "api_method"),
[
diff --git a/tests/test_ui_server_skills_routes.py b/tests/test_ui_server_skills_routes.py
index 56cb1cbf2..5d8b870a0 100644
--- a/tests/test_ui_server_skills_routes.py
+++ b/tests/test_ui_server_skills_routes.py
@@ -52,6 +52,42 @@ def test_list_degrades_to_global_with_flag(folderless, monkeypatch):
assert body["skills"][0]["scope"] == "global"
+def test_resolve_project_dir_uses_request_authorization_context(monkeypatch):
+ from vibe.authorization import AuthorizationContext
+ from vibe.ui_compat import g
+
+ seen = {}
+
+ class _Engine:
+ class _Connection:
+ def __enter__(self):
+ return object()
+
+ def __exit__(self, *_exc_info):
+ return False
+
+ def connect(self):
+ return self._Connection()
+
+ def fake_get_project(conn, project_id, *, authorization_context=None):
+ seen["project_id"] = project_id
+ seen["authorization_context"] = authorization_context
+ return {"folder_path": "/tmp/project"}
+
+ monkeypatch.setattr(ui_server, "_projects_engine", lambda: _Engine())
+ monkeypatch.setattr("storage.projects_service.get_project", fake_get_project)
+ remote_context = AuthorizationContext(instance_role="editor", is_remote=True, subject="user-1")
+
+ with app.test_request_context("/api/skills?project_id=proj-restricted"):
+ g.authorization_context = remote_context
+ assert ui_server._resolve_project_dir("proj-restricted") == "/tmp/project"
+
+ assert seen == {
+ "project_id": "proj-restricted",
+ "authorization_context": remote_context,
+ }
+
+
def test_check_returns_empty(folderless, monkeypatch):
monkeypatch.setattr(api, "check_skills", _boom)
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 8763f86bf..a8daefd76 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -2406,7 +2406,7 @@ def _remote_payload_is_allowed(method: str, path: str, payload: Any) -> bool:
if normalized_method == "POST" and path == "/api/sessions":
return _payload_has_only_fields(payload, {"project_id", "title"})
if normalized_method == "PATCH" and re.fullmatch(r"/api/sessions/[^/]+", path):
- return _payload_has_only_fields(payload, {"pinned", "title", "visibility"})
+ return _payload_has_only_fields(payload, {"title"})
if normalized_method == "PATCH" and re.fullmatch(r"/api/projects/[^/]+", path):
return _payload_has_only_fields(payload, {"display_name"})
if normalized_method == "POST" and path == "/api/projects":
@@ -7669,14 +7669,23 @@ def _resolve_project_dir(project_id):
an unknown id (→ 404) and _ProjectNoFolder when the project's folder is
unset/blank, so callers can degrade gracefully rather than passing an empty
cwd to askill (which would surface as a raw ``project folder not found:``).
+
+ Project-scoped skill routes are remote-readable, so the project lookup must
+ carry the current request's authorization context; a resource ACL on the
+ skill is an additional gate, not a substitute for Project access.
"""
if not project_id:
return None
from storage import projects_service
+ authorization_context = getattr(g, "authorization_context", None)
engine = _projects_engine()
with engine.connect() as conn:
- project = projects_service.get_project(conn, project_id)
+ project = projects_service.get_project(
+ conn,
+ project_id,
+ authorization_context=authorization_context,
+ )
folder = (project.get("folder_path") or "").strip()
if not folder:
raise _ProjectNoFolder(project_id)