Skip to content

Commit

Permalink
Merge pull request #736 from alanisaac/schema-tests
Browse files Browse the repository at this point in the history
Implement Metaschema
  • Loading branch information
mikeradka authored Nov 14, 2023
2 parents 22c3243 + 60aac04 commit 8285738
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .vscode/settings.json
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"
}
]
}
42 changes: 42 additions & 0 deletions metaschema/attribute.schema.json
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"]
}
}
}
75 changes: 75 additions & 0 deletions metaschema/event.schema.json
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
}
85 changes: 85 additions & 0 deletions metaschema/object.schema.json
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"
}
}
}
}

0 comments on commit 8285738

Please sign in to comment.