Skip to content

Commit

Permalink
Fix: FieldnameLogosurceValidator on correlation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspatzke committed Jul 14, 2024
1 parent 61356c8 commit f18ac8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sigma/validators/core/logsources.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class FieldnameLogsourceIssue(SigmaValidationIssue):

class FieldnameLogsourceValidator(SigmaRuleValidator):
def validate(self, rule: SigmaRule) -> List[SigmaValidationIssue]:
if rule.logsource.custom_attributes:
if isinstance(rule, SigmaRule) and rule.logsource.custom_attributes:
return [
FieldnameLogsourceIssue(rules=[rule], fieldname=name)
for name in rule.logsource.custom_attributes
Expand Down
15 changes: 13 additions & 2 deletions tests/test_validators_logsource.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from wsgiref.validate import validator

from sigma.collection import SigmaCollection
from sigma.correlations import SigmaCorrelationRule
from sigma.rule import SigmaRule

from sigma.validators.core.logsources import FieldnameLogsourceIssue, FieldnameLogsourceValidator
from .test_conversion_correlations import event_count_correlation_rule


def test_fieldnamelogsourcevalidator_valid():
Expand Down Expand Up @@ -83,3 +84,13 @@ def test_fieldnamelogsourcevalidator_many_invalid():
FieldnameLogsourceIssue(rule, "editor"),
FieldnameLogsourceIssue(rule, "description"),
]


def test_fieldnamelogsourcevalidator_correlation_rule(event_count_correlation_rule):
validator = FieldnameLogsourceValidator()
correlation_rule = [
rule
for rule in event_count_correlation_rule.rules
if isinstance(rule, SigmaCorrelationRule)
][0]
assert validator.validate(correlation_rule) == []

0 comments on commit f18ac8a

Please sign in to comment.