Skip to content

Compare discriminants when checking modes/permissions#200

Open
josevalim wants to merge 1 commit intozed-industries:mainfrom
josevalim:jv-workspace
Open

Compare discriminants when checking modes/permissions#200
josevalim wants to merge 1 commit intozed-industries:mainfrom
josevalim:jv-workspace

Conversation

@josevalim
Copy link
Copy Markdown
Contributor

The APPROVAL_PRESETS have this shape:

preset id="read-only" approval=OnRequest sandbox=ReadOnly { access: FullAccess, network_access: false }

preset id="auto" approval=OnRequest sandbox=WorkspaceWrite { writable_roots: [], read_only_access: FullAccess, network_access: false, exclude_tmpdir_env_var: false, exclude_slash_tmp: false }

preset id="full-access" approval=Never sandbox=DangerFullAccess

However, the config permission sandbox, whenever a directory is trusted, has this shape:

approval_policy=OnRequest
sandbox_policy=WorkspaceWrite { writable_roots: [AbsolutePathBuf("/Users/jose/.codex/memories")], read_only_access: FullAccess, network_access: false, exclude_tmpdir_env_var: false, exclude_slash_tmp: false }

As you can see, the WorkspaceWrite is not going to match, because the struct has some information filled in. Therefore, we only check the names themselves.

Closes #194.

The APPROVAL_PRESETS have this shape:

    preset id="read-only" approval=OnRequest sandbox=ReadOnly { access: FullAccess, network_access: false }

    preset id="auto" approval=OnRequest sandbox=WorkspaceWrite { writable_roots: [], read_only_access: FullAccess, network_access: false, exclude_tmpdir_env_var: false, exclude_slash_tmp: false }

    preset id="full-access" approval=Never sandbox=DangerFullAccess

However, the config permission sandbox, whenever a directory
is trusted, has this shape:

    approval_policy=OnRequest
    sandbox_policy=WorkspaceWrite { writable_roots: [AbsolutePathBuf("/Users/jose/.codex/memories")], read_only_access: FullAccess, network_access: false, exclude_tmpdir_env_var: false, exclude_slash_tmp: false }

As you can see, the WorkspaceWrite is not going to match,
because the struct has some information filled in. Therefore,
we only check the names themselves.

Closes zed-industries#194.
@josevalim
Copy link
Copy Markdown
Contributor Author

Btw, this happens based on cwd that ACP itself is started. So if you always start acp in the directory the project is running, and that directory is trusted, it will trigger this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex trusted-working-directory behavior bypasses the ACP permission callback entirely

1 participant