Skip to content

Commit

Permalink
Resolved import loop betwen base and attributes in sigma.rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspatzke committed Nov 3, 2024
1 parent 234ffb5 commit c692b4c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion sigma/rule/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from .rule import SigmaRule
from .logsource import SigmaLogSource
from .detection import SigmaDetection, SigmaDetectionItem, SigmaDetections
from .base import SigmaRuleBase, EnumLowercaseStringMixin, SigmaYAMLLoader
from .base import SigmaRuleBase, SigmaYAMLLoader
from .attributes import (
EnumLowercaseStringMixin,
SigmaStatus,
SigmaLevel,
SigmaRelatedType,
Expand Down
6 changes: 5 additions & 1 deletion sigma/rule/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
from typing import Optional, List, Type
from uuid import UUID
from enum import Enum, auto
from sigma.rule.base import EnumLowercaseStringMixin
import sigma.exceptions as sigma_exceptions
from sigma.exceptions import (
SigmaRuleLocation,
)


class EnumLowercaseStringMixin:
def __str__(self) -> str:
return self.name.lower()


class SigmaStatus(EnumLowercaseStringMixin, Enum):
UNSUPPORTED = auto()
DEPRECATED = auto()
Expand Down
13 changes: 4 additions & 9 deletions sigma/rule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
from sigma.rule.attributes import SigmaLevel, SigmaRelated, SigmaRuleTag, SigmaStatus


class EnumLowercaseStringMixin:
def __str__(self) -> str:
return self.name.lower()


class SigmaYAMLLoader(yaml.SafeLoader):
"""Custom YAML loader implementing additional functionality for Sigma."""

Expand All @@ -35,18 +30,18 @@ class SigmaRuleBase:
id: Optional[UUID] = None
name: Optional[str] = None
taxonomy: str = "sigma"
related: Optional[SigmaRelated] = None
status: Optional[SigmaStatus] = None
related: Optional["sigma.rule.attributes.SigmaRelated"] = None
status: Optional["sigma.rule.attributes.SigmaStatus"] = None
description: Optional[str] = None
license: Optional[str] = None
references: List[str] = field(default_factory=list)
tags: List[SigmaRuleTag] = field(default_factory=list)
tags: List["sigma.rule.attributes.SigmaRuleTag"] = field(default_factory=list)
author: Optional[str] = None
date: Optional["datetime.date"] = None
modified: Optional["datetime.date"] = None
fields: List[str] = field(default_factory=list)
falsepositives: List[str] = field(default_factory=list)
level: Optional[SigmaLevel] = None
level: Optional["sigma.rule.attributes.SigmaLevel"] = None
scope: Optional[List[str]] = None

errors: List[sigma_exceptions.SigmaError] = field(default_factory=list)
Expand Down

0 comments on commit c692b4c

Please sign in to comment.