mirror of
https://github.com/openai/codex.git
synced 2026-10-18 17:18:52 +00:00
## Why Automatic startup work and `codex doctor` can run before a workspace is trusted. A repository-controlled `PATH` must not be able to make those flows execute workspace-provided helpers. ## What changed - Resolve helpers used by automatic startup from trusted system installation directories, and give plugin-sync Git subprocesses a sanitized environment. - Make terminal detection environment-only and have doctor inspect executable locations without running them. Fetch update metadata with the HTTP client instead of `curl`. - Fall back conservatively when trusted terminal helpers are unavailable, including for tmux keyboard enhancement flags. ## Testing Add black-box coverage with hostile workspace `PATH` entries for startup, interactive tmux startup, support log collection, doctor, and curated plugin sync. Add unit coverage for trusted executable resolution and bounded update HTTP responses. GitOrigin-RevId: 3b8995eb422b60ed53b0386951de59e8f9bfc542
32 lines
1.2 KiB
Rust
32 lines
1.2 KiB
Rust
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn resolves_only_executables_inside_installation_directories() {
|
|
let root = tempfile::tempdir().unwrap();
|
|
let bin = root.path().join("bin");
|
|
std::fs::create_dir(&bin).unwrap();
|
|
let executable = bin.join(format!("helper{}", std::env::consts::EXE_SUFFIX));
|
|
std::fs::write(&executable, "installed helper").unwrap();
|
|
#[cfg(unix)]
|
|
{
|
|
use std::os::unix::fs::PermissionsExt;
|
|
std::fs::set_permissions(&executable, std::fs::Permissions::from_mode(/*mode*/ 0o755))
|
|
.unwrap();
|
|
}
|
|
let directories = vec![dunce::canonicalize(bin).unwrap()];
|
|
assert_eq!(
|
|
executable_in_directories("helper", &directories),
|
|
Some(dunce::canonicalize(&executable).unwrap())
|
|
);
|
|
assert_eq!(executable_in_directories("../helper", &directories), None);
|
|
assert_eq!(executable_in_directories("missing", &directories), None);
|
|
#[cfg(unix)]
|
|
{
|
|
let outside = root.path().join("outside");
|
|
std::fs::rename(&executable, &outside).unwrap();
|
|
std::os::unix::fs::symlink(&outside, &executable).unwrap();
|
|
assert_eq!(executable_in_directories("helper", &directories), None);
|
|
}
|
|
}
|