ocsf / ocsf-validator

OCSF Schema Validation
Apache License 2.0
9 stars 5 forks source link

Fixed validation to not merge dependencies into categories #22

Closed alanisaac closed 7 months ago

alanisaac commented 7 months ago

Currently the ocsf-validator is treating the attributes tag of categories the same as any other attributes, which involves merging them with the dictionary. This is incorrect behavior, as attributes of categories do not have any of the characteristics imbued by the dictionary.

This is currently causing a problem in https://github.com/ocsf/ocsf-schema/pull/1066, which adds a remediation category, because remediation is an event attribute elsewhere, with an entry in the dictionary.

This PR changes the validator's logic, such that categories are skipped when the validator merges in dependencies (a.k.a. extends, profiles, includes, or advanced attributes) as categories should have none of these.

Tested against the branch from the PR above, and it fixes the original problem:

SUMMARY
   PASSED: Schema definitions can be loaded
   PASSED: Schema types can be inferred
   PASSED: Check observable type_id definitions
   PASSED: Dependency targets are resolvable and exist
   PASSED: Required keys are present
   PASSED: There are no unrecognized keys
   PASSED: All attributes in the dictionary are used
   PASSED: All attributes are defined in dictionary.json
   PASSED: Names are not used multiple times within a record type
   PASSED: Attribute type references are defined
   PASSED: Event class categories are defined
   PASSED: JSON files match their metaschema definition