Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Use path URIs in shell approval keys (#34806)

Adam Perry @ OpenAIa59a419afa34
diff --git a/codex-rs/core/src/tools/runtimes/shell.rs b/codex-rs/core/src/tools/runtimes/shell.rs
index 1d25672e92..ac8e020599 100644
--- a/codex-rs/core/src/tools/runtimes/shell.rs
+++ b/codex-rs/core/src/tools/runtimes/shell.rs
@@ -95,7 +95,7 @@ pub struct ShellRuntime {
pub(crate) struct ApprovalKey {
environment_id: String,
command: Vec<String>,
- cwd: AbsolutePathBuf,
+ cwd: PathUri,
sandbox_permissions: SandboxPermissions,
additional_permissions: Option<AdditionalPermissionProfile>,
}
@@ -130,7 +130,7 @@ impl Approvable<ShellRequest> for ShellRuntime {
vec![ApprovalKey {
environment_id: req.turn_environment.environment_id.clone(),
command: canonicalize_command_for_approval(&req.command),
- cwd: req.cwd.clone(),
+ cwd: PathUri::from_abs_path(&req.cwd),
sandbox_permissions: req.sandbox_permissions,
additional_permissions: req.additional_permissions.clone(),
}]
diff --git a/codex-rs/core/src/tools/runtimes/shell_tests.rs b/codex-rs/core/src/tools/runtimes/shell_tests.rs
index 9f070490ad..7ae93ab918 100644
--- a/codex-rs/core/src/tools/runtimes/shell_tests.rs
+++ b/codex-rs/core/src/tools/runtimes/shell_tests.rs
@@ -1,10 +1,11 @@
use super::*;
use codex_exec_server::Environment;
use codex_utils_path_uri::PathUri;
+use pretty_assertions::assert_eq;
use std::sync::Arc;
#[tokio::test]
-async fn approval_key_includes_environment_id() {
+async fn approval_key_uses_path_uri_and_includes_environment_id() {
let cwd = AbsolutePathBuf::try_from(std::env::current_dir().expect("read current dir"))
.expect("current dir is absolute");
let mut request = ShellRequest {
@@ -36,6 +37,16 @@ async fn approval_key_includes_environment_id() {
};
let runtime = ShellRuntime::for_shell_command(ShellRuntimeBackend::ShellCommandClassic);
let original_key = runtime.approval_keys(&request);
+ assert_eq!(
+ original_key,
+ vec![ApprovalKey {
+ environment_id: "remote".to_string(),
+ command: request.command.clone(),
+ cwd: PathUri::from_abs_path(&cwd),
+ sandbox_permissions: request.sandbox_permissions,
+ additional_permissions: request.additional_permissions.clone(),
+ }]
+ );
request.turn_environment.environment_id = "other".to_string();
let other_key = runtime.approval_keys(&request);