-
Notifications
You must be signed in to change notification settings - Fork 375
/
default.yml
302 lines (302 loc) · 9.15 KB
/
default.yml
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
---
description: Pipeline for parsing Oracle Audit logs
processors:
- set:
field: ecs.version
value: '8.6.0'
- set:
field: event.action
value: database_audit
- set:
field: event.kind
value: event
- set:
field: event.category
value: [database]
- set:
field: event.type
value: [access]
- set:
field: event.outcome
value: success
# Need to know which type of audit event it is, oracle_event_type is a temp field.
- set:
field: oracle_event_type
value: database
if: 'ctx.message.contains("LENGTH :")'
- set:
field: oracle_event_type
value: object
if: 'ctx.message.contains("LENGTH:")'
- set:
field: event.outcome
value: success
- rename:
field: message
target_field: event.original
ignore_missing: true
if: 'ctx.event?.original == null'
# First pattern for object, second for database audit events.
- grok:
field: event.original
patterns:
- "%{GREEDYDATA:tmp_timestamp}\\nLENGTH : '%{GREEDYDATA:LENGTH}'\\nACTION :\\[\\d+\\] (?m)%{GREEDYDATA:action}(DATABASE USER):\\S+ '%{FIELD:db_user}'\\n(?m)%{GREEDYDATA:audit}"
- "%{GREEDYDATA:tmp_timestamp}\\nLENGTH : '%{GREEDYDATA:LENGTH}'\\nACTION :\\[\\d+\\] (?m)%{GREEDYDATA:action}"
- "%{GREEDYDATA:tmp_timestamp}\\nLENGTH: \"%{GREEDYDATA:LENGTH}\"\\n%{GREEDYDATA:audit}"
pattern_definitions:
"FIELD": "[^']+"
- kv:
field: audit
field_split: "\\\n(?=[a-zA-Z])"
value_split: ":\\S\\d+\\S(?= ')"
trim_value: " '"
trim_key: " "
prefix: oracle.database_audit.
if: ctx.oracle_event_type == "database" && ctx?.audit != null && ctx?.audit.length() != 0
- kv:
field: audit
field_split: "\" "
value_split: ":\\S\\d+\\S (?=\")"
strip_brackets: true
prefix: oracle.database_audit.
if: ctx.oracle_event_type == "object" && ctx?.audit != null && ctx?.audit.length() != 0
- grok:
field: log.file.path
patterns:
- "%{BASE10NUM:process.pid}\\_%{BASE10NUM}\\.aud(\\.log)?$"
if: ctx.log?.file?.path != null
- rename:
field: action
target_field: oracle.database_audit.action
ignore_missing: true
- rename:
field: db_user
target_field: oracle.database_audit.database_user
ignore_missing: true
# All field names are uppercase by default, converts them to lowercase
- script:
source: "ctx.oracle.database_audit = ctx.oracle.database_audit.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().toLowerCase(), Map.Entry::getValue));"
lang: painless
# Replace all field names that has spaces in them with _
- script:
lang: painless
source: "ctx.oracle.database_audit = ctx?.oracle?.database_audit.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().replace(' ', '_'), e -> e.getValue()));"
- gsub:
field: "oracle.database_audit.action"
pattern: "\\n"
replacement: ""
- gsub:
field: "oracle.database_audit.action"
pattern: "\\s{2,}"
replacement: " "
- gsub:
field: "oracle.database_audit.action"
pattern: "^\\'"
replacement: ""
- gsub:
field: "oracle.database_audit.action"
pattern: "\\'$"
replacement: ""
- trim:
field: "oracle.database_audit.action_number"
ignore_missing: true
# Removes all null values from ctx.*
- script:
lang: painless
if: ctx?.oracle?.database_audit != null
source: |
void handleMap(Map map) {
for (def x : map.values()) {
if (x instanceof Map) {
handleMap(x);
} else if (x instanceof List) {
handleList(x);
}
}
map.values().removeIf(v -> v instanceof String && v.isEmpty() == true);
}
void handleList(List list) {
for (def x : list) {
if (x instanceof Map) {
handleMap(x);
} else if (x instanceof List) {
handleList(x);
}
}
}
handleMap(ctx);
- remove:
field:
- "@timestamp"
ignore_missing: true
- date:
field: tmp_timestamp
target_field: "@timestamp"
formats:
- EEE MMM [ d][dd] HH:mm:ss uuuu XXX
- grok:
field: tmp_timestamp
patterns:
- "%{ISO8601_TIMEZONE:event.timezone}$"
- set:
field: user.roles
value: ["{{{oracle.database_audit.privilege}}}"]
ignore_empty_value: true
ignore_failure: true
- remove:
field: oracle.database_audit.privilege
ignore_missing: true
- rename:
field: LENGTH
target_field: oracle.database_audit.length
ignore_missing: true
- rename:
field: oracle.database_audit.client_user
target_field: client.user.name
ignore_missing: true
- rename:
field: oracle.database_audit.userid
target_field: client.user.id
ignore_missing: true
- rename:
field: oracle.database_audit.current_user
target_field: client.user.name
ignore_missing: true
- rename:
field: oracle.database_audit.comment$text
target_field: oracle.database_audit.comment_text
ignore_missing: true
- rename:
field: oracle.database_audit.obj$creator
target_field: oracle.database_audit.obj_creator
ignore_missing: true
- rename:
field: oracle.database_audit.obj$name
target_field: oracle.database_audit.obj_name
ignore_missing: true
- rename:
field: oracle.database_audit.os$userid
target_field: oracle.database_audit.os_userid
ignore_missing: true
- rename:
field: oracle.database_audit.ses$actions
target_field: oracle.database_audit.ses_actions
ignore_missing: true
- rename:
field: oracle.database_audit.ses$tid
target_field: oracle.database_audit.ses_tid
ignore_missing: true
- rename:
field: oracle.database_audit.client_address
target_field: client.address
ignore_missing: true
- rename:
field: oracle.database_audit.userhost
target_field: server.address
ignore_missing: true
- rename:
field: oracle.database_audit.database_user
target_field: server.user.name
ignore_missing: true
- convert:
field: oracle.database_audit.length
type: long
ignore_missing: true
- grok:
field: client.address
patterns:
- "(?:%{IP:client.ip}|%{GREEDYDATA:client.domain})"
ignore_failure: true
ignore_missing: true
- grok:
field: server.address
patterns:
- "(?:%{IP:server.ip}|%{GREEDYDATA:server.domain})"
ignore_failure: true
ignore_missing: true
# Renaming certain fields for better data structure
- rename:
field: oracle.database_audit.sessionid
target_field: oracle.database_audit.session_id
ignore_missing: true
- rename:
field: oracle.database_audit.client_terminal
target_field: oracle.database_audit.client.terminal
ignore_missing: true
- rename:
field: oracle.database_audit.client_address
target_field: oracle.database_audit.client.address
ignore_missing: true
- rename:
field: oracle.database_audit.database_user
target_field: oracle.database_audit.database.user
ignore_missing: true
- rename:
field: oracle.database_audit.userhost
target_field: oracle.database_audit.database.host
ignore_missing: true
- rename:
field: oracle.database_audit.dbid
target_field: oracle.database_audit.database.id
ignore_missing: true
- rename:
field: oracle.database_audit.entry_id
target_field: oracle.database_audit.entry.id
ignore_missing: true
- rename:
field: oracle.database_audit.entryid
target_field: oracle.database_audit.entry.id
ignore_missing: true
- convert:
field: oracle.database_audit.entry.id
type: long
ignore_missing: true
- convert:
field: process.pid
type: long
ignore_missing: true
- append:
field: related.user
value: "{{server.user.name}}"
allow_duplicates: false
if: ctx?.server?.user?.name != null
- append:
field: related.user
value: "{{client.user.name}}"
allow_duplicates: false
if: ctx?.client?.user?.name != null
- append:
field: related.ip
value: "{{client.ip}}"
allow_duplicates: false
if: ctx?.client?.ip != null
- append:
field: related.ip
value: "{{server.ip}}"
allow_duplicates: false
if: ctx?.server?.ip != null
- append:
field: related.hosts
value: "{{client.domain}}"
allow_duplicates: false
if: ctx?.client?.domain != null
- append:
field: related.hosts
value: "{{server.domain}}"
allow_duplicates: false
if: ctx?.server?.domain != null
- remove:
field: event.original
if: "ctx?.tags == null || !(ctx.tags.contains('preserve_original_event'))"
ignore_failure: true
ignore_missing: true
- remove:
field:
- tmp_timestamp
- audit
- oracle_event_type
ignore_missing: true
on_failure:
- set:
field: error.message
value: "{{ _ingest.on_failure_message }}"