diff --git a/detection_rules/schemas/__init__.py b/detection_rules/schemas/__init__.py index 2787dcf19..c3b508fdb 100644 --- a/detection_rules/schemas/__init__.py +++ b/detection_rules/schemas/__init__.py @@ -3,15 +3,15 @@ # 2.0; you may not use this file except in compliance with the Elastic License # 2.0. import json +from pathlib import Path from typing import Dict, List, Optional import jsonschema +from . import definitions from .rta_schema import validate_rta_mapping from ..semver import Version from ..utils import cached, get_etc_path, load_etc_dump -from . import definitions -from pathlib import Path __all__ = ( @@ -139,7 +139,7 @@ def downgrade_threshold_to_7_11(version: Version, api_contents: dict) -> dict: @migrate("7.12") def migrate_to_7_12(version: Version, api_contents: dict) -> dict: - """Default migration for 7.9.""" + """Default migration for 7.12.""" return strip_additional_properties(version, api_contents) @@ -160,6 +160,12 @@ def downgrade_ml_multijob_713(version: Version, api_contents: dict) -> dict: return strip_additional_properties(version, api_contents) +@migrate("7.14") +def migrate_to_7_14(version: Version, api_contents: dict) -> dict: + """Default migration for 7.14.""" + return strip_additional_properties(version, api_contents) + + def downgrade(api_contents: dict, target_version: str, current_version: Optional[str] = None) -> dict: """Downgrade a rule to a target stack version.""" from ..packaging import current_stack_version diff --git a/etc/stack-schema-map.yaml b/etc/stack-schema-map.yaml index c8ae96e14..f5e1d5fd3 100644 --- a/etc/stack-schema-map.yaml +++ b/etc/stack-schema-map.yaml @@ -10,3 +10,7 @@ "7.14.0": beats: "7.14.0" ecs: "1.11.0" + +"7.15.0": + beats: "master" # TODO: update this once beats releases + ecs: "1.11.0" diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 68ed2a3d1..9b129d88b 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -10,9 +10,11 @@ import uuid import eql +from detection_rules import utils from detection_rules.packaging import load_current_package_version from detection_rules.rule import TOMLRuleContents from detection_rules.schemas import downgrade +from detection_rules.semver import Version class TestSchemas(unittest.TestCase): @@ -194,3 +196,14 @@ class TestSchemas(unittest.TestCase): build_rule(""" process where process.pid == "some string field" """) + + +class TestVersions(unittest.TestCase): + """Test that schema versioning aligns.""" + + def test_stack_schema_map(self): + """Test to ensure that an entry exists in the stack-schema-map for the current package version.""" + package_version = Version(load_current_package_version()) + stack_map = utils.load_etc_dump('stack-schema-map.yaml') + err_msg = f'There is no entry defined for the current package ({package_version}) in the stack-schema-map' + self.assertIn(package_version, [Version(v)[:2] for v in stack_map], err_msg)