improvement(execute): enforce workspace permissions on function file exports - #6427
Merged
Merged
Conversation
…exports Check the acting user's workspace access before a function execution uses a request-supplied workspaceId, and gate workspace file writes in the shared VFS writer so every caller is covered by default. Access is resolved once per request and threaded through the export path so the added check does not re-query per output file.
Contributor
Greptile SummaryThis PR enforces workspace permissions for function output exports and shared VFS writes while reusing request-scoped access results to avoid per-file authorization queries.
Confidence Score: 5/5The PR appears safe to merge, with workspace write authorization consistently enforced before export validation and mutation. The changed execution and shared-writer paths resolve effective workspace access, require write permission, and preserve authorization across batched writes without exposing an unauthorized mutation path.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/function/execute/route.ts | Adds request and export-path workspace authorization, threads resolved access through all output branches, and returns explicit denial responses. |
| apps/sim/lib/copilot/vfs/resource-writer.ts | Centralizes workspace write authorization in both target validation and file mutation operations. |
| apps/sim/lib/copilot/request/tools/files.ts | Resolves workspace access once per prepared output batch and safely passes it to the shared writer. |
| apps/sim/app/api/function/execute/route.test.ts | Adds coverage for direct workspace denial, read-only export denial, and workflow-derived workspace denial. |
| apps/sim/lib/copilot/vfs/resource-writer.test.ts | Adds coverage proving unauthorized and read-only users are rejected before file lookup or mutation. |
Sequence Diagram
sequenceDiagram
participant Caller
participant Execute as Function Execute Route
participant Authz as Workspace Access Resolver
participant Sandbox
participant Writer as Shared VFS Writer
Caller->>Execute: POST code, workspaceId/workflowId, outputs
Execute->>Authz: Check direct workspace access
Authz-->>Execute: WorkspaceAccess
Execute->>Sandbox: Execute function
Sandbox-->>Execute: Exported files
Execute->>Authz: Resolve export workspace write access
Authz-->>Execute: Writable access or denial
Execute->>Writer: Write file with resolved access
Writer->>Authz: Validate reusable access
Writer-->>Execute: Written file or access denial
Reviews (1): Last reviewed commit: "improvement(execute): enforce workspace ..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
workspaceIdType of Change
Testing
Unit tests added for the new checks; verified they fail without the fix. Full type-check and lint pass.
Checklist