Skip to content

Commit f68db91

Browse files
committed
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 <[email protected]>
1 parent c5850d7 commit f68db91

29 files changed

Lines changed: 145724 additions & 25 deletions

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ crates/openshell-core/src/proto/openshell.*.rs linguist-generated
1111

1212
# Vendored OCSF schemas fetched from schema.ocsf.io
1313
crates/openshell-ocsf/schemas/** linguist-generated
14+
crates/openshell-ocsf-validate/schemas/v*/** linguist-generated

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Do not rely on this file for a full inventory. The detailed public and contribut
3535
| `crates/openshell-bootstrap/` | Gateway metadata | Gateway registration metadata, auth token storage, mTLS bundle storage |
3636
| `crates/openshell-gateway-interceptors/` | Gateway interceptors | Intercepts and transforms configured gRPC requests at the gateway routing boundary |
3737
| `crates/openshell-ocsf/` | OCSF logging | OCSF v1.8.0 event types, builders, shorthand/JSONL formatters, tracing layers |
38+
| `crates/openshell-ocsf-validate/` | OCSF validation | Test-time validation of OCSF events against vendored OCSF JSON Schemas |
3839
| `crates/openshell-otel/` | OpenTelemetry support | Shared OTLP trace provider, resource, and tracing-layer construction |
3940
| `crates/openshell-otel-test-support/` | OpenTelemetry test support | Shared loopback OTLP collector fixture for tracing tests |
4041
| `crates/openshell-crypto/` | Crypto backend | Backend-neutral primitives and TLS, PKI, JWT adapters; AWS-LC implementation |

0 commit comments

Comments
 (0)