mirror of
https://github.com/openai/codex.git
synced 2026-11-20 23:08:21 +00:00
Preserve parent repository discovery through sandbox metadata mounts (#39629)
## Why The Linux sandbox represents missing protected metadata paths such as `.git` with empty read-only directories. Repository and project discovery treated any `.git` directory as a checkout root, so this synthetic directory could hide a real parent repository and its trust configuration. ## What changed - Treat a `.git` directory as repository metadata only when it contains `HEAD`, while continuing to recognize file-based `.git` entries. - Protect missing `.git` paths with the same read-only synthetic mounts as other workspace metadata without disrupting parent-repository discovery. - Canonicalize and read-only bind the synthetic-mount registry into the sandbox, and make protected-path cleanup handle read-only directory trees. ## Testing Added coverage for repository, project-root, trust, synthetic-mount, and Landlock behavior, including nested incomplete `.git` directories and a redirected `TMPDIR`. GitOrigin-RevId: 0724c54d56531143bb28011e4ca414cd3b0212be
This commit is contained in:
1 parent
e396ef3fc1
commit
9ca99b5171
15 files changed
+305
-116
No files matched your search
@@ -1315,13 +1315,22 @@ async fn find_project_root(
|
||||
for marker in project_root_markers {
|
||||
let marker_path = ancestor.join(marker);
|
||||
let marker_path_uri = PathUri::from_abs_path(&marker_path);
|
||||
if fs
|
||||
.get_metadata(&marker_path_uri, /*sandbox*/ None)
|
||||
.await
|
||||
.is_ok()
|
||||
let Ok(metadata) = fs.get_metadata(&marker_path_uri, /*sandbox*/ None).await else {
|
||||
continue;
|
||||
};
|
||||
if marker == ".git"
|
||||
&& metadata.is_directory
|
||||
&& fs
|
||||
.get_metadata(
|
||||
&PathUri::from_abs_path(&marker_path.join("HEAD")),
|
||||
/*sandbox*/ None,
|
||||
)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
return Ok(ancestor);
|
||||
continue;
|
||||
}
|
||||
return Ok(ancestor);
|
||||
}
|
||||
}
|
||||
Ok(cwd.clone())
|
||||
@@ -1340,13 +1349,21 @@ async fn find_git_checkout_root(
|
||||
for dir in base.ancestors() {
|
||||
let dot_git = dir.join(".git");
|
||||
let dot_git_uri = PathUri::from_abs_path(&dot_git);
|
||||
if fs
|
||||
.get_metadata(&dot_git_uri, /*sandbox*/ None)
|
||||
.await
|
||||
.is_ok()
|
||||
let Ok(metadata) = fs.get_metadata(&dot_git_uri, /*sandbox*/ None).await else {
|
||||
continue;
|
||||
};
|
||||
if metadata.is_directory
|
||||
&& fs
|
||||
.get_metadata(
|
||||
&PathUri::from_abs_path(&dot_git.join("HEAD")),
|
||||
/*sandbox*/ None,
|
||||
)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
return Some(dir);
|
||||
continue;
|
||||
}
|
||||
return Some(dir);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user