Files
codex/codex-rs/mcp-server/tests/common/responses.rs
T
jif 942af8447b Retire the untrusted approval policy (#39630)
## What changed

- Remove `untrusted` from the CLI, configuration schema, and MCP tool interface. Explicit `approval_policy = "untrusted"` settings now fail with an actionable error.
- Remove the known-safe command allowlist. Projects marked untrusted now request approval for every command unless an explicit exec policy rule allows it.
- Keep command parsing conservative by treating in-place `sed` forms as mutating and ignoring unrecognized commands when recording memory usage.

## Testing

- Cover rejection of the retired configuration value and approval requests for commands in untrusted projects.

GitOrigin-RevId: d6bf425edddfffbb325eee6acf383434af5fd33b
2026-08-20 07:03:02 +00:00

50 lines
1.7 KiB
Rust

use std::path::Path;
use core_test_support::responses;
use serde_json::json;
pub fn create_shell_command_sse_response(
command: Vec<String>,
workdir: Option<&Path>,
timeout_ms: Option<u64>,
call_id: &str,
) -> anyhow::Result<String> {
let command_str = shlex::try_join(command.iter().map(String::as_str))?;
let arguments = serde_json::to_string(&json!({
"command": command_str,
"workdir": workdir.map(|w| w.to_string_lossy()),
"timeout_ms": timeout_ms,
"sandbox_permissions": "require_escalated",
"justification": "Test approval request.",
}))?;
let response_id = format!("resp-{call_id}");
Ok(responses::sse(vec![
responses::ev_response_created(&response_id),
responses::ev_function_call(call_id, "shell_command", &arguments),
responses::ev_completed(&response_id),
]))
}
pub fn create_final_assistant_message_sse_response(message: &str) -> anyhow::Result<String> {
let response_id = "resp-final";
Ok(responses::sse(vec![
responses::ev_response_created(response_id),
responses::ev_assistant_message("msg-final", message),
responses::ev_completed(response_id),
]))
}
pub fn create_apply_patch_sse_response(
patch_content: &str,
call_id: &str,
) -> anyhow::Result<String> {
let command = format!("apply_patch <<'EOF'\n{patch_content}\nEOF");
let arguments = serde_json::to_string(&json!({ "command": command }))?;
let response_id = format!("resp-{call_id}");
Ok(responses::sse(vec![
responses::ev_response_created(&response_id),
responses::ev_function_call(call_id, "shell_command", &arguments),
responses::ev_completed(&response_id),
]))
}