mirror of
https://github.com/openai/codex.git
synced 2026-09-06 15:29:32 +00:00
Reject Windows proxies without elevated sandbox
This commit is contained in:
@@ -173,25 +173,29 @@ fn windows_network_proxy_requires_elevated_only_sandbox_requirement() {
|
||||
|
||||
#[test]
|
||||
fn windows_network_proxy_requires_elevated_sandbox() {
|
||||
let err = validate_windows_sandbox_network_proxy_compatibility_for_platform(
|
||||
/*is_windows*/ true,
|
||||
for windows_sandbox_level in [
|
||||
WindowsSandboxLevel::Disabled,
|
||||
WindowsSandboxLevel::RestrictedToken,
|
||||
/*network_proxy_configured*/ true,
|
||||
)
|
||||
.expect_err("unelevated Windows sandbox should reject configured network proxy");
|
||||
] {
|
||||
let err = validate_windows_sandbox_network_proxy_compatibility_for_platform(
|
||||
/*is_windows*/ true,
|
||||
windows_sandbox_level,
|
||||
/*network_proxy_configured*/ true,
|
||||
)
|
||||
.expect_err("non-elevated Windows sandbox should reject configured network proxy");
|
||||
|
||||
assert!(matches!(
|
||||
err.get_ref()
|
||||
.and_then(|source| source.downcast_ref::<ConstraintError>()),
|
||||
Some(ConstraintError::NetworkProxyIncompatibleWithUnelevatedWindowsSandbox)
|
||||
));
|
||||
assert!(matches!(
|
||||
err.get_ref()
|
||||
.and_then(|source| source.downcast_ref::<ConstraintError>()),
|
||||
Some(ConstraintError::NetworkProxyIncompatibleWithUnelevatedWindowsSandbox)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_network_proxy_compatibility_allows_valid_combinations() -> std::io::Result<()> {
|
||||
for (windows_sandbox_level, network_proxy_configured) in [
|
||||
(WindowsSandboxLevel::Disabled, false),
|
||||
(WindowsSandboxLevel::Disabled, true),
|
||||
(WindowsSandboxLevel::RestrictedToken, false),
|
||||
(WindowsSandboxLevel::Elevated, false),
|
||||
(WindowsSandboxLevel::Elevated, true),
|
||||
|
||||
@@ -615,7 +615,7 @@ fn validate_windows_sandbox_network_proxy_compatibility_for_platform(
|
||||
) -> std::io::Result<()> {
|
||||
if is_windows
|
||||
&& network_proxy_configured
|
||||
&& windows_sandbox_level == WindowsSandboxLevel::RestrictedToken
|
||||
&& windows_sandbox_level != WindowsSandboxLevel::Elevated
|
||||
{
|
||||
return Err(ConstraintError::NetworkProxyIncompatibleWithUnelevatedWindowsSandbox.into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user