L4-6: Non-CONNECT HTTP method -> rejected with 403.
(
sandbox: Callable[..., Sandbox],
)
| 567 | |
| 568 | |
| 569 | def test_l4_non_connect_method_rejected( |
| 570 | sandbox: Callable[..., Sandbox], |
| 571 | ) -> None: |
| 572 | """L4-6: Non-CONNECT HTTP method -> rejected with 403.""" |
| 573 | |
| 574 | def send_get_to_proxy() -> str: |
| 575 | import socket |
| 576 | |
| 577 | conn = socket.create_connection(("10.200.0.1", 3128), timeout=10) |
| 578 | try: |
| 579 | conn.sendall( |
| 580 | b"GET http://example.com/ HTTP/1.1\r\nHost: example.com\r\n\r\n" |
| 581 | ) |
| 582 | return conn.recv(256).decode("latin1") |
| 583 | finally: |
| 584 | conn.close() |
| 585 | |
| 586 | policy = _base_policy( |
| 587 | network_policies={ |
| 588 | "any": sandbox_pb2.NetworkPolicyRule( |
| 589 | name="any", |
| 590 | endpoints=[ |
| 591 | sandbox_pb2.NetworkEndpoint(host="example.com", port=443), |
| 592 | ], |
| 593 | binaries=[sandbox_pb2.NetworkBinary(path="/**")], |
| 594 | ), |
| 595 | }, |
| 596 | ) |
| 597 | spec = datamodel_pb2.SandboxSpec(policy=policy) |
| 598 | with sandbox(spec=spec, delete_on_exit=True) as sb: |
| 599 | result = sb.exec_python(send_get_to_proxy) |
| 600 | assert result.exit_code == 0, result.stderr |
| 601 | assert "403" in result.stdout |
| 602 | |
| 603 | |
| 604 | def test_l4_log_fields( |
nothing calls this directly
no test coverage detected