MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / test_l4_no_policy_denies_all

Function test_l4_no_policy_denies_all

e2e/python/test_sandbox_policy.py:416–441  ·  view source on GitHub ↗

L4-1: No matching endpoint in any network policy -> CONNECT denied. We need at least one network policy so the proxy and network namespace start (empty network_policies disables networking entirely, including socket syscalls). The policy allows python->example.com:443 but api.anthro

(
    sandbox: Callable[..., Sandbox],
)

Source from the content-addressed store, hash-verified

414
415
416def test_l4_no_policy_denies_all(
417 sandbox: Callable[..., Sandbox],
418) -> None:
419 """L4-1: No matching endpoint in any network policy -> CONNECT denied.
420
421 We need at least one network policy so the proxy and network namespace
422 start (empty network_policies disables networking entirely, including
423 socket syscalls). The policy allows python->example.com:443 but
424 api.anthropic.com:443 should still be denied.
425 """
426 policy = _base_policy(
427 network_policies={
428 "other": sandbox_pb2.NetworkPolicyRule(
429 name="other",
430 endpoints=[
431 sandbox_pb2.NetworkEndpoint(host="example.com", port=443),
432 ],
433 binaries=[sandbox_pb2.NetworkBinary(path="/**")],
434 ),
435 },
436 )
437 spec = datamodel_pb2.SandboxSpec(policy=policy)
438 with sandbox(spec=spec, delete_on_exit=True) as sb:
439 result = sb.exec_python(_proxy_connect(), args=("api.anthropic.com", 443))
440 assert result.exit_code == 0, result.stderr
441 assert "403" in result.stdout
442
443
444def test_l4_wildcard_binary_allows_any_binary(

Callers

nothing calls this directly

Calls 4

_base_policyFunction · 0.85
_proxy_connectFunction · 0.85
sandboxFunction · 0.70
exec_pythonMethod · 0.45

Tested by

no test coverage detected