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],
)
| 414 | |
| 415 | |
| 416 | def 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 | |
| 444 | def test_l4_wildcard_binary_allows_any_binary( |
nothing calls this directly
no test coverage detected