mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
fix(core): keep managed network permission profile
Co-authored-by: Codex noreply@openai.com
This commit is contained in:
co-authored by
Codex noreply@openai.com
parent
4e248f97ff
commit
8d117e135a
@@ -290,26 +290,23 @@ pub(crate) fn escalation_profile_preserving_deny_read(
|
||||
managed_network_active: bool,
|
||||
permission_profile: &PermissionProfile,
|
||||
) -> Option<PermissionProfile> {
|
||||
if !matches!(
|
||||
sandbox_override,
|
||||
SandboxOverride::EscalatedSandboxWithDenyRead
|
||||
) {
|
||||
if managed_network_active
|
||||
|| !matches!(
|
||||
sandbox_override,
|
||||
SandboxOverride::EscalatedSandboxWithDenyRead
|
||||
)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut file_system_policy = FileSystemSandboxPolicy::unrestricted();
|
||||
file_system_policy
|
||||
.preserve_deny_read_restrictions_from(&permission_profile.file_system_sandbox_policy());
|
||||
let network_sandbox_policy = if managed_network_active {
|
||||
permission_profile.network_sandbox_policy()
|
||||
} else {
|
||||
NetworkSandboxPolicy::Enabled
|
||||
};
|
||||
Some(
|
||||
PermissionProfile::from_runtime_permissions_with_enforcement(
|
||||
permission_profile.enforcement(),
|
||||
&file_system_policy,
|
||||
network_sandbox_policy,
|
||||
NetworkSandboxPolicy::Enabled,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -252,16 +252,14 @@ fn deny_read_is_preserved_during_explicit_escalation_and_policy_bypass() {
|
||||
None,
|
||||
"ordinary sandboxed attempts keep their original profile",
|
||||
);
|
||||
let managed_network_escalation = escalation_profile_preserving_deny_read(
|
||||
SandboxOverride::EscalatedSandboxWithDenyRead,
|
||||
/*managed_network_active*/ true,
|
||||
&permission_profile,
|
||||
)
|
||||
.expect("managed network escalation profile");
|
||||
assert_eq!(
|
||||
managed_network_escalation.network_sandbox_policy(),
|
||||
NetworkSandboxPolicy::Restricted,
|
||||
"managed network restrictions must survive escalation",
|
||||
escalation_profile_preserving_deny_read(
|
||||
SandboxOverride::EscalatedSandboxWithDenyRead,
|
||||
/*managed_network_active*/ true,
|
||||
&permission_profile,
|
||||
),
|
||||
None,
|
||||
"managed network attempts keep their original profile",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user