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

Enum reuse

Open alanisaac opened this issue 4 months ago • 4 comments

Background

In OCSF, there are a few standard conventions for enums. Typically:

  • There are two attributes that define an enum, one suffixed with _id that takes on an integer value, and one with no suffix that is typed as a string. The string attribute takes on the value of the caption of the _id field.
  • When the enum id attribute is defined, it uses the enum property to define a set of valid enum values for the attribute. These are defined in-line with each attribute.

There are times where these conventions are broken, but this is the pattern for the majority of enums.

Issue

Because the enums are defined in-line for each attribute in the dictionary, it means that if two attributes have the same enum values (the same conceptual "enum") that set of valid values are defined twice. One example of this duplication is prev_security_level_id and security_level_id define the same enum.

While it doesn't occur with high frequency in the base OCSF schema, I'm writing an extension that has a few more "previous" and "current" fields, and the enum values have useful but long descriptions. Ideally, I could write the enum once as a type, and reuse it in multiple attributes.

  • Does OCSF support enums-as-types out of the box? I haven't seen any examples of it, so I am not sure
    • If it does support this, should it be the convention for enums so duplication is reduced?
    • If it does not support this, is it something that could be enhanced in the framework?

Generally, defining enums as types is common for object-oriented languages, from which OCSF derives a number of other definition conventions (inheritance, profiles (mixins), etc.), so it feels like something that would be in-line with the design philosophy.

alanisaac avatar Oct 21 '24 14:10 alanisaac