ocsf-server icon indicating copy to clipboard operation
ocsf-server copied to clipboard

JSON schema improvements - Add constraints, enum values

Open floydtree opened this issue 1 year ago • 2 comments

The current json-schema, e.g. https://schema.ocsf.io/schema/1.3.0/objects/network_endpoint doesn't include the data-type constraints defined in the dictionary - https://github.com/ocsf/ocsf-schema/blob/main/dictionary.json#L4839.

These constraints are in the form of regex, max_length, range and values. All these can be represented in the json-schema that is rendered by our server, helping json-schema based validation use-cases and perform value specific validation. JSON spec has a few built-in string formats that can be leveraged as well.

Further, we can also add constant values for attributes such as class_name, category_name etc, as we render the json-schema of an event class.

References -

  1. https://json-schema.org/understanding-json-schema/reference/const
  2. https://json-schema.org/understanding-json-schema/reference/regular_expressions
  3. https://json-schema.org/understanding-json-schema/reference/string
  4. https://json-schema.org/understanding-json-schema/reference/numeric#range

We should also include "additionalProperties": false, key in the generated schema to make validation use-cases more feasible. (for each object definition and the event class definition) https://github.com/ocsf/ocsf-server/pull/112


The string sibling values should also be added as an enum for the corresponding properties


Add requirements based on OCSF "constraints"

floydtree avatar Sep 10 '24 18:09 floydtree

@floydtree was this resolved by https://github.com/ocsf/ocsf-server/pull/112? Could it be closed out or does it need additional effort?

mikeradka avatar Jan 09 '25 19:01 mikeradka

@mikeradka nope, it was partially fixed. There are a few more to go.

floydtree avatar Feb 06 '25 16:02 floydtree