mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Record Windows world-writable scan telemetry (#40983)
## What changed - Return the number of directories flagged by successful Windows sandbox world-writable scans. - Record that count in the `codex.windows_sandbox.world_writable_scan_flagged_directories` histogram for startup and warning-triggered scans. - Tag each measurement with a `success` or `error` result, using a count of zero when the scan fails. GitOrigin-RevId: 076160f36b1d62fa737f4b2d0318774e6c44a4b1
This commit is contained in:
1 parent
d61ba72f2f
commit
37a5149822
6 files changed
+31
-5
No files matched your search
@@ -2292,6 +2292,7 @@ impl App {
|
|||||||
env_map,
|
env_map,
|
||||||
logs_base_dir,
|
logs_base_dir,
|
||||||
permission_profile,
|
permission_profile,
|
||||||
|
self.session_telemetry.clone(),
|
||||||
tx,
|
tx,
|
||||||
/*startup_scan*/ false,
|
/*startup_scan*/ false,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ pub(super) struct WindowsSandboxState {
|
|||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(super) fn spawn_world_writable_scan(
|
pub(super) fn spawn_world_writable_scan(
|
||||||
cwd: AbsolutePathBuf,
|
cwd: AbsolutePathBuf,
|
||||||
workspace_roots: Vec<AbsolutePathBuf>,
|
workspace_roots: Vec<AbsolutePathBuf>,
|
||||||
env_map: std::collections::HashMap<String, String>,
|
env_map: std::collections::HashMap<String, String>,
|
||||||
logs_base_dir: AbsolutePathBuf,
|
logs_base_dir: AbsolutePathBuf,
|
||||||
permission_profile: PermissionProfile,
|
permission_profile: PermissionProfile,
|
||||||
|
session_telemetry: SessionTelemetry,
|
||||||
tx: AppEventSender,
|
tx: AppEventSender,
|
||||||
startup_scan: bool,
|
startup_scan: bool,
|
||||||
) {
|
) {
|
||||||
@@ -47,6 +49,7 @@ impl App {
|
|||||||
&permissions,
|
&permissions,
|
||||||
Some(logs_base_dir_path),
|
Some(logs_base_dir_path),
|
||||||
);
|
);
|
||||||
|
crate::windows_sandbox::record_world_writable_scan_result(&session_telemetry, &result);
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
// Scan failed: warn without examples.
|
// Scan failed: warn without examples.
|
||||||
send_world_writable_scan_failed(&tx);
|
send_world_writable_scan_failed(&tx);
|
||||||
|
|||||||
@@ -611,6 +611,7 @@ See the Codex keymap documentation for supported actions and examples."
|
|||||||
env_map,
|
env_map,
|
||||||
logs_base_dir,
|
logs_base_dir,
|
||||||
startup_permission_profile,
|
startup_permission_profile,
|
||||||
|
app.session_telemetry.clone(),
|
||||||
tx,
|
tx,
|
||||||
/*startup_scan*/ true,
|
/*startup_scan*/ true,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,13 +48,15 @@ impl ChatWidget {
|
|||||||
else {
|
else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
match codex_windows_sandbox::apply_world_writable_scan_and_denies_for_permissions(
|
let result = codex_windows_sandbox::apply_world_writable_scan_and_denies_for_permissions(
|
||||||
self.config.codex_home.as_path(),
|
self.config.codex_home.as_path(),
|
||||||
cwd.as_path(),
|
cwd.as_path(),
|
||||||
&env_map,
|
&env_map,
|
||||||
&permissions,
|
&permissions,
|
||||||
Some(self.config.codex_home.as_path()),
|
Some(self.config.codex_home.as_path()),
|
||||||
) {
|
);
|
||||||
|
crate::windows_sandbox::record_world_writable_scan_result(&self.session_telemetry, &result);
|
||||||
|
match result {
|
||||||
Ok(_) => None,
|
Ok(_) => None,
|
||||||
Err(_) => Some((Vec::new(), 0, true)),
|
Err(_) => Some((Vec::new(), 0, true)),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
use crate::legacy_core::config::Config;
|
use crate::legacy_core::config::Config;
|
||||||
use codex_config::types::WindowsSandboxModeToml;
|
use codex_config::types::WindowsSandboxModeToml;
|
||||||
use codex_features::Feature;
|
use codex_features::Feature;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use codex_otel::SessionTelemetry;
|
||||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use codex_protocol::models::PermissionProfile;
|
use codex_protocol::models::PermissionProfile;
|
||||||
@@ -20,6 +22,22 @@ use std::path::Path;
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
pub(crate) fn record_world_writable_scan_result(
|
||||||
|
session_telemetry: &SessionTelemetry,
|
||||||
|
result: &anyhow::Result<usize>,
|
||||||
|
) {
|
||||||
|
let (flagged_count, result) = match result {
|
||||||
|
Ok(flagged_count) => (*flagged_count as i64, "success"),
|
||||||
|
Err(_) => (0, "error"),
|
||||||
|
};
|
||||||
|
session_telemetry.histogram(
|
||||||
|
"codex.windows_sandbox.world_writable_scan_flagged_directories",
|
||||||
|
flagged_count,
|
||||||
|
&[("result", result)],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn level_from_config(config: &Config) -> WindowsSandboxLevel {
|
pub(crate) fn level_from_config(config: &Config) -> WindowsSandboxLevel {
|
||||||
match config.permissions.windows_sandbox_mode {
|
match config.permissions.windows_sandbox_mode {
|
||||||
Some(WindowsSandboxModeToml::Elevated) => WindowsSandboxLevel::Elevated,
|
Some(WindowsSandboxModeToml::Elevated) => WindowsSandboxLevel::Elevated,
|
||||||
|
|||||||
@@ -224,11 +224,12 @@ pub fn apply_world_writable_scan_and_denies_for_permissions(
|
|||||||
env_map: &std::collections::HashMap<String, String>,
|
env_map: &std::collections::HashMap<String, String>,
|
||||||
permissions: &ResolvedWindowsSandboxPermissions,
|
permissions: &ResolvedWindowsSandboxPermissions,
|
||||||
logs_base_dir: Option<&Path>,
|
logs_base_dir: Option<&Path>,
|
||||||
) -> Result<()> {
|
) -> Result<usize> {
|
||||||
let flagged = audit_everyone_writable(cwd, env_map, logs_base_dir)?;
|
let flagged = audit_everyone_writable(cwd, env_map, logs_base_dir)?;
|
||||||
if flagged.is_empty() {
|
if flagged.is_empty() {
|
||||||
return Ok(());
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
let flagged_count = flagged.len();
|
||||||
let result = apply_capability_denies_for_world_writable_for_permissions(
|
let result = apply_capability_denies_for_world_writable_for_permissions(
|
||||||
codex_home,
|
codex_home,
|
||||||
&flagged,
|
&flagged,
|
||||||
@@ -243,7 +244,7 @@ pub fn apply_world_writable_scan_and_denies_for_permissions(
|
|||||||
logs_base_dir,
|
logs_base_dir,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
result
|
result.map(|()| flagged_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_capability_denies_for_world_writable_for_permissions(
|
fn apply_capability_denies_for_world_writable_for_permissions(
|
||||||
|
|||||||
Reference in new issue
Block a user