From b12437c88cc2b0d283c98bef37998a8baf8b23bc Mon Sep 17 00:00:00 2001 From: Ross Wolf <31489089+rw-access@users.noreply.github.com> Date: Mon, 5 Apr 2021 14:30:26 -0600 Subject: [PATCH] Remove dead code in the rule loader --- detection_rules/rule_loader.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/detection_rules/rule_loader.py b/detection_rules/rule_loader.py index 381a44f99..66596aba7 100644 --- a/detection_rules/rule_loader.py +++ b/detection_rules/rule_loader.py @@ -14,7 +14,7 @@ import pytoml from .mappings import RtaMappings from .rule import TOMLRule, TOMLRuleContents -from .schemas import CurrentSchema, definitions +from .schemas import definitions from .utils import get_path, cached DEFAULT_RULES_DIR = Path(get_path("rules")) @@ -255,24 +255,6 @@ def load_github_pr_rules(labels: list = None, repo: str = 'elastic/detection-rul return new, modified, errors -@cached -def get_non_required_defaults_by_type(rule_type: str) -> dict: - """Get list of fields which are not required for a specified rule type.""" - schema = CurrentSchema.get_schema(rule_type) - properties = schema['properties'] - non_required_defaults = {prop: properties[prop].get('default') for prop in properties - if prop not in schema['required'] and 'default' in properties[prop]} - return non_required_defaults - - -def find_unneeded_defaults_from_rule(toml_contents: dict) -> dict: - """Remove values that are not required in the schema which are set with default values.""" - unrequired_defaults = get_non_required_defaults_by_type(toml_contents['rule']['type']) - default_matches = {prop: toml_contents["rule"][prop] for prop, val in unrequired_defaults.items() - if toml_contents["rule"].get(prop) == val} - return default_matches - - rta_mappings = RtaMappings() @@ -280,11 +262,9 @@ __all__ = ( "FILE_PATTERN", "DEFAULT_RULES_DIR", "load_github_pr_rules", - "get_non_required_defaults_by_type", "RuleCollection", "metadata_filter", "production_filter", "dict_filter", - "find_unneeded_defaults_from_rule", "rta_mappings" )