Repository navigation
feat(ocsf): validate OCSF events against exported JSON Schemas - #5019
Merged
Merged
Conversation
This was referenced Oct 28, 2026
krishicks
force-pushed
the
feat/4596-ocsf-json-schema-validation/krishicks
branch
from
October 28, 2026 22:47
c3c8114 to
16f91f1
Compare
TaylorMutch
reviewed
Oct 28, 2026
|
Label |
matthewgrossman
left a comment
Member
There was a problem hiding this comment.
Review summary: no correctness bugs found in the new crate. Two non-blocking concerns inline.
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>
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>
krishicks
force-pushed
the
feat/4596-ocsf-json-schema-validation/krishicks
branch
from
October 28, 2026 23:09
16f91f1 to
a711f9a
Compare
krishicks
enabled auto-merge
October 28, 2026 23:15
TaylorMutch
approved these changes
Oct 29, 2026
8 tasks
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the hand-written OCSF schema walker with validation against the JSON Schemas the OCSF schema server exports. The exports already encode required attributes,
at_least_oneconstraints, undefined attributes, types, and enum values, so the newopenshell-ocsf-validatecrate only picks the schema and delegates to thejsonschemacrate. This adds the enum, type, and class identifier checks #4596 asks for.Related Issue
Closes #4596
Changes
openshell-ocsf-validatecrate (test-only; consumers take it as a dev-dependency).validate_eventselects the schema from the event'smetadata.version,class_uid, and declaredmetadata.profiles, and returns every violation with its JSON pointer path.schemas/v<version>/<class>@<profiles>.json(18 files for 1.8.0). An event with no vendored schema fails with theschemas/update.shcommand that vendors it.metadata.versionlets a new OCSF version's schemas land before the emitters switch to it, then the old version's directory is deleted.containeris accepted unvalidated, as before (bug(ocsf): top-level container is undefined in OCSF 1.8.0 event classes #4915).validate_event;openshell-ocsf'svalidationmodule and its vendored per-object schemas are removed.jsonschema0.58.6 (default features off). It raisesnum-bigint,regex-automata, andzmijin the root lockfile, so the nested testkit and conformance lockfiles are aligned.Reviewing commit by commit separates the new crate from the switch to it.
Testing
openshell-ocsf-validateunit tests (written red first),openshell-ocsf, and the producer tests inopenshell-supervisor-network,openshell-supervisor-process, andopenshell-serverpassmise run pre-commitpassesocsf_jsonl_conformancepasses: real supervisor Network, HTTP, and SSH records validate against the exported schemas (run with the follow-ups from the fix(ocsf): emit schema-conformant OCSF 1.8 events #4288 review on top)Checklist