mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
Reference writable roots from environment context
This commit is contained in:
@@ -510,7 +510,7 @@ async fn resume_and_fork_append_permissions_messages() -> Result<()> {
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn permissions_message_includes_writable_roots() -> Result<()> {
|
||||
async fn permissions_message_references_environment_context_for_writable_roots() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
@@ -576,6 +576,10 @@ async fn permissions_message_includes_writable_roots() -> Result<()> {
|
||||
.map(|s| normalize_line_endings(s))
|
||||
.collect();
|
||||
assert_eq!(actual_normalized, vec![expected_normalized]);
|
||||
assert!(permissions[0].contains(
|
||||
"Filesystem access is specified by `<entry>` rules in the `<filesystem>` section of `<environment_context>`. An entry's `access` attribute indicates whether its path is readable, writable, or denied. More-specific rules may restrict access within broader paths."
|
||||
));
|
||||
assert!(!permissions[0].contains(writable_root.to_string_lossy().as_ref()));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -259,21 +259,13 @@ fn sandbox_text(mode: SandboxMode, network_access: NetworkAccess) -> String {
|
||||
}
|
||||
|
||||
fn writable_roots_text(writable_roots: Option<Vec<WritableRoot>>) -> Option<String> {
|
||||
let mut roots = writable_roots?;
|
||||
if roots.is_empty() {
|
||||
if writable_roots?.is_empty() {
|
||||
return None;
|
||||
}
|
||||
roots.sort_by(|left, right| left.root.as_path().cmp(right.root.as_path()));
|
||||
|
||||
let roots_list: Vec<String> = roots
|
||||
.iter()
|
||||
.map(|r| format!("`{}`", r.root.to_string_lossy()))
|
||||
.collect();
|
||||
Some(if roots_list.len() == 1 {
|
||||
format!(" The writable root is {}.", roots_list[0])
|
||||
} else {
|
||||
format!(" The writable roots are {}.", roots_list.join(", "))
|
||||
})
|
||||
Some(
|
||||
"Filesystem access is specified by `<entry>` rules in the `<filesystem>` section of `<environment_context>`. An entry's `access` attribute indicates whether its path is readable, writable, or denied. More-specific rules may restrict access within broader paths."
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
|
||||
fn denied_reads_text(file_system_policy: &FileSystemSandboxPolicy, cwd: &Path) -> Option<String> {
|
||||
|
||||
@@ -81,7 +81,10 @@ fn builds_permissions_from_profile() {
|
||||
let text = instructions.body();
|
||||
assert!(text.contains("`sandbox_mode` is `workspace-write`"));
|
||||
assert!(text.contains("Network access is enabled."));
|
||||
assert!(text.contains(writable_root.to_string_lossy().as_ref()));
|
||||
assert!(text.contains(
|
||||
"Filesystem access is specified by `<entry>` rules in the `<filesystem>` section of `<environment_context>`. An entry's `access` attribute indicates whether its path is readable, writable, or denied. More-specific rules may restrict access within broader paths."
|
||||
));
|
||||
assert!(!text.contains(writable_root.to_string_lossy().as_ref()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user