Files
sigma-rules/tests/base.py
T

27 lines
897 B
Python
Raw Normal View History

# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
"""Shared resources for tests."""
import unittest
from detection_rules import rule_loader
2021-03-24 10:24:32 -06:00
from detection_rules.rule import TOMLRule
class BaseRuleTest(unittest.TestCase):
"""Base class for shared test cases which need to load rules"""
@classmethod
def setUpClass(cls):
cls.rule_files = rule_loader.load_rule_files(verbose=False)
cls.rule_lookup = rule_loader.load_rules(verbose=False)
cls.rules = cls.rule_lookup.values()
cls.production_rules = rule_loader.get_production_rules()
@staticmethod
2021-03-24 10:24:32 -06:00
def rule_str(rule: TOMLRule, trailer=' ->'):
return f'{rule.id} - {rule.name}{trailer or ""}'