fix: make $PWD/.agent read-only like $PWD/.codex

This commit is contained in:
Michael Bolin
2026-02-03 08:05:55 -08:00
parent cbfd2a37cc
commit d3afd4e31a

View File

@@ -589,13 +589,18 @@ impl SandboxPolicy {
}
subpaths.push(top_level_git);
}
#[allow(clippy::expect_used)]
let top_level_codex = writable_root
.join(".codex")
.expect(".codex is a valid relative path");
if top_level_codex.as_path().is_dir() {
subpaths.push(top_level_codex);
// Make .agent/skills and .codex/config.toml and related
// files read-only to the agent, by default.
for subdir in &[".agent", ".codex"] {
#[allow(clippy::expect_used)]
let top_level_codex =
writable_root.join(subdir).expect("valid relative path");
if top_level_codex.as_path().is_dir() {
subpaths.push(top_level_codex);
}
}
WritableRoot {
root: writable_root,
read_only_subpaths: subpaths,