mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Use permission profiles throughout sandbox execution (#36183)
## What changed - Pass the canonical `PermissionProfile` through execution requests, sandbox selection, escalation, and the exec server instead of carrying separate derived filesystem and network policies. - Derive runtime sandbox policies from the effective profile at their points of use, including after applying additional permissions. - Update sandbox and escalation tests to inspect policies through the profile. GitOrigin-RevId: 695b82ea94f5289516b0933bb23074cb2dcce8ac
This commit is contained in:
1 parent
ceb4bc72c4
commit
0dcad0c972
15 files changed
+74
-166
No files matched your search
@@ -29,8 +29,7 @@ use tempfile::TempDir;
|
||||
fn danger_full_access_defaults_to_no_sandbox_without_network_requirements() {
|
||||
let manager = SandboxManager::new();
|
||||
let sandbox = manager.select_initial(
|
||||
&FileSystemSandboxPolicy::unrestricted(),
|
||||
NetworkSandboxPolicy::Enabled,
|
||||
&PermissionProfile::Disabled,
|
||||
SandboxablePreference::Auto,
|
||||
WindowsSandboxLevel::Disabled,
|
||||
/*has_managed_network_requirements*/ false,
|
||||
@@ -44,8 +43,7 @@ fn danger_full_access_uses_platform_sandbox_with_network_requirements() {
|
||||
let expected =
|
||||
get_platform_sandbox(/*windows_sandbox_enabled*/ false).unwrap_or(SandboxType::None);
|
||||
let sandbox = manager.select_initial(
|
||||
&FileSystemSandboxPolicy::unrestricted(),
|
||||
NetworkSandboxPolicy::Enabled,
|
||||
&PermissionProfile::Disabled,
|
||||
SandboxablePreference::Auto,
|
||||
WindowsSandboxLevel::Disabled,
|
||||
/*has_managed_network_requirements*/ true,
|
||||
@@ -58,7 +56,7 @@ fn restricted_file_system_uses_platform_sandbox_without_managed_network() {
|
||||
let manager = SandboxManager::new();
|
||||
let expected =
|
||||
get_platform_sandbox(/*windows_sandbox_enabled*/ false).unwrap_or(SandboxType::None);
|
||||
let sandbox = manager.select_initial(
|
||||
let permissions = PermissionProfile::from_runtime_permissions(
|
||||
&FileSystemSandboxPolicy::restricted(vec![FileSystemSandboxEntry {
|
||||
path: FileSystemPath::Special {
|
||||
value: FileSystemSpecialPath::Root,
|
||||
@@ -67,6 +65,9 @@ fn restricted_file_system_uses_platform_sandbox_without_managed_network() {
|
||||
missing_path_behavior: None,
|
||||
}]),
|
||||
NetworkSandboxPolicy::Enabled,
|
||||
);
|
||||
let sandbox = manager.select_initial(
|
||||
&permissions,
|
||||
SandboxablePreference::Auto,
|
||||
WindowsSandboxLevel::Disabled,
|
||||
/*has_managed_network_requirements*/ false,
|
||||
@@ -112,11 +113,11 @@ fn unsandboxed_transform_preserves_foreign_cwd_and_unrestricted_file_system_poli
|
||||
assert_eq!(exec_request.cwd, cwd_uri);
|
||||
assert_eq!(exec_request.sandbox_policy_cwd, cwd_uri);
|
||||
assert_eq!(
|
||||
exec_request.file_system_sandbox_policy,
|
||||
exec_request.permission_profile.file_system_sandbox_policy(),
|
||||
FileSystemSandboxPolicy::unrestricted()
|
||||
);
|
||||
assert_eq!(
|
||||
exec_request.network_sandbox_policy,
|
||||
exec_request.permission_profile.network_sandbox_policy(),
|
||||
NetworkSandboxPolicy::Restricted
|
||||
);
|
||||
}
|
||||
@@ -172,7 +173,7 @@ fn transform_additional_permissions_enable_network_for_external_sandbox() {
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
exec_request.network_sandbox_policy,
|
||||
exec_request.permission_profile.network_sandbox_policy(),
|
||||
NetworkSandboxPolicy::Enabled
|
||||
);
|
||||
}
|
||||
@@ -239,7 +240,7 @@ fn transform_additional_permissions_preserves_denied_entries() {
|
||||
.expect("transform");
|
||||
|
||||
assert_eq!(
|
||||
exec_request.file_system_sandbox_policy,
|
||||
exec_request.permission_profile.file_system_sandbox_policy(),
|
||||
FileSystemSandboxPolicy::restricted(vec![
|
||||
FileSystemSandboxEntry {
|
||||
path: FileSystemPath::Special {
|
||||
@@ -261,7 +262,7 @@ fn transform_additional_permissions_preserves_denied_entries() {
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
exec_request.network_sandbox_policy,
|
||||
exec_request.permission_profile.network_sandbox_policy(),
|
||||
NetworkSandboxPolicy::Restricted
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user