mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Remove Windows world-writable scans and warnings from the TUI (#44933)
## What changed Remove TUI-triggered world-writable scans at startup and during permission changes, along with their warning dialogs, acknowledgement handling, and scan telemetry. Permission selection and shortcuts no longer check for these warnings, and terminal color probing no longer waits for a startup scan. GitOrigin-RevId: a8d2fb5de7f891dcae5261286743fe3a125b82aa
This commit is contained in:
1 parent
202d61c629
commit
f3c4d082d9
13 files changed
+4
-615
No files matched your search
@@ -1909,24 +1909,6 @@ impl App {
|
||||
AppEvent::ApplyPermissionShortcut { thread_id, selection } => {
|
||||
self.apply_permission_shortcut(app_server, tui, thread_id, selection).await;
|
||||
}
|
||||
AppEvent::OpenWorldWritableWarningConfirmation {
|
||||
preset,
|
||||
profile_selection,
|
||||
sample_paths,
|
||||
extra_count,
|
||||
failed_scan,
|
||||
} => {
|
||||
self.chat_widget.open_world_writable_warning_confirmation(
|
||||
preset,
|
||||
profile_selection,
|
||||
sample_paths,
|
||||
extra_count,
|
||||
failed_scan,
|
||||
);
|
||||
}
|
||||
AppEvent::StartupWorldWritableScanCompleted => {
|
||||
self.windows_sandbox.startup_world_writable_scan_pending = false;
|
||||
}
|
||||
AppEvent::OpenFeedbackNote {
|
||||
category,
|
||||
include_logs,
|
||||
@@ -2229,36 +2211,7 @@ impl App {
|
||||
);
|
||||
let windows_sandbox_level =
|
||||
crate::windows_sandbox::level_from_config(&self.config);
|
||||
if let Some((sample_paths, extra_count, failed_scan)) =
|
||||
self.chat_widget.world_writable_warning_details()
|
||||
{
|
||||
self.app_event_tx.send(AppEvent::CodexOp(
|
||||
AppCommand::override_turn_context(
|
||||
/*cwd*/ None,
|
||||
/*approval_policy*/ None,
|
||||
/*approvals_reviewer*/ None,
|
||||
/*permission_profile*/ None,
|
||||
/*active_permission_profile*/ None,
|
||||
#[cfg(target_os = "windows")]
|
||||
Some(windows_sandbox_level),
|
||||
/*model*/ None,
|
||||
/*effort*/ None,
|
||||
/*summary*/ None,
|
||||
/*service_tier*/ None,
|
||||
/*collaboration_mode*/ None,
|
||||
/*personality*/ None,
|
||||
),
|
||||
));
|
||||
self.app_event_tx.send(
|
||||
AppEvent::OpenWorldWritableWarningConfirmation {
|
||||
preset: Some(preset.clone()),
|
||||
profile_selection: profile_selection.clone(),
|
||||
sample_paths,
|
||||
extra_count,
|
||||
failed_scan,
|
||||
},
|
||||
);
|
||||
} else if let Some(selection) = profile_selection {
|
||||
if let Some(selection) = profile_selection {
|
||||
self.app_event_tx.send(AppEvent::CodexOp(
|
||||
AppCommand::override_turn_context(
|
||||
/*cwd*/ None,
|
||||
@@ -2504,9 +2457,6 @@ impl App {
|
||||
else {
|
||||
return Ok(AppRunControl::Continue);
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
let permission_profile_is_managed_restricted =
|
||||
managed_filesystem_sandbox_is_restricted(&permission_profile);
|
||||
let permission_profile_for_chat = permission_profile.clone();
|
||||
|
||||
self.config = config;
|
||||
@@ -2529,42 +2479,6 @@ impl App {
|
||||
self.sync_active_thread_permission_settings_to_cached_session()
|
||||
.await;
|
||||
self.chat_widget.submit_initial_user_message_if_pending();
|
||||
|
||||
// If a managed filesystem sandbox is active, run the Windows
|
||||
// world-writable scan.
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
// One-shot suppression if the user just confirmed continue.
|
||||
if self.windows_sandbox.skip_world_writable_scan_once {
|
||||
self.windows_sandbox.skip_world_writable_scan_once = false;
|
||||
return Ok(AppRunControl::Continue);
|
||||
}
|
||||
|
||||
let should_check = crate::windows_sandbox::level_from_config(&self.config)
|
||||
!= WindowsSandboxLevel::Disabled
|
||||
&& permission_profile_is_managed_restricted
|
||||
&& !self.chat_widget.world_writable_warning_hidden();
|
||||
if should_check {
|
||||
let cwd = self.config.cwd.clone();
|
||||
let workspace_roots = self.config.effective_workspace_roots();
|
||||
let env_map: std::collections::HashMap<String, String> =
|
||||
std::env::vars().collect();
|
||||
let tx = self.app_event_tx.clone();
|
||||
let logs_base_dir = self.config.codex_home.clone();
|
||||
let permission_profile =
|
||||
self.config.permissions.effective_permission_profile();
|
||||
Self::spawn_world_writable_scan(
|
||||
cwd,
|
||||
workspace_roots,
|
||||
env_map,
|
||||
logs_base_dir,
|
||||
permission_profile,
|
||||
self.session_telemetry.clone(),
|
||||
tx,
|
||||
/*startup_scan*/ false,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
AppEvent::SelectPermissionProfile(selection) => {
|
||||
self.select_permission_profile(app_server, selection).await;
|
||||
@@ -2621,13 +2535,6 @@ impl App {
|
||||
AppEvent::ResetMemories => {
|
||||
self.reset_memories_with_app_server(app_server).await;
|
||||
}
|
||||
AppEvent::SkipNextWorldWritableScan => {
|
||||
self.windows_sandbox.skip_world_writable_scan_once = true;
|
||||
}
|
||||
AppEvent::UpdateWorldWritableWarningAcknowledged(ack) => {
|
||||
self.chat_widget
|
||||
.set_world_writable_warning_acknowledged(ack);
|
||||
}
|
||||
AppEvent::UpdateRateLimitSwitchPromptHidden(hidden) => {
|
||||
self.chat_widget.set_rate_limit_switch_prompt_hidden(hidden);
|
||||
}
|
||||
@@ -2636,22 +2543,6 @@ impl App {
|
||||
self.sync_active_thread_plan_mode_reasoning_setting(app_server)
|
||||
.await;
|
||||
}
|
||||
AppEvent::PersistWorldWritableWarningAcknowledged => {
|
||||
self.local_settings.notices.hide_world_writable_warning = Some(true);
|
||||
if let Err(err) = ConfigEditsBuilder::for_config_path(self.local_settings.user_config_path.as_path())
|
||||
.set_hide_world_writable_warning(/*acknowledged*/ true)
|
||||
.apply()
|
||||
.await
|
||||
{
|
||||
tracing::error!(
|
||||
error = %err,
|
||||
"failed to persist world-writable warning acknowledgement"
|
||||
);
|
||||
self.chat_widget.add_error_message(format!(
|
||||
"Failed to save Agent mode warning preference: {err}"
|
||||
));
|
||||
}
|
||||
}
|
||||
AppEvent::PersistRateLimitSwitchPromptHidden => {
|
||||
self.local_settings.notices.hide_rate_limit_model_nudge = Some(true);
|
||||
if let Err(err) = ConfigEditsBuilder::for_config_path(self.local_settings.user_config_path.as_path())
|
||||
|
||||
@@ -8,68 +8,6 @@ use super::*;
|
||||
#[derive(Default)]
|
||||
pub(super) struct WindowsSandboxState {
|
||||
pub(super) setup_started_at: Option<Instant>,
|
||||
// One-shot suppression of the next world-writable scan after user confirmation.
|
||||
pub(super) skip_world_writable_scan_once: bool,
|
||||
/// A startup filesystem scan can still enqueue a protected warning after the app queue drains.
|
||||
pub(super) startup_world_writable_scan_pending: bool,
|
||||
}
|
||||
|
||||
impl App {
|
||||
#[cfg(target_os = "windows")]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(super) fn spawn_world_writable_scan(
|
||||
cwd: AbsolutePathBuf,
|
||||
workspace_roots: Vec<AbsolutePathBuf>,
|
||||
env_map: std::collections::HashMap<String, String>,
|
||||
logs_base_dir: AbsolutePathBuf,
|
||||
permission_profile: PermissionProfile,
|
||||
session_telemetry: SessionTelemetry,
|
||||
tx: AppEventSender,
|
||||
startup_scan: bool,
|
||||
) {
|
||||
let Ok(permissions) =
|
||||
codex_windows_sandbox::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_workspace_roots(
|
||||
&permission_profile,
|
||||
workspace_roots.as_slice(),
|
||||
)
|
||||
else {
|
||||
if startup_scan {
|
||||
tx.send(AppEvent::StartupWorldWritableScanCompleted);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let logs_base_dir_path = logs_base_dir.as_path();
|
||||
let result =
|
||||
codex_windows_sandbox::apply_world_writable_scan_and_denies_for_permissions(
|
||||
logs_base_dir_path,
|
||||
cwd.as_path(),
|
||||
&env_map,
|
||||
&permissions,
|
||||
Some(logs_base_dir_path),
|
||||
);
|
||||
crate::windows_sandbox::record_world_writable_scan_result(&session_telemetry, &result);
|
||||
if result.is_err() {
|
||||
// Scan failed: warn without examples.
|
||||
send_world_writable_scan_failed(&tx);
|
||||
}
|
||||
if startup_scan {
|
||||
tx.send(AppEvent::StartupWorldWritableScanCompleted);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn send_world_writable_scan_failed(tx: &AppEventSender) {
|
||||
tx.send(AppEvent::OpenWorldWritableWarningConfirmation {
|
||||
preset: None,
|
||||
profile_selection: None,
|
||||
sample_paths: Vec::new(),
|
||||
extra_count: 0usize,
|
||||
failed_scan: true,
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn side_return_shortcut_matches(key_event: KeyEvent) -> bool {
|
||||
|
||||
@@ -128,7 +128,6 @@ impl App {
|
||||
pub(super) fn ready_for_terminal_color_probe(&self, has_pending_app_events: bool) -> bool {
|
||||
!has_pending_app_events
|
||||
&& !self.chat_widget.has_active_view()
|
||||
&& !self.windows_sandbox.startup_world_writable_scan_pending
|
||||
&& !self.startup_pending_protected_request
|
||||
&& !self.has_queued_startup_protected_request()
|
||||
&& !self.chat_widget.has_pending_protected_request()
|
||||
@@ -864,39 +863,6 @@ See the Codex keymap documentation for supported actions and examples."
|
||||
}
|
||||
let initial_session_ms = initial_session_started_at.elapsed().as_millis();
|
||||
|
||||
// On startup, if a managed filesystem sandbox is active, warn about
|
||||
// world-writable dirs on Windows.
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let startup_permission_profile = app.config.permissions.effective_permission_profile();
|
||||
let should_check = crate::windows_sandbox::level_from_config(&app.config)
|
||||
!= WindowsSandboxLevel::Disabled
|
||||
&& managed_filesystem_sandbox_is_restricted(&startup_permission_profile)
|
||||
&& !app
|
||||
.local_settings
|
||||
.notices
|
||||
.hide_world_writable_warning
|
||||
.unwrap_or(false);
|
||||
if should_check {
|
||||
app.windows_sandbox.startup_world_writable_scan_pending = true;
|
||||
let cwd = app.config.cwd.clone();
|
||||
let workspace_roots = app.config.effective_workspace_roots();
|
||||
let env_map: std::collections::HashMap<String, String> = std::env::vars().collect();
|
||||
let tx = app.app_event_tx.clone();
|
||||
let logs_base_dir = app.config.codex_home.clone();
|
||||
Self::spawn_world_writable_scan(
|
||||
cwd,
|
||||
workspace_roots,
|
||||
env_map,
|
||||
logs_base_dir,
|
||||
startup_permission_profile,
|
||||
app.session_telemetry.clone(),
|
||||
tx,
|
||||
/*startup_scan*/ true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(err) = startup_draft.flush_pending_events(tui).await {
|
||||
return shutdown_on_startup_error(app_server, err).await;
|
||||
}
|
||||
|
||||
@@ -63,74 +63,6 @@ async fn terminal_color_probe_waits_for_startup_sandbox_choice() {
|
||||
assert!(app.ready_for_terminal_color_probe(/*has_pending_app_events*/ false));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn terminal_color_probe_waits_for_delayed_world_writable_scan_failure() {
|
||||
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
||||
app.startup_protected_input_boundary = true;
|
||||
app.windows_sandbox.startup_world_writable_scan_pending = true;
|
||||
while app_event_rx.try_recv().is_ok() {}
|
||||
|
||||
assert!(!app.ready_for_terminal_color_probe(/*has_pending_app_events*/ false));
|
||||
|
||||
app.app_event_tx
|
||||
.send(AppEvent::OpenWorldWritableWarningConfirmation {
|
||||
preset: None,
|
||||
profile_selection: None,
|
||||
sample_paths: Vec::new(),
|
||||
extra_count: 0,
|
||||
failed_scan: true,
|
||||
});
|
||||
app.app_event_tx
|
||||
.send(AppEvent::StartupWorldWritableScanCompleted);
|
||||
assert!(!app.ready_for_terminal_color_probe(/*has_pending_app_events*/ true));
|
||||
|
||||
let warning = app_event_rx
|
||||
.try_recv()
|
||||
.expect("the delayed scan should queue its warning before completion");
|
||||
let AppEvent::OpenWorldWritableWarningConfirmation {
|
||||
preset,
|
||||
profile_selection,
|
||||
sample_paths,
|
||||
extra_count,
|
||||
failed_scan,
|
||||
} = warning
|
||||
else {
|
||||
panic!("the delayed scan should open a protected warning before completion");
|
||||
};
|
||||
app.chat_widget.open_world_writable_warning_confirmation(
|
||||
preset,
|
||||
profile_selection,
|
||||
sample_paths,
|
||||
extra_count,
|
||||
failed_scan,
|
||||
);
|
||||
assert!(matches!(
|
||||
app_event_rx.try_recv(),
|
||||
Ok(AppEvent::StartupWorldWritableScanCompleted)
|
||||
));
|
||||
app.windows_sandbox.startup_world_writable_scan_pending = false;
|
||||
|
||||
assert!(!app.windows_sandbox.startup_world_writable_scan_pending);
|
||||
assert!(!app.ready_for_terminal_color_probe(/*has_pending_app_events*/ false));
|
||||
for character in "20;rgb:2222/ffff/ffff".chars() {
|
||||
app.chat_widget
|
||||
.handle_key_event(KeyEvent::new(KeyCode::Char(character), KeyModifiers::NONE));
|
||||
assert!(app_event_rx.try_recv().is_err());
|
||||
}
|
||||
|
||||
app.chat_widget
|
||||
.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
|
||||
assert!(matches!(
|
||||
app_event_rx.try_recv(),
|
||||
Ok(AppEvent::UpdateWorldWritableWarningAcknowledged(true))
|
||||
));
|
||||
assert!(matches!(
|
||||
app_event_rx.try_recv(),
|
||||
Ok(AppEvent::PersistWorldWritableWarningAcknowledged)
|
||||
));
|
||||
assert!(app.ready_for_terminal_color_probe(/*has_pending_app_events*/ false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_waiting_gate_is_only_for_fresh_or_exit_session_selection() {
|
||||
assert_eq!(
|
||||
@@ -907,12 +839,7 @@ async fn queued_startup_app_event_owns_protected_view_before_draft_restore() ->
|
||||
|
||||
while let Ok(event) = app_event_rx.try_recv() {
|
||||
assert!(
|
||||
!matches!(
|
||||
event,
|
||||
AppEvent::StartFileSearch(_)
|
||||
| AppEvent::UpdateWorldWritableWarningAcknowledged(_)
|
||||
| AppEvent::PersistWorldWritableWarningAcknowledged
|
||||
),
|
||||
!matches!(event, AppEvent::StartFileSearch(_)),
|
||||
"protected startup app event must own input before draft side effects: {event:?}"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user