Files
OpenShell/crates/openshell-supervisor-network
krishicks af6604a617 feat(ocsf): validate OCSF events against exported JSON Schemas (#5019)
* feat(ocsf): add JSON Schema validator for OCSF events

Add openshell-ocsf-validate, which validates an OCSF event against the
JSON Schema the OCSF schema server exports for the event's version,
class, and declared profiles. The exports encode required attributes,
at_least_one constraints, undefined attributes, types, and enum values,
so the crate delegates to the jsonschema crate and only selects the
schema. The exports type type_uid only as an integer, so the crate also
checks that it equals class_uid * 100 + activity_id.

An exported schema covers one fixed set of profiles, so the crate vendors
one export per class and profile combination that OpenShell emits, under
schemas/v<version>/<class>@<profiles>.json. An event whose version or
combination has no vendored schema fails with the schemas/update.sh
command that vendors it. Keying on the event's version lets a new OCSF
version's schemas land before the emitters switch to it. The build
embeds every vendored file.

Top-level container is accepted unvalidated, as OCSF does not define it
at the event level (#4915).

Signed-off-by: Kris Hicks <khicks@nvidia.com>

* test(ocsf): validate OCSF events with openshell-ocsf-validate

Replace openshell-ocsf's hand-written schema walker with
openshell-ocsf-validate in the builder, producer, gateway audit and
Podman e2e tests. One validate_event call now covers what the
per-object validate_required_fields, validate_known_fields and
validate_enum_value calls checked, and adds type checks and enum
checks for every attribute.

Remove the validation module and the vendored OCSF object and class
schemas from openshell-ocsf. The e2e suite no longer depends on
openshell-ocsf directly.

Signed-off-by: Kris Hicks <khicks@nvidia.com>

---------

Signed-off-by: Kris Hicks <khicks@nvidia.com>
2026-10-29 00:44:47 +00:00
..

Network supervisor

This crate forbids unsafe code, including its local tests. Typed socket APIs provide original-destination lookup for transparent proxying.

Socket attribution tests pass a duplicate connected socket as a spawned child's stdin. Re-executing the test binary checks multiple holders with the same binary identity; executing a different binary checks ambiguous shared-socket identity. The fixture kills and reaps the child when the parent test ends.

The manual proxy performance baseline still counts allocations. Its test-only global allocator uses openshell-driver-vm::allocation_tracking; the unsafe allocator implementation belongs to the VM crate. The VM dependency disables default features, so this instrumentation does not require the compute runtime or Unix-only sandbox library. It is a development dependency only.

Sandbox instance inputs

run_networking takes a SandboxInstanceNetwork with the sandbox identity, the sandbox instance's GatewayEndpoint, the SPIFFE Workload API socket for provider token grants, the policy.local denial source, and proxy CA files. None of these are read from the process environment, so one process can run several sandbox instances. Each instance owns its provider token cache and HTTP client; a token acquired for one sandbox is never served to another. Without a Workload API socket, token grants fail closed. A process hosting several instances serves /v1/denials from a per-instance SandboxInstanceDenialLog instead of the shared shorthand log files.

Reserved destinations

preauthorize_transparent_open matches a staged TCP open against the reserved OTLP relay address (openshell_core::sandbox_env::OTLP_RELAY_ADDR) before host mapping, policy evaluation, and SSRF checks. The address is an unroutable label, so the proxy never dials it. When run_networking receives a ReservedDestination, the proxy hands the workload stream to its ReservedStreamHandler; a handler that refuses, for example at its connection cap, turns the open into a resource-exhausted denial. Without a handler, the proxy denies the open at once. It logs the first attempt at warn and later ones at debug, and emits no OCSF denial event: a standard OpenTelemetry SDK retries for the life of the agent, and one event per retry would flood the OCSF log. The supervisor installs its OTLP relay receiver as the handler while the agent trace relay is active.