Port historical schemas to jsonschema (#1084)

* Port historical schemas to jsonschema
* Add marshmallow-json dependency
* Mark etc/api_schemas as binary
* Remove gitattributes attempt
* Lint fix
* Apply PR feedback
* Additional PR feedback
* Extract stack version from packages.yml
* Fix the backport schemas
* Cache the schema reads
* Add migration for #1167
* Make a separate 'migration not found' error
This commit is contained in:
Ross Wolf
2021-05-13 14:27:32 -06:00
committed by GitHub
parent e40276c12b
commit eb40c52c7c
56 changed files with 25134 additions and 560 deletions
+5 -3
View File
@@ -6,6 +6,7 @@
import copy
import datetime
import os
import typing
from pathlib import Path
from typing import List
@@ -17,7 +18,7 @@ from . import ecs
from .attack import matrix, tactics, build_threat_map_entry
from .rule import TOMLRule, TOMLRuleContents
from .rule_loader import RuleCollection, DEFAULT_RULES_DIR, dict_filter
from .schemas import CurrentSchema
from .schemas import definitions
from .utils import clear_caches, get_path
RULES_DIR = get_path("rules")
@@ -111,9 +112,10 @@ def rule_prompt(path=None, rule_type=None, required_only=True, save=True, verbos
kwargs.update(kwargs.pop('rule'))
rule_type = rule_type or kwargs.get('type') or \
click.prompt('Rule type', type=click.Choice(CurrentSchema.RULE_TYPES))
click.prompt('Rule type', type=click.Choice(typing.get_args(definitions.RuleType)))
schema = CurrentSchema.get_schema(role=rule_type)
target_data_subclass = TOMLRuleContents.get_data_subclass(rule_type)
schema = target_data_subclass.jsonschema()
props = schema['properties']
opt_reqs = schema.get('required', [])
contents = {}