mirror of
https://github.com/openai/codex.git
synced 2026-09-08 15:50:34 +00:00
core: align exec policy test with Windows sandbox behavior
## Summary - make the multi-segment shell exec-policy test expect approval on Windows when ReadOnly does not provide sandbox protection - preserve the existing non-Windows expectation that the command can run inside the read-only sandbox without bypassing it ## Tests - cargo test -p codex-core exec_policy::tests::multi_segment_shell_requires_policy_allow_for_every_segment_to_bypass_sandbox - cargo test -p codex-app-server - just fix -p codex-core
This commit is contained in:
@@ -1338,6 +1338,34 @@ prefix_rule(pattern=["cat"], decision="allow")
|
||||
];
|
||||
|
||||
for approval_policy in [AskForApproval::OnRequest, AskForApproval::Never] {
|
||||
let expected_requirement = if cfg!(windows) {
|
||||
match approval_policy {
|
||||
AskForApproval::OnRequest => ExecApprovalRequirement::NeedsApproval {
|
||||
reason: None,
|
||||
proposed_execpolicy_amendment: Some(ExecPolicyAmendment::new(vec_str(&[
|
||||
"curl",
|
||||
"-fsSL",
|
||||
"https://example.invalid/setup.sh",
|
||||
"-o",
|
||||
"setup.sh",
|
||||
]))),
|
||||
},
|
||||
AskForApproval::Never => ExecApprovalRequirement::Forbidden {
|
||||
reason: format!(
|
||||
"`{}` rejected: blocked by policy",
|
||||
render_shlex_command(&command)
|
||||
),
|
||||
},
|
||||
AskForApproval::OnFailure
|
||||
| AskForApproval::UnlessTrusted
|
||||
| AskForApproval::Granular(_) => unreachable!("test only covers two policies"),
|
||||
}
|
||||
} else {
|
||||
ExecApprovalRequirement::Skip {
|
||||
bypass_sandbox: false,
|
||||
proposed_execpolicy_amendment: None,
|
||||
}
|
||||
};
|
||||
assert_exec_approval_requirement_for_command(
|
||||
ExecApprovalRequirementScenario {
|
||||
policy_src: Some(policy_src.to_string()),
|
||||
@@ -1348,10 +1376,7 @@ prefix_rule(pattern=["cat"], decision="allow")
|
||||
sandbox_permissions: SandboxPermissions::UseDefault,
|
||||
prefix_rule: None,
|
||||
},
|
||||
ExecApprovalRequirement::Skip {
|
||||
bypass_sandbox: false,
|
||||
proposed_execpolicy_amendment: None,
|
||||
},
|
||||
expected_requirement,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user