mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
Propagate executor home directories into sandbox contexts (#41204)
## What changed - Report the executor's user home in environment metadata. - Cache the reported home on selected turn environments and include it in filesystem sandbox contexts, including `apply_patch` requests. - Preserve compatibility with executors that do not report a home directory. ## Testing - Cover local, remote, inherited, serialized, and `apply_patch` sandbox contexts. GitOrigin-RevId: ea65e68e33a80bc9bcfc7c53b1486ab944699470
This commit is contained in:
@@ -263,6 +263,7 @@ pub struct RawFileSystemSandboxPolicy {
|
||||
pub struct FileSystemSandboxPolicyContext<'a> {
|
||||
pub cwd: &'a PathUri,
|
||||
pub workspace_roots: &'a [PathUri],
|
||||
pub user_home_dir: Option<&'a PathUri>,
|
||||
pub temporary_directories: Option<&'a [PathUri]>,
|
||||
}
|
||||
|
||||
@@ -1784,10 +1785,12 @@ fn with_local_policy_context<T>(
|
||||
let cwd = AbsolutePathBuf::from_absolute_path(cwd).ok()?;
|
||||
let path = PathUri::from(resolve_candidate_path(path, cwd.as_path())?);
|
||||
let cwd = PathUri::from(cwd);
|
||||
let user_home_dir = PathUri::from_host_native_path("~").ok();
|
||||
let temporary_directories = local_temporary_directories();
|
||||
let context = FileSystemSandboxPolicyContext {
|
||||
cwd: &cwd,
|
||||
workspace_roots: std::slice::from_ref(&cwd),
|
||||
user_home_dir: user_home_dir.as_ref(),
|
||||
temporary_directories: Some(&temporary_directories),
|
||||
};
|
||||
Some(evaluate(&path, &context))
|
||||
@@ -2451,6 +2454,7 @@ mod tests {
|
||||
let context = FileSystemSandboxPolicyContext {
|
||||
cwd: &cwd,
|
||||
workspace_roots: &workspace_roots,
|
||||
user_home_dir: None,
|
||||
temporary_directories: Some(&temporary_directories),
|
||||
};
|
||||
let policy = FileSystemSandboxPolicy::restricted(vec![
|
||||
@@ -2530,6 +2534,7 @@ mod tests {
|
||||
let context = FileSystemSandboxPolicyContext {
|
||||
cwd: &cwd,
|
||||
workspace_roots: std::slice::from_ref(&cwd),
|
||||
user_home_dir: None,
|
||||
temporary_directories: None,
|
||||
};
|
||||
let candidate = path("file:///workspace/private/secret/key");
|
||||
@@ -2575,6 +2580,7 @@ mod tests {
|
||||
let context = FileSystemSandboxPolicyContext {
|
||||
cwd: &cwd,
|
||||
workspace_roots: &[],
|
||||
user_home_dir: None,
|
||||
temporary_directories: None,
|
||||
};
|
||||
let policy = FileSystemSandboxPolicy::restricted(vec![
|
||||
@@ -2605,6 +2611,7 @@ mod tests {
|
||||
let opaque_context = FileSystemSandboxPolicyContext {
|
||||
cwd: &opaque,
|
||||
workspace_roots: std::slice::from_ref(&opaque),
|
||||
user_home_dir: None,
|
||||
temporary_directories: None,
|
||||
};
|
||||
let opaque_policy = FileSystemSandboxPolicy::restricted(vec![FileSystemSandboxEntry::new(
|
||||
|
||||
Reference in New Issue
Block a user