mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
Preserve filesystem permission path conventions (#39084)
## Why Filesystem permission paths can use a convention that differs from the host running Codex. Converting them immediately to native absolute paths can change the meaning of ambiguous paths such as `/C:/secret` or Windows UNC paths. ## What changed - Store literal filesystem permission paths as `PathUri` values through the runtime policy and execution protocol. - Keep legacy string-based serialization at explicit protocol boundaries and reject conversions that cannot be represented losslessly. - Encode native paths as opaque URIs when a normal file URI would imply the wrong path convention. ## Testing Added coverage for cross-platform and ambiguous path round trips, UNC path variants, permission-profile serialization, and deny-policy enforcement. GitOrigin-RevId: 5247713796d1f2bb4e02f94eb9fc82d4698060f0
This commit is contained in:
@@ -82,8 +82,8 @@ const RENDER_CASES: &[RenderCase] = &[
|
||||
),
|
||||
RenderCase::round_trips("file:///etc", PathConvention::Posix, "/etc"),
|
||||
RenderCase::round_trips("file:///tmp/", PathConvention::Posix, "/tmp/"),
|
||||
RenderCase::round_trips("file:///C:/Project", PathConvention::Posix, "/C:/Project"),
|
||||
RenderCase::round_trips("file:///C:", PathConvention::Posix, "/C:"),
|
||||
RenderCase::renders_lossily("file:///C:/Project", PathConvention::Posix, "/C:/Project"),
|
||||
RenderCase::renders_lossily("file:///C:", PathConvention::Posix, "/C:"),
|
||||
RenderCase::round_trips("file:///tmp/%E2%98%83", PathConvention::Posix, "/tmp/☃"),
|
||||
RenderCase::round_trips("file:///tmp/a%5Cb", PathConvention::Posix, "/tmp/a\\b"),
|
||||
RenderCase::round_trips(
|
||||
@@ -466,6 +466,19 @@ fn converts_absolute_api_paths_using_the_inferred_convention() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ambiguous_absolute_api_paths_preserve_their_inferred_convention() {
|
||||
for (raw_path, convention) in [
|
||||
("/C:/secret", PathConvention::Posix),
|
||||
(r"\\localhost\share", PathConvention::Windows),
|
||||
] {
|
||||
let path = LegacyAppPathString::from_string(raw_path);
|
||||
let uri = PathUri::try_from(path.clone()).expect("absolute API path should convert");
|
||||
assert_eq!(uri.infer_path_convention(), Some(convention));
|
||||
assert_eq!(LegacyAppPathString::from(uri), path);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn converts_native_api_path_to_inferred_absolute_path() {
|
||||
#[cfg(windows)]
|
||||
|
||||
Reference in New Issue
Block a user