mirror of
https://github.com/openai/codex.git
synced 2026-10-21 14:23:14 +00:00
Use path URIs in shell approval keys (#34806)
## What changed - Store the shell approval key's `cwd` as a `PathUri`, matching the URI representation used by approval actions. - Extend the approval-key test to verify both the URI-based working directory and environment scoping. ## Testing - Added `approval_key_uses_path_uri_and_includes_environment_id`. GitOrigin-RevId: 4d7ba1a2e652f4ffe317242f52beb33513b01e6a
This commit is contained in:
committed by
copyberry
parent
f343d1237d
commit
a59a419afa
@@ -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(),
|
||||
}]
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user