forked from SigmaHQ/pySigma-validators-sigmaHQ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetadata.py
More file actions
28 lines (21 loc) · 940 Bytes
/
Copy pathmetadata.py
File metadata and controls
28 lines (21 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from dataclasses import dataclass
from typing import ClassVar, List
from sigma.correlations import SigmaCorrelationRule
from sigma.rule import SigmaRule
from sigma.validators.base import (
SigmaRuleValidator,
SigmaValidationIssue,
SigmaValidationIssueSeverity,
)
@dataclass
class SigmahqLicenseIssue(SigmaValidationIssue):
description: ClassVar[str] = "Rule has a malformed 'license' field (has to be a string)."
severity: ClassVar[SigmaValidationIssueSeverity] = SigmaValidationIssueSeverity.MEDIUM
class SigmahqLicenseValidator(SigmaRuleValidator):
"""Checks if a rule has a malformed 'license' field."""
def validate(self, rule: SigmaRule | SigmaCorrelationRule) -> List[SigmaValidationIssue]:
if not isinstance(rule, SigmaRule):
return []
if rule.license is not None and not isinstance(rule.license, str):
return [SigmahqLicenseIssue([rule])]
return []