mirror of
https://github.com/openai/codex.git
synced 2026-05-03 04:42:20 +03:00
remove sandbox globals. (#9797)
Threads sandbox updates through OverrideTurnContext for active turn Passes computed sandbox type into safety/exec
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
use crate::config::Config;
|
||||
use crate::features::Feature;
|
||||
use crate::features::Features;
|
||||
use crate::protocol::SandboxPolicy;
|
||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -8,6 +12,36 @@ use std::path::Path;
|
||||
/// prompts users to enable the legacy sandbox feature.
|
||||
pub const ELEVATED_SANDBOX_NUX_ENABLED: bool = true;
|
||||
|
||||
pub trait WindowsSandboxLevelExt {
|
||||
fn from_config(config: &Config) -> WindowsSandboxLevel;
|
||||
fn from_features(features: &Features) -> WindowsSandboxLevel;
|
||||
}
|
||||
|
||||
impl WindowsSandboxLevelExt for WindowsSandboxLevel {
|
||||
fn from_config(config: &Config) -> WindowsSandboxLevel {
|
||||
Self::from_features(&config.features)
|
||||
}
|
||||
|
||||
fn from_features(features: &Features) -> WindowsSandboxLevel {
|
||||
if !features.enabled(Feature::WindowsSandbox) {
|
||||
return WindowsSandboxLevel::Disabled;
|
||||
}
|
||||
if features.enabled(Feature::WindowsSandboxElevated) {
|
||||
WindowsSandboxLevel::Elevated
|
||||
} else {
|
||||
WindowsSandboxLevel::RestrictedToken
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn windows_sandbox_level_from_config(config: &Config) -> WindowsSandboxLevel {
|
||||
WindowsSandboxLevel::from_config(config)
|
||||
}
|
||||
|
||||
pub fn windows_sandbox_level_from_features(features: &Features) -> WindowsSandboxLevel {
|
||||
WindowsSandboxLevel::from_features(features)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn sandbox_setup_is_complete(codex_home: &Path) -> bool {
|
||||
codex_windows_sandbox::sandbox_setup_is_complete(codex_home)
|
||||
|
||||
Reference in New Issue
Block a user