From b262c52803d45ab7c927f5020b3f924b593b476f Mon Sep 17 00:00:00 2001 From: Chris Bookholt Date: Wed, 1 Jul 2026 15:50:37 -0700 Subject: [PATCH] git-utils: mirror resolver roots in traversal test --- codex-rs/git-utils/src/git_command_tests.rs | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/codex-rs/git-utils/src/git_command_tests.rs b/codex-rs/git-utils/src/git_command_tests.rs index 15667106f9..77807ba8d4 100644 --- a/codex-rs/git-utils/src/git_command_tests.rs +++ b/codex-rs/git-utils/src/git_command_tests.rs @@ -62,8 +62,13 @@ fn write_git_candidate(directory: &Path) { } fn locations_for_root(root: &Path) -> UntrustedGitLocations { + let mut roots = vec![root.to_path_buf()]; + push_unique( + &mut roots, + std::fs::canonicalize(root).expect("canonical root"), + ); UntrustedGitLocations { - roots: vec![std::fs::canonicalize(root).expect("canonical root")], + roots, common_dirs: Vec::new(), } } @@ -329,12 +334,17 @@ fn resolver_rejects_parent_traversal_spelled_through_repository() { write_git_candidate(&trusted_bin); let locations = locations_for_root(&repo); - let traversing_path = locations.roots[0].join("../trusted-bin"); - let search_path = std::env::join_paths([traversing_path]).expect("PATH"); - assert!(matches!( - GitRunner::from_search_path(&locations, &search_path), - Err(GitReadError::NoTrustedGit) - )); + for root in &locations.roots { + let traversing_path = root.join("../trusted-bin"); + let search_path = std::env::join_paths([traversing_path]).expect("PATH"); + assert!( + matches!( + GitRunner::from_search_path(&locations, &search_path), + Err(GitReadError::NoTrustedGit) + ), + "resolver accepted parent traversal from {root:?}" + ); + } } #[cfg(windows)]