-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #736 from alanisaac/schema-tests
Implement Metaschema
- Loading branch information
Showing
4 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"json.schemas": [ | ||
{ | ||
"url": "./metaschema/attribute.schema.json" | ||
}, | ||
{ | ||
"fileMatch": [ | ||
"/objects/**/*.json" | ||
], | ||
"url": "./metaschema/object.schema.json" | ||
}, | ||
{ | ||
"fileMatch": [ | ||
"/events/**/*.json" | ||
], | ||
"url": "./metaschema/event.schema.json" | ||
} | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"$id": "https://schema.ocsf.io/attribute.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "Attribute", | ||
"type": "object", | ||
"properties": { | ||
"caption": { | ||
"type": "string", | ||
"description": "A short, more specific identifier for this attribute." | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "The description of the attribute." | ||
}, | ||
"enum": { | ||
"type": "object", | ||
"description": "An enumeration of options for this attribute.", | ||
"additionalProperties": { | ||
"type": "object", | ||
"required": [ | ||
"caption" | ||
], | ||
"properties": { | ||
"caption": { | ||
"type": "string", | ||
"description": "The caption of this enum value." | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "The description of this enum value." | ||
}, | ||
"additionalProperties": false | ||
} | ||
} | ||
}, | ||
"requirement": { | ||
"type": "string", | ||
"description": "The requirement placed on the attribute for inclusion in the schema.", | ||
"enum": ["optional", "recommended", "required"] | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
"$id": "https://schema.ocsf.io/event.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "Event", | ||
"allOf": [ | ||
{ | ||
"$ref": "object.schema.json" | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"associations": { | ||
"type": "object", | ||
"description": "Associations indicate attributes in a schema which 'go together'. For example, if a schema has multiple users and multiple endpoints, associations can indicate which user attribute goes with which endpoint.", | ||
"additionalProperties": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"attributes": { | ||
"type": "object", | ||
"description": "A dictionary of attributes for the event.", | ||
"properties": { | ||
"$include": { | ||
"description": "A reference to another schema for attributes to include.", | ||
"oneOf": [ | ||
{ | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"additionalProperties": { | ||
"allOf": [ | ||
{ | ||
"$ref": "attribute.schema.json" | ||
}, | ||
{ | ||
"properties": { | ||
"group": { | ||
"type": "string", | ||
"description": "The group that the attribute is a part of.", | ||
"enum": ["context", "classification", "occurrence", "primary"] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"category": { | ||
"type": "string", | ||
"description": "The category that the event belongs to.", | ||
"enum": ["system", "findings", "iam", "network", "discovery", "application", "other"] | ||
}, | ||
"uid": { | ||
"type": "integer", | ||
"description": "A unique identifier for this event, must be unique within the category.", | ||
"minimum": 0, | ||
"maximum": 999 | ||
} | ||
} | ||
} | ||
], | ||
"unevaluatedProperties": false | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"$id": "https://schema.ocsf.io/object.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "Object", | ||
"type": "object", | ||
"anyOf": [ | ||
{ | ||
"required": [ | ||
"description", | ||
"caption", | ||
"name", | ||
"attributes" | ||
] | ||
}, | ||
{ | ||
"required": [ | ||
"extends" | ||
] | ||
} | ||
], | ||
"properties": { | ||
"description": { | ||
"type": "string", | ||
"description": "A concise description of the object." | ||
}, | ||
"caption": { | ||
"type": "string", | ||
"description": "A short, human friendly name for the object." | ||
}, | ||
"name": { | ||
"type": "string", | ||
"description": "A name of the object. It must be a unique name. The name is all lower case letters, combine words using underscore.", | ||
"pattern": "^[a-z0-9_]*$" | ||
}, | ||
"extends": { | ||
"type": "string", | ||
"description": "An object that this one extends from." | ||
}, | ||
"constraints": { | ||
"type": "object", | ||
"description": "Constraints that apply to the attribute requirements.", | ||
"properties": { | ||
"at_least_one": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
}, | ||
"just_one": { | ||
"type": "array", | ||
"items": {"type": "string"} | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"profiles": { | ||
"type": "array", | ||
"items": {"type": "string"}, | ||
"description": "The list of profiles used to create the event." | ||
}, | ||
"attributes": { | ||
"type": "object", | ||
"description": "A dictionary of attributes for the object.", | ||
"properties": { | ||
"$include": { | ||
"description": "A reference to another schema for attributes to include.", | ||
"oneOf": [ | ||
{ | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"additionalProperties": { | ||
"$ref": "attribute.schema.json" | ||
} | ||
} | ||
} | ||
} |