-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathexample_rule.py
More file actions
70 lines (50 loc) · 1.97 KB
/
Copy pathexample_rule.py
File metadata and controls
70 lines (50 loc) · 1.97 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from panther_base_helpers import pattern_match
## Required
#
# The logic to determine if an alert should send.
# return True = Alert, False = Do not Alert
def rule(event):
return event.get("field") == "value" and event.deep_get("field", "nestedValue")
## Optional Functions
#
# Set custom alert titles, must return a string.
# If not defined, defaults to the rule display name or rule ID.
def title(event):
if pattern_match(event.get("field"), "string*"):
return f"This is my alert title {event.get('field')}"
return f"This is my fallback title {event.get('field')}"
# Set custom deduplication strings, must return a string.
# If not defined, defaults to the alert title.
def dedup(event):
return event.get("identity")
# Additional information append to an alert, must return a dictionary
def alert_context(event):
return {
"someField": event.get("someField"),
"someRandomValue": 4, # chosen by a dice roll, guaranteed to be random
}
## Override Functions
#
# Override the severity of an alert based on the contents of the events,
# must return one of the following strings "INFO", "LOW", "MEDIUM', "HIGH", "CRITICAL"
def severity(event):
if event.get("field") == "value":
return "INFO"
return "HIGH"
# Override the description of the alert, must return a string
def description(event):
return f"Some Alert Description {event.get('Something')}"
# Override the reference in the alert, must return a string
def reference(event):
return f"https://some.com/reference/{event.get('Something')}"
# Override the runbook in the alert, must return a string
def runbook(event):
return f"If this happens, do {event.get('Something')}"
# Override the destination(s) the alert is sent to, must return a list of strings corresponding to
# panther destinations
BAD_THINGS = []
def destinations(event):
if event.get("Something") in BAD_THINGS:
return ["01234567-1edf-4edb-8f5b-0123456789a"]
# Suppress the alert
return []