This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathemail_for_critical_security_findings.yaml
More file actions
136 lines (120 loc) · 4.48 KB
/
Copy pathemail_for_critical_security_findings.yaml
File metadata and controls
136 lines (120 loc) · 4.48 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
metadata:
version: "1"
dependencies:
apps:
- id: dynatrace.automations
version: ^1.1492.3
- id: dynatrace.email
version: ^1.1.5
inputs: []
workflow:
title: "[Sample] Email notification for new critical security findings"
tasks:
get_security_findings:
name: get_security_findings
description: Query for new vulnerability findings in the last 24 hours.
action: dynatrace.automations:execute-dql-query
active: true
input:
query: >-
// The query has a rolling window of 7 days and the last 24hrs.
// Security finding events which have already been reported
// before the current 24hr window will not be reported again.
fetch security.events, from: now() - 7d
| filter dt.system.bucket == "default_securityevents"
AND event.kind == "SECURITY_EVENT"
AND dt.security.risk.level == "CRITICAL"
AND isNotNull(object.id) AND isNotNull(object.type)
| fieldsAdd object.name=coalesce(object.name, object.id)
// Aggregate security findings per affected object
| summarize {
finding_events = collectArray(
record(
event.provider,
dt.security.risk.level,
finding.id,
finding.title,
finding.time.created=toTimestamp(finding.time.created),
ingest_time= timestamp
)
)
}, by:{ object.id , object.name, object.type}
// Filter out, if this object had already a finding within queried
last 7 days
// and not only new occurence within the last 24 hours.
| filterOut iAny(finding_events[][ingest_time] < now() - 24h)
// Expand and deduplicate for repetitive findings if they
// were reported more than once in the last 24 hours.
| expand finding_events
| dedup { finding_events[event.provider], object.id,
finding_events[finding.id] }
// Aggregate again to count the unique findings for the object.
| summarize {
findings_count = count(),
finding_events = collectArray(
record(
event.provider=finding_events[event.provider],
dt.security.risk.level=finding_events[dt.security.risk.level],
finding.id=finding_events[finding.id],
finding.title=finding_events[finding.title],
finding.time.created=finding_events[finding.time.created],
ingest_time=finding_events[ingest_time]
)
)
}, by:{ object.id , object.name, object.type}
| sort finding_events[][finding.time.created] desc
customSampleResult: {}
position:
x: 0
y: 1
predecessors: []
conditions:
states: {}
custom: ""
send_email_notification:
name: send_email_notification
description: Send email
action: dynatrace.email:send-email
input:
cc: []
to: []
bcc: []
taskId: "{{ task().id }}"
content: >-
{% for object in result("get_security_findings").records %}
{{ object.get("findings_count") }} critical findings in {{ object.get("object.type") }} {{ object.get("object.name") }}:
{% for finding in object.get("finding_events") %}
{{ finding.get("dt.security.risk.level") }} | Found by {{ finding.get("event.provider") }} | {{ finding.get("finding.time.created") }} | {{ finding.get("finding.title") }}
{% endfor %}
{% endfor %}
subject: Critical security findings detected on
{{result("get_security_findings") | length}} objects!
executionId: "{{ execution().id }}"
environmentUrl: "{{ environment().url }}"
position:
x: 0
y: 2
predecessors:
- get_security_findings
conditions:
states:
get_security_findings: OK
description: ""
trigger:
schedule:
rule: null
trigger:
type: time
time: 08:00
timezone: Europe/Vienna
isActive: false
isFaulty: false
nextExecution: null
filterParameters:
earliestStart: 2024-04-10
inputs: {}
schemaVersion: 3
result: null
input: {}
hourlyExecutionLimit: 1000
type: STANDARD