mirror of
https://github.com/openai/codex.git
synced 2026-05-04 03:16:31 +00:00
Protect workspace .agents directory in Windows sandbox (#11970)
The Mac and Linux implementations of the sandbox recently added write protections for `.codex` and `.agents` subdirectories in all writable roots. When adding documentation for this, I noticed that this change was never made for the Windows sandbox. Summary - make compute_allow_paths treat .codex/.agents as protected alongside .git, and cover their behavior in new tests - wire protect_workspace_agents_dir through the sandbox lib and setup path to apply deny ACEs when `.agents` exists - factor shared ACL logic for workspace subdirectories
This commit is contained in:
@@ -11,9 +11,19 @@ pub fn is_command_cwd_root(root: &Path, canonical_command_cwd: &Path) -> bool {
|
||||
/// # Safety
|
||||
/// Caller must ensure `psid` is a valid SID pointer.
|
||||
pub unsafe fn protect_workspace_codex_dir(cwd: &Path, psid: *mut c_void) -> Result<bool> {
|
||||
let cwd_codex = cwd.join(".codex");
|
||||
if cwd_codex.is_dir() {
|
||||
add_deny_write_ace(&cwd_codex, psid)
|
||||
protect_workspace_subdir(cwd, psid, ".codex")
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// Caller must ensure `psid` is a valid SID pointer.
|
||||
pub unsafe fn protect_workspace_agents_dir(cwd: &Path, psid: *mut c_void) -> Result<bool> {
|
||||
protect_workspace_subdir(cwd, psid, ".agents")
|
||||
}
|
||||
|
||||
unsafe fn protect_workspace_subdir(cwd: &Path, psid: *mut c_void, subdir: &str) -> Result<bool> {
|
||||
let path = cwd.join(subdir);
|
||||
if path.is_dir() {
|
||||
add_deny_write_ace(&path, psid)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user