fix: apply token path scope to apps that depend on a runnable
Summary
GET /api/w/{workspace}/apps/list_paths_from_workspace_runnable/{runnable_kind}/{path} returned the paths of every app that depends on a script or flow without applying the token's path scope. A token restricted with apps:read:<prefix> received app paths outside that prefix, even though apps/get for those paths returns 403. RLS still limited results to apps the token owner can read, so only out-of-scope paths leaked.
Changes
list_paths_from_workspace_runnable(backend/windmill-api/src/apps.rs) filters its rows throughbuild_scope_path_predicate(&authed, "apps", "read"), aslist_search_appsalready does. Unscoped tokens and sessions are unaffected. The endpoint is not paginated, so filtering after the fetch reveals nothing through page sizes.- Regression test
backend/tests/app_runnable_paths_scope.rs: an unscoped token sees both dependent apps, anapps:read:u/test-user/*token sees only the one in scope. It fails without the fix.
Out of scope, noted for follow-up: the scripts and flows variants of list_paths_from_workspace_runnable (and list_paths_linking_agent) don't filter their returned paths by the token's path scope either.
Test plan
-
cargo test --features quickjs --test app_runnable_paths_scopepasses, and fails with the handler change reverted - On the running dev instance: two apps depending on
u/admin/sinf/allowedandf/other; an unscoped token gets["f/allowed/app1","f/other/app2"], anapps:read:f/allowed/*token gets["f/allowed/app1"]
Left in draft: touches a token-scope (auth) path, wants a human look before ready.
š¤ Generated with Claude Code
Summary by cubic
Fixes GET /apps/list_paths_from_workspace_runnable so tokens restricted with apps:read:<prefix> no longer receive app paths outside that prefix. Previously the endpoint returned out-of-scope paths even though apps/get on the same paths returns 403; RLS still limited results to apps the token owner can read.
- Filters returned rows through
build_scope_path_predicate, matching whatlist_search_appsalready does. - Adds a regression test covering both an unscoped token (sees all dependent apps) and an
apps:read:u/test-user/*token (sees only in-scope apps). - The scripts and flows variants of this endpoint, and
list_paths_linking_agent, still don't filter by token path scope; noted for follow-up.