Require explicit project trust in non-interactive runs (#60041)

## What changed

Keep untrusted project configuration and MCP servers disabled in exec runs, even with `--sandbox workspace-write`, and warn when project configuration is disabled.

Add `--trust` to `codex exec` and `codex review` to save project trust for the current and future chats, including MCP commands outside the sandbox. The grant persists with `--ephemeral`, refuses explicitly untrusted projects, and cannot be combined with `--ignore-user-config`.

Pass the working directory as a configuration default so embedded server startup does not implicitly grant trust. Preserve the selected `--oss` provider across configuration reloads.

## Testing

Extend CLI parsing and MCP integration coverage for explicit trust, persistence across ephemeral runs, disabled project configuration with write access, and rejection of conflicting or explicitly untrusted settings.

GitOrigin-RevId: b57f4f8829f98d77c5487fa8405c7f29b5d70d0c
This commit is contained in:
Eric Traut
2026-11-07 02:39:03 +00:00
committed by copyberry
parent 762f87d5bb
commit 11ca3f7531
7 changed files with 193 additions and 69 deletions
+5
View File
@@ -37,6 +37,11 @@ pub struct Cli {
#[arg(long = "skip-git-repo-check", global = true, default_value_t = false)]
pub skip_git_repo_check: bool,
/// Save trust for this project and future chats, including MCP commands outside the sandbox.
/// Persists even with --ephemeral. Does not override an explicitly untrusted project.
#[arg(long, global = true)]
pub trust: bool,
/// Run without persisting session files to disk.
#[arg(long = "ephemeral", global = true, default_value_t = false)]
pub ephemeral: bool,