forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Justin Ibarra <[email protected]> Co-authored-by: brokensound77 <[email protected]> Co-authored-by: Mika Ayenson <[email protected]> Co-authored-by: Mika Ayenson <[email protected]>
- Loading branch information
1 parent
f9717e7
commit 47d7a3a
Showing
48 changed files
with
2,962 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 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. | ||
|
||
"""Dataclasses for Action.""" | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from typing import List, Optional | ||
|
||
from .mixins import MarshmallowDataclassMixin | ||
from .schemas import definitions | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ActionMeta(MarshmallowDataclassMixin): | ||
"""Data stored in an exception's [metadata] section of TOML.""" | ||
creation_date: definitions.Date | ||
rule_id: List[definitions.UUIDString] | ||
rule_name: str | ||
updated_date: definitions.Date | ||
|
||
# Optional fields | ||
deprecation_date: Optional[definitions.Date] | ||
comments: Optional[str] | ||
maturity: Optional[definitions.Maturity] | ||
|
||
|
||
@dataclass | ||
class Action(MarshmallowDataclassMixin): | ||
"""Data object for rule Action.""" | ||
@dataclass | ||
class ActionParams: | ||
"""Data object for rule Action params.""" | ||
body: str | ||
|
||
action_type_id: definitions.ActionTypeId | ||
group: str | ||
params: ActionParams | ||
id: Optional[str] | ||
frequency: Optional[dict] | ||
alerts_filter: Optional[dict] | ||
|
||
|
||
@dataclass(frozen=True) | ||
class TOMLActionContents(MarshmallowDataclassMixin): | ||
"""Object for action from TOML file.""" | ||
metadata: ActionMeta | ||
actions: List[Action] | ||
|
||
|
||
@dataclass(frozen=True) | ||
class TOMLAction: | ||
"""Object for action from TOML file.""" | ||
contents: TOMLActionContents | ||
path: Path | ||
|
||
@property | ||
def name(self): | ||
return self.contents.metadata.rule_name | ||
|
||
@property | ||
def id(self): | ||
return self.contents.metadata.rule_id |
Oops, something went wrong.