Skip to content

Commit

Permalink
Merge pull request #162 from Res260/fixvalidators
Browse files Browse the repository at this point in the history
Fix a bug in InvalidRelatedTypeValidator, InvalidRelatedSubfieldValid…
  • Loading branch information
thomaspatzke authored Nov 14, 2023
2 parents 1233ae6 + 4fa7ad7 commit 66a31ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sigma/validators/core/metadata.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import re

from collections import Counter
from collections import defaultdict
from dataclasses import dataclass
from typing import ClassVar, Dict, List
from uuid import UUID

from sigma.rule import SigmaRule
from sigma.validators.base import (
SigmaRuleValidator,
Expand Down Expand Up @@ -143,7 +143,7 @@ def __init__(self) -> None:
self.allowed_type = {"derived", "obsoletes", "merged", "renamed", "similar"}

def validate(self, rule: SigmaRule) -> List[SigmaValidationIssue]:
if rule.custom_attributes["related"]:
if rule.custom_attributes.get("related"):
return [
InvalidRelatedTypeIssue([rule], value["type"])
for value in rule.custom_attributes["related"]
Expand All @@ -163,7 +163,7 @@ class InvalidRelatedIdValidator(SigmaRuleValidator):
"""Validate rule related id format."""

def validate(self, rule: SigmaRule) -> List[SigmaValidationIssue]:
if rule.custom_attributes["related"]:
if rule.custom_attributes.get("related"):
return [
InvalidRelatedIdIssue([rule], value["id"])
for value in rule.custom_attributes["related"]
Expand All @@ -183,7 +183,7 @@ class InvalidRelatedSubfieldValidator(SigmaRuleValidator):
"""Validate rule related subfield name."""

def validate(self, rule: SigmaRule) -> List[SigmaValidationIssue]:
if rule.custom_attributes["related"]:
if rule.custom_attributes.get("related"):
return [
InvalidRelatedSubfieldIssue([rule], value_key)
for value in rule.custom_attributes["related"]
Expand Down

0 comments on commit 66a31ea

Please sign in to comment.