-
Notifications
You must be signed in to change notification settings - Fork 12
/
jira_tickets_for_critical_vulnerabilities.yaml
184 lines (154 loc) · 13.6 KB
/
jira_tickets_for_critical_vulnerabilities.yaml
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
metadata:
version: "1"
dependencies:
apps:
- id: dynatrace.automations
version: ^1.728.0
- id: dynatrace.jira
version: ^4.0.0
inputs:
- type: connection
schema: app:dynatrace.jira:connection
targets:
- tasks.create_task_in_jira.connectionId
workflow:
title: "[Sample] Jira tickets for critical vulnerabilities"
tasks:
get_vulnerabilites:
name: get_vulnerabilites
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.
// Vulnerability finding events which have already been reported
// before the current 24hr window will not be reported again.
fetch events, from: now() - 7d
| filter dt.system.bucket == "default_security_custom_events"
AND event.kind == "SECURITY_EVENT"
AND event.type == "VULNERABILITY_FINDING"
AND isNotNull(component.name)
AND dt.security.risk.level == "CRITICAL"
// Aggregate vulnerability findings per object.id, vulnerability,
// component and component version.
| summarize {
vulnerable_components_count = count(),
vulnerability_finding_events = collectArray(
record(
object.id = object.id,
event.provider = event.provider,
component.version = component.version,
component.name = component.name,
dt.security.risk.level = dt.security.risk.level,
vulnerability.title = vulnerability.title,
vulnerability.id = vulnerability.id,
ingest_time = timestamp
)
)
}, by:{ object.id, vulnerability.id, component.name, component.version }
// Filter out, if this vulnerability for the object and the component
// and version was already reported before the last 24 hours.
// For example, if the same vulnerability was reported multiple times
// during the last 7 days, don't report it again.
| filterOut iAny(vulnerability_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 vulnerability_finding_events
| dedup { vulnerability_finding_events[object.id],
vulnerability_finding_events[vulnerability.id],
vulnerability_finding_events[component.name],
vulnerability_finding_events[component.version] }
// Aggregate again to count the unique vulnerable components for each
vulnerability.
| summarize {
vulnerable_components_count = count(),
vulnerability_finding_events = collectArray(
vulnerability_finding_events
)
}, by:{ vulnerability.id }
| sort vulnerability_finding_events[][ingest_time] desc
customSampleResult: {}
position:
x: 0
y: 1
predecessors: []
conditions:
states: {}
custom: ""
create_task_in_jira:
name: create_task_in_jira
description: Create a Jira ticket for the vulnerability findings.
action: dynatrace.jira:jira-create-issue
active: true
input:
labels: []
taskId: "{{ task().id }}"
project:
id: null
summary: '{{
(_.finding.vulnerability_finding_events|first).get("dt.security.risk.level")
}} vulnerability {{ _.finding.get("vulnerability.id") }} was detected
in {{ (_.finding.vulnerability_finding_events|first).get("object.id")
or "unknown"}}'
assignee:
id: "-1"
priority: null
reporter: null
issueType:
id: null
components: []
description: >-
*Finding source:* {{
(_.finding.vulnerability_finding_events|first).get("event.provider")
}}
*Affected object ID:* {{
(_.finding.vulnerability_finding_events|first).get("object.id") }}
*Number of vulnerable components:* {{
(_.finding.vulnerable_components_count)}}
*Vulnerability severity:* {{
(_.finding.vulnerability_finding_events|first).get("dt.security.risk.level")
}}
*Vulnerability title:* {{
(_.finding.vulnerability_finding_events|first).get("vulnerability.title")
}}
*Vulnerability ID:* {{
(_.finding.vulnerability_finding_events|first).get("vulnerability.id")
}}
[View all vulnerability findings in a notebook.|{{ environment().url
}}/ui/intent/dynatrace.notebooks/view-query#%7B%22title%22%3A%22List%20recent%20vulnerability%20findings%22%2C%22visualization%22%3A%22recordView%22%2C%22visualizationSettings%22%3A%7B%22thresholds%22%3A%5B%5D%2C%22chartSettings%22%3A%7B%22gapPolicy%22%3A%22connect%22%2C%22circleChartSettings%22%3A%7B%22groupingThresholdType%22%3A%22relative%22%2C%22groupingThresholdValue%22%3A0%2C%22valueType%22%3A%22relative%22%7D%2C%22categoryOverrides%22%3A%7B%7D%2C%22curve%22%3A%22linear%22%2C%22pointsDisplay%22%3A%22auto%22%2C%22categoricalBarChartSettings%22%3A%7B%22layout%22%3A%22horizontal%22%2C%22categoryAxisTickLayout%22%3A%22horizontal%22%2C%22scale%22%3A%22absolute%22%2C%22groupMode%22%3A%22stacked%22%2C%22colorPaletteMode%22%3A%22multi-color%22%2C%22categoryAxis%22%3A%5B%22account%22%2C%22aws.account.id%22%2C%22aws.region%22%2C%22aws.resource.id%22%2C%22component.name%22%2C%22component.version%22%2C%22container_image.digest%22%2C%22container_image.registry%22%2C%22container_image.repository%22%2C%22detail%22%2C%22detail-type%22%2C%22dt.openpipeline.source%22%2C%22dt.security.risk.level%22%2C%22event.category%22%2C%22event.description%22%2C%22event.id%22%2C%22event.kind%22%2C%22event.name%22%2C%22event.provider%22%2C%22event.type%22%2C%22event.version%22%2C%22finding.description%22%2C%22finding.id%22%2C%22finding.title%22%2C%22id%22%2C%22object.id%22%2C%22object.type%22%2C%22region%22%2C%22source%22%2C%22time%22%2C%22uuid%22%2C%22version%22%2C%22vulnerability.description%22%2C%22vulnerability.id%22%2C%22vulnerability.title%22%2C%22activity_name%22%2C%22category_name%22%2C%22class_name%22%2C%22cloud%22%2C%22finding_info%22%2C%22metadata%22%2C%22resource%22%2C%22severity%22%2C%22status%22%2C%22time_dt%22%2C%22type_name%22%2C%22unmapped%22%2C%22ResponseMetadata%22%2C%22imageId%22%2C%22imageScanFindings%22%2C%22imageScanStatus%22%2C%22provider_product%22%2C%22registryId%22%2C%22repositoryName%22%2C%22type%22%5D%2C%22categoryAxisLabel%22%3A%22account%2Caws.account.id%2Caws.region%2Caws.resource.id%2Ccomponent.name%2Ccomponent.version%2Ccontainer_image.digest%2Ccontainer_image.registry%2Ccontainer_image.repository%2Cdetail%2Cdetail-type%2Cdt.openpipeline.source%2Cdt.security.risk.level%2Cevent.category%2Cevent.description%2Cevent.id%2Cevent.kind%2Cevent.name%2Cevent.provider%2Cevent.type%2Cevent.version%2Cfinding.description%2Cfinding.id%2Cfinding.title%2Cid%2Cobject.id%2Cobject.type%2Cregion%2Csource%2Ctime%2Cuuid%2Cversion%2Cvulnerability.description%2Cvulnerability.id%2Cvulnerability.title%2Cactivity_name%2Ccategory_name%2Cclass_name%2Ccloud%2Cfinding_info%2Cmetadata%2Cresource%2Cseverity%2Cstatus%2Ctime_dt%2Ctype_name%2Cunmapped%2CResponseMetadata%2CimageId%2CimageScanFindings%2CimageScanStatus%2Cprovider_product%2CregistryId%2CrepositoryName%2Ctype%22%2C%22valueAxis%22%3A%5B%22dt.security.risk.score%22%2C%22activity_id%22%2C%22category_uid%22%2C%22class_uid%22%2C%22severity_id%22%2C%22time%22%2C%22type_uid%22%5D%2C%22valueAxisLabel%22%3A%22dt.security.risk.score%2Cactivity_id%2Ccategory_uid%2Cclass_uid%2Cseverity_id%2Ctime%2Ctype_uid%22%2C%22tooltipVariant%22%3A%22single%22%7D%2C%22colorPalette%22%3A%22categorical%22%2C%22valueRepresentation%22%3A%22absolute%22%2C%22xAxisScaling%22%3A%22analyzedTimeframe%22%2C%22hiddenLegendFields%22%3A%5B%5D%2C%22fieldMapping%22%3A%7B%22timestamp%22%3A%22timestamp%22%2C%22leftAxisValues%22%3A%5B%22dt.security.risk.score%22%5D%2C%22leftAxisDimensions%22%3A%5B%22account%22%5D%7D%2C%22truncationMode%22%3A%22middle%22%7D%2C%22singleValue%22%3A%7B%22showLabel%22%3Atrue%2C%22label%22%3A%22%22%2C%22prefixIcon%22%3A%22%22%2C%22recordField%22%3A%22timestamp%22%2C%22autoscale%22%3Atrue%2C%22alignment%22%3A%22center%22%2C%22trend%22%3A%7B%22trendType%22%3A%22auto%22%2C%22isVisible%22%3Afalse%7D%2C%22colorThresholdTarget%22%3A%22value%22%7D%2C%22table%22%3A%7B%22rowDensity%22%3A%22condensed%22%2C%22enableSparklines%22%3Afalse%2C%22hiddenColumns%22%3A%5B%5D%2C%22linewrapEnabled%22%3Afalse%2C%22lineWrapIds%22%3A%5B%5D%2C%22monospacedFontEnabled%22%3Afalse%2C%22monospacedFontColumns%22%3A%5B%5D%2C%22firstVisibleRowIndex%22%3A0%2C%22columnWidths%22%3A%7B%7D%2C%22columnTypeOverrides%22%3A%5B%5D%2C%22enableThresholdInRow%22%3Afalse%7D%2C%22honeycomb%22%3A%7B%22shape%22%3A%22hexagon%22%2C%22legend%22%3A%22auto%22%2C%22displayedFields%22%3A%5B%22account%22%2C%22aws.account.id%22%2C%22aws.region%22%2C%22aws.resource.id%22%2C%22component.name%22%2C%22component.version%22%2C%22container_image.digest%22%2C%22container_image.registry%22%2C%22container_image.repository%22%2C%22detail%22%2C%22detail-type%22%2C%22dt.openpipeline.source%22%2C%22dt.security.risk.level%22%2C%22event.category%22%2C%22event.description%22%2C%22event.id%22%2C%22event.kind%22%2C%22event.name%22%2C%22event.provider%22%2C%22event.type%22%2C%22event.version%22%2C%22finding.description%22%2C%22finding.id%22%2C%22finding.title%22%2C%22id%22%2C%22object.id%22%2C%22object.type%22%2C%22region%22%2C%22source%22%2C%22time%22%2C%22uuid%22%2C%22version%22%2C%22vulnerability.description%22%2C%22vulnerability.id%22%2C%22vulnerability.title%22%2C%22activity_name%22%2C%22category_name%22%2C%22class_name%22%2C%22cloud%22%2C%22finding_info%22%2C%22metadata%22%2C%22resource%22%2C%22severity%22%2C%22status%22%2C%22time_dt%22%2C%22type_name%22%2C%22unmapped%22%2C%22ResponseMetadata%22%2C%22imageId%22%2C%22imageScanFindings%22%2C%22imageScanStatus%22%2C%22provider_product%22%2C%22registryId%22%2C%22repositoryName%22%2C%22type%22%5D%2C%22dataMappings%22%3A%7B%22value%22%3A%22dt.security.risk.score%22%7D%2C%22colorMode%22%3A%22color-palette%22%2C%22colorPalette%22%3A%22blue%22%7D%2C%22histogram%22%3A%7B%22legend%22%3A%22auto%22%2C%22yAxis%22%3A%7B%22label%22%3A%22Frequency%22%2C%22scale%22%3A%22linear%22%7D%2C%22colorPalette%22%3A%22categorical%22%2C%22dataMappings%22%3A%5B%7B%22valueAxis%22%3A%22dt.security.risk.score%22%2C%22rangeAxis%22%3A%22%22%7D%2C%7B%22valueAxis%22%3A%22activity_id%22%2C%22rangeAxis%22%3A%22%22%7D%2C%7B%22valueAxis%22%3A%22category_uid%22%2C%22rangeAxis%22%3A%22%22%7D%2C%7B%22valueAxis%22%3A%22class_uid%22%2C%22rangeAxis%22%3A%22%22%7D%2C%7B%22valueAxis%22%3A%22severity_id%22%2C%22rangeAxis%22%3A%22%22%7D%2C%7B%22valueAxis%22%3A%22time%22%2C%22rangeAxis%22%3A%22%22%7D%2C%7B%22valueAxis%22%3A%22type_uid%22%2C%22rangeAxis%22%3A%22%22%7D%5D%2C%22variant%22%3A%22single%22%2C%22displayedFields%22%3A%5B%22account%22%2C%22container_image.digest%22%2C%22container_image.registry%22%2C%22container_image.repository%22%2C%22detail%22%2C%22detail-type%22%2C%22dt.openpipeline.source%22%2C%22event.category%22%2C%22event.description%22%2C%22event.kind%22%2C%22event.name%22%2C%22event.provider%22%2C%22event.type%22%2C%22id%22%2C%22region%22%2C%22source%22%2C%22time%22%2C%22uuid%22%2C%22version%22%2C%22vulnerability.description%22%2C%22vulnerability.title%22%2C%22activity_name%22%2C%22category_name%22%2C%22class_name%22%2C%22cloud%22%2C%22finding_info%22%2C%22metadata%22%2C%22resource%22%2C%22severity%22%2C%22status%22%2C%22time_dt%22%2C%22type_name%22%2C%22unmapped%22%2C%22ResponseMetadata%22%2C%22imageId%22%2C%22imageScanFindings%22%2C%22imageScanStatus%22%2C%22provider_product%22%2C%22registryId%22%2C%22repositoryName%22%2C%22type%22%5D%7D%7D%2C%22dt.timeframe%22%3A%7B%22from%22%3A%22now()-7d%22%2C%22to%22%3A%22now()%22%7D%2C%22dt.query%22%3A%22fetch%20events%5Cn%2F%2F%20data%20access%5Cn%7C%20filter%20dt.system.bucket%20%3D%3D%20%5C%22default_security_custom_events%5C%22%5Cn%20%20%20%20%20AND%20event.type%20%3D%3D%20%5C%22VULNERABILITY_FINDING%5C%22%5Cn%20%20%20%20%20AND%20isNotNull(component.name)%5Cn%7C%20dedup%20%7Bobject.id%2C%20vulnerability.id%2C%20component.name%7D%2C%20sort%3A%20%7Btimestamp%20desc%7D%5Cn%2F%2F%20aggregation%20and%20custom%20filtering%5Cn%7C%20sort%20timestamp%20desc%22%2C%22hideInput%22%3Afalse%2C%22sourceApplication%22%3A%22dynatrace.notebooks%22%7D]
||Component name||Component version||
{% for component in _.finding.vulnerability_finding_events %}
|{{ component.get("component.name") }}|{{
component.get("component.version") }}|
{% endfor %}
executionId: "{{ execution().id }}"
connectionId: ""
fieldSetters: []
environmentUrl: "{{ environment().url }}"
position:
x: 0
y: 2
predecessors:
- get_vulnerabilites
conditions:
states:
get_vulnerabilites: SUCCESS
custom: '{{result("get_vulnerabilites").records|length > 0}}'
concurrency: 1
withItems: finding in {{ result("get_vulnerabilites").records }}
description: ""
trigger:
schedule:
rule: null
trigger:
type: time
time: 08:00
timezone: Europe/Vienna
isActive: false
isFaulty: false
filterParameters:
earliestStart: 2024-04-10
inputs: {}
schemaVersion: 3