L7-T7: L7 request logging includes structured fields.
(
sandbox: Callable[..., Sandbox],
)
| 1167 | |
| 1168 | |
| 1169 | def test_l7_tls_log_fields( |
| 1170 | sandbox: Callable[..., Sandbox], |
| 1171 | ) -> None: |
| 1172 | """L7-T7: L7 request logging includes structured fields.""" |
| 1173 | policy = _base_policy( |
| 1174 | network_policies={ |
| 1175 | "anthropic": sandbox_pb2.NetworkPolicyRule( |
| 1176 | name="anthropic", |
| 1177 | endpoints=[ |
| 1178 | sandbox_pb2.NetworkEndpoint( |
| 1179 | host="api.anthropic.com", |
| 1180 | port=443, |
| 1181 | protocol="rest", |
| 1182 | tls="terminate", |
| 1183 | enforcement="enforce", |
| 1184 | access="full", |
| 1185 | ), |
| 1186 | ], |
| 1187 | binaries=[sandbox_pb2.NetworkBinary(path="/**")], |
| 1188 | ), |
| 1189 | }, |
| 1190 | ) |
| 1191 | spec = datamodel_pb2.SandboxSpec(policy=policy) |
| 1192 | with sandbox(spec=spec, delete_on_exit=True) as sb: |
| 1193 | sb.exec_python( |
| 1194 | _proxy_connect_then_http(), |
| 1195 | args=("api.anthropic.com", 443, "GET", "/v1/models"), |
| 1196 | ) |
| 1197 | |
| 1198 | log_result = sb.exec_python(_read_openshell_log()) |
| 1199 | assert log_result.exit_code == 0, log_result.stderr |
| 1200 | log = log_result.stdout |
| 1201 | |
| 1202 | # OCSF shorthand: L7 requests show as HTTP:method events |
| 1203 | assert "HTTP:" in log, "Expected OCSF HTTP activity event in log" |
| 1204 | assert "ALLOWED" in log or "DENIED" in log, "Expected L7 decision in log" |
| 1205 | assert "policy:" in log, "Expected policy context in log" |
| 1206 | |
| 1207 | |
| 1208 | def test_l7_query_matchers_enforced( |
nothing calls this directly
no test coverage detected