Honor managed network in bubblewrap probe

This commit is contained in:
Amruth Venkatraman
2026-06-16 20:54:11 +00:00
parent db902b4ad7
commit 17bea28954
7 changed files with 41 additions and 11 deletions
+4 -3
View File
@@ -629,9 +629,10 @@ pub async fn run_main_with_transport_options(
range: None,
});
}
if let Some(warning) =
codex_core::config::system_bwrap_warning(config.permissions.permission_profile())
{
if let Some(warning) = codex_core::config::system_bwrap_warning(
config.permissions.permission_profile(),
config.managed_network_requirements_enabled(),
) {
config_warnings.push(ConfigWarningNotification {
summary: warning,
details: None,
+4 -2
View File
@@ -845,8 +845,10 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
// is using.
event_processor.print_config_summary(&config, &prompt_summary, &session_configured);
if !json_mode
&& let Some(message) =
codex_core::config::system_bwrap_warning(config.permissions.permission_profile())
&& let Some(message) = codex_core::config::system_bwrap_warning(
config.permissions.permission_profile(),
config.managed_network_requirements_enabled(),
)
{
event_processor.process_warning(message);
}
+6 -3
View File
@@ -52,12 +52,15 @@ enum SystemBwrapProbeResult {
Failed,
}
pub fn system_bwrap_warning(permission_profile: &PermissionProfile) -> Option<String> {
pub fn system_bwrap_warning(
permission_profile: &PermissionProfile,
has_managed_network_requirements: bool,
) -> Option<String> {
let (file_system_policy, network_policy) = permission_profile.to_runtime_permissions();
if !should_require_platform_sandbox(
&file_system_policy,
network_policy,
/*has_managed_network_requirements*/ false,
has_managed_network_requirements,
) {
return None;
}
@@ -65,7 +68,7 @@ pub fn system_bwrap_warning(permission_profile: &PermissionProfile) -> Option<St
let system_bwrap_path = find_system_bwrap_in_path();
system_bwrap_warning_for_path(
system_bwrap_path.as_deref(),
/*unshare_network*/ !network_policy.is_enabled(),
/*unshare_network*/ !network_policy.is_enabled() || has_managed_network_requirements,
)
}
+1
View File
@@ -26,6 +26,7 @@ use codex_protocol::error::CodexErr;
#[cfg(not(target_os = "linux"))]
pub fn system_bwrap_warning(
_permission_profile: &codex_protocol::models::PermissionProfile,
_has_managed_network_requirements: bool,
) -> Option<String> {
None
}
+4 -3
View File
@@ -105,9 +105,10 @@ pub(super) fn emit_project_config_warnings(app_event_tx: &AppEventSender, config
}
pub(super) fn emit_system_bwrap_warning(app_event_tx: &AppEventSender, config: &Config) {
let Some(message) =
codex_sandboxing::system_bwrap_warning(config.permissions.permission_profile())
else {
let Some(message) = codex_sandboxing::system_bwrap_warning(
config.permissions.permission_profile(),
config.managed_network_requirements_enabled(),
) else {
return;
};
+14
View File
@@ -193,6 +193,20 @@ fn bypass_hook_trust_startup_warning_snapshot() {
assert_app_snapshot!("bypass_hook_trust_startup_warning", rendered);
}
#[test]
fn disconnected_proc_sys_startup_warning_snapshot() {
let rendered = lines_to_single_string(
&history_cell::new_warning_event(
"Codex's Linux sandbox cannot access /proc/sys because the mount is disconnected. Restart the environment or container before running sandboxed commands."
.to_string(),
)
.display_lines(/*width*/ 80),
);
assert_app_snapshot!("disconnected_proc_sys_startup_warning", rendered);
}
#[tokio::test]
async fn enqueue_primary_thread_session_replays_buffered_approval_after_attach() -> Result<()> {
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
@@ -0,0 +1,8 @@
---
source: tui/src/app/tests.rs
assertion_line: 207
expression: rendered
---
⚠ Codex's Linux sandbox cannot access /proc/sys because the mount is
disconnected. Restart the environment or container before running sandboxed
commands.