Skip to content

Commit 017813f

Browse files
chrisberkhoutefd6
authored andcommitted
[jamf_compliance_reporter] Clean up null handling, other checks, scripting (#9179)
- Combine 'not null and is/not value' checks. - Remove redundant null-safe operator. - Add 'not null' check to 'not value' checks. - Correct date conversion conditions to check source values. - Add 'not null' check before .entrySet(). - Avoid trying to cast null to long/int. --------- Co-authored-by: Dan Kortschak <90160302+efd6@users.noreply.github.com>
1 parent 8d7533b commit 017813f

16 files changed

+83
-63
lines changed

packages/jamf_compliance_reporter/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.11.2"
3+
changes:
4+
- description: Clean up null handling, other checks and scripting
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/pull/9179
27
- version: "1.11.1"
38
changes:
49
- description: Changed owners

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ processors:
1818
if: ctx.json?.header?.event_name == 'APP_METRICS'
1919
- pipeline:
2020
name: '{{ IngestPipeline "pipeline_audit" }}'
21-
if: ctx.json?.header?.event_name != null && ctx.json?.header?.event_name.startsWith('AUE_')
21+
if: ctx.json?.header?.event_name?.startsWith('AUE_') == true
2222
- pipeline:
2323
name: '{{ IngestPipeline "pipeline_event" }}'
2424
if: "['AUDIO_VIDEO_DEVICE_EVENT','AUDIT_CLASS_VERIFICATION_EVENT','COMPLIANCE_REPORTER_TAMPER_EVENT','FILE_EVENT','GATEKEEPER_INFO_EVENT','GATEKEEPER_MANUAL_OVERRIDES','GATEKEEPER_QUARANTINE_LOG','HARDWARE_EVENT','LICENSE_INFO_EVENT','PREFERENCE_LIST_EVENT','PRINT_EVENT_INFORMATION','PROHIBITED_APP_BLOCKED','SIGNAL_EVENT','UNIFIED_LOG_EVENT','XPROTECT_DEFINITIONS_VERSION_INFO','XPROTECT_EVENT_LOG'].contains(ctx.json?.header?.event_name)"

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_app_metrics.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ processors:
136136
if: ctx.json?.app_metric_info?.cpu_percentage != null
137137
source: |
138138
ctx.host.cpu = new HashMap();
139-
ctx.host.cpu.usage = Math.round(ctx.json?.app_metric_info?.cpu_percentage *10) / 1000.0;
139+
ctx.host.cpu.usage = Math.round(ctx.json.app_metric_info.cpu_percentage * 10) / 1000.0;
140140
on_failure:
141141
- set:
142142
field: event.kind

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_audit.yml

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ processors:
3434
ignore_missing: true
3535
- script:
3636
lang: painless
37-
if: ctx.json?.header?.time_seconds_epoch != 0
37+
if: ctx.json?.header?.time_seconds_epoch != null && ctx.json.header.time_seconds_epoch != 0
3838
source: |
39-
ctx.json.time_milliseconds = (long)ctx.json?.header?.time_seconds_epoch * 1000 + (long)ctx.json?.header?.time_milliseconds_offset;
39+
ctx.json.time_milliseconds = (long)ctx.json.header.time_seconds_epoch * 1000;
40+
if (ctx.json?.header?.time_milliseconds_offset != null && ctx.json.header.time_milliseconds_offset != 0) {
41+
ctx.json.time_milliseconds = ctx.json.time_milliseconds + (long)ctx.json.header.time_milliseconds_offset;
42+
}
4043
- date:
4144
field: json.time_milliseconds
42-
if: ctx.json?.time_milliseconds != 0
45+
if: ctx.json?.time_milliseconds != null && ctx.json.time_milliseconds != 0
4346
formats:
4447
- UNIX_MS
4548
on_failure:
@@ -281,82 +284,82 @@ processors:
281284
value: authentication
282285
- pipeline:
283286
name: '{{ IngestPipeline "pipeline_aue_accept" }}'
284-
if: ctx.event?.action == 'aue_accept'
287+
if: ctx.event.action == 'aue_accept'
285288
- pipeline:
286289
name: '{{ IngestPipeline "pipeline_aue_auth" }}'
287-
if: '["aue_auth_user", "aue_ssauthorize", "aue_ssauthmech"].contains(ctx.event?.action)'
290+
if: '["aue_auth_user", "aue_ssauthorize", "aue_ssauthmech"].contains(ctx.event.action)'
288291
- pipeline:
289292
name: '{{ IngestPipeline "pipeline_aue_bind_and_aue_connect" }}'
290-
if: '["aue_bind", "aue_connect"].contains(ctx.event?.action)'
293+
if: '["aue_bind", "aue_connect"].contains(ctx.event.action)'
291294
- pipeline:
292295
name: '{{ IngestPipeline "pipeline_aue_chdir" }}'
293-
if: ctx.event?.action == 'aue_chdir'
296+
if: ctx.event.action == 'aue_chdir'
294297
- pipeline:
295298
name: '{{ IngestPipeline "pipeline_aue_chroot" }}'
296-
if: ctx.event?.action == 'aue_chroot'
299+
if: ctx.event.action == 'aue_chroot'
297300
- pipeline:
298301
name: '{{ IngestPipeline "pipeline_aue_execve" }}'
299-
if: ctx.event?.action == 'aue_execve'
302+
if: ctx.event.action == 'aue_execve'
300303
- pipeline:
301304
name: '{{ IngestPipeline "pipeline_aue_exit" }}'
302-
if: ctx.event?.action == 'aue_exit'
305+
if: ctx.event.action == 'aue_exit'
303306
- pipeline:
304307
name: '{{ IngestPipeline "pipeline_aue_kill" }}'
305-
if: ctx.event?.action == 'aue_kill'
308+
if: ctx.event.action == 'aue_kill'
306309
- pipeline:
307310
name: '{{ IngestPipeline "pipeline_aue_mount" }}'
308-
if: ctx.event?.action == 'aue_mount'
311+
if: ctx.event.action == 'aue_mount'
309312
- pipeline:
310313
name: '{{ IngestPipeline "pipeline_aue_posix_spawn" }}'
311-
if: ctx.event?.action == 'aue_posix_spawn'
314+
if: ctx.event.action == 'aue_posix_spawn'
312315
- pipeline:
313316
name: '{{ IngestPipeline "pipeline_aue_remove_from_group_and_aue_mac_set_proc" }}'
314-
if: '["aue_remove_from_group", "aue_mac_set_proc"].contains(ctx.event?.action)'
317+
if: '["aue_remove_from_group", "aue_mac_set_proc"].contains(ctx.event.action)'
315318
- pipeline:
316319
name: '{{ IngestPipeline "pipeline_aue_session" }}'
317-
if: '["aue_session_end", "aue_session_update", "aue_session_close", "aue_session_start"].contains(ctx.event?.action)'
320+
if: '["aue_session_end", "aue_session_update", "aue_session_close", "aue_session_start"].contains(ctx.event.action)'
318321
- pipeline:
319322
name: '{{ IngestPipeline "pipeline_aue_arguments" }}'
320-
if: '["aue_setsockopt", "aue_shutdown"].contains(ctx.event?.action)'
323+
if: '["aue_setsockopt", "aue_shutdown"].contains(ctx.event.action)'
321324
- pipeline:
322325
name: '{{ IngestPipeline "pipeline_aue_ssauthint" }}'
323-
if: ctx.event?.action == 'aue_ssauthint'
326+
if: ctx.event.action == 'aue_ssauthint'
324327
- pipeline:
325328
name: '{{ IngestPipeline "pipeline_aue_tasknameforpid" }}'
326-
if: ctx.event?.action == 'aue_tasknameforpid'
329+
if: ctx.event.action == 'aue_tasknameforpid'
327330
- pipeline:
328331
name: '{{ IngestPipeline "pipeline_aue_unmount" }}'
329-
if: ctx.event?.action == 'aue_unmount'
332+
if: ctx.event.action == 'aue_unmount'
330333
- pipeline:
331334
name: '{{ IngestPipeline "pipeline_aue_fork" }}'
332-
if: ctx.event?.action == 'aue_fork'
335+
if: ctx.event.action == 'aue_fork'
333336
- pipeline:
334337
name: '{{ IngestPipeline "pipeline_identity_object" }}'
335-
if: '["aue_getauid", "aue_lw_login", "aue_settimeofday"].contains(ctx.event?.action)'
338+
if: '["aue_getauid", "aue_lw_login", "aue_settimeofday"].contains(ctx.event.action)'
336339
- pipeline:
337340
name: '{{ IngestPipeline "pipeline_aue_listen" }}'
338-
if: ctx.event?.action == 'aue_listen'
341+
if: ctx.event.action == 'aue_listen'
339342
- pipeline:
340343
name: '{{ IngestPipeline "pipeline_aue_logout" }}'
341-
if: ctx.event?.action == 'aue_logout'
344+
if: ctx.event.action == 'aue_logout'
342345
- pipeline:
343346
name: '{{ IngestPipeline "pipeline_aue_pidfortask" }}'
344-
if: ctx.event?.action == 'aue_pidfortask'
347+
if: ctx.event.action == 'aue_pidfortask'
345348
- pipeline:
346349
name: '{{ IngestPipeline "pipeline_aue_ptrace" }}'
347-
if: ctx.event?.action == 'aue_ptrace'
350+
if: ctx.event.action == 'aue_ptrace'
348351
- pipeline:
349352
name: '{{ IngestPipeline "pipeline_aue_setpriority" }}'
350-
if: ctx.event?.action == 'aue_setpriority'
353+
if: ctx.event.action == 'aue_setpriority'
351354
- pipeline:
352355
name: '{{ IngestPipeline "pipeline_aue_socketpair" }}'
353-
if: ctx.event?.action == 'aue_socketpair'
356+
if: ctx.event.action == 'aue_socketpair'
354357
- pipeline:
355358
name: '{{ IngestPipeline "pipeline_aue_taskforpid" }}'
356-
if: ctx.event?.action == 'aue_taskforpid'
359+
if: ctx.event.action == 'aue_taskforpid'
357360
- pipeline:
358361
name: '{{ IngestPipeline "pipeline_aue_wait4" }}'
359-
if: ctx.event?.action == 'aue_wait4'
362+
if: ctx.event.action == 'aue_wait4'
360363
on_failure:
361364
- set:
362365
field: event.kind

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_aue_chdir.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ processors:
6565
- script:
6666
description: Convert Decimal into Octal.
6767
lang: painless
68+
if: ctx.json?.file_access_mode != null
6869
source: |
69-
int temp = (int)ctx.json?.file_access_mode;
70+
int temp = (int)ctx.json.file_access_mode;
7071
ctx.jamf_compliance_reporter.log.attributes.file.access_mode = Integer.toOctalString(temp);
7172
on_failure:
7273
- set:

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_aue_chroot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ processors:
6767
- script:
6868
description: Convert Decimal into Octal.
6969
lang: painless
70+
if: ctx.json?.file_access_mode != null
7071
source: |
71-
int temp = (int)ctx.json?.file_access_mode;
72+
int temp = (int)ctx.json.file_access_mode;
7273
ctx.jamf_compliance_reporter.log.attributes.file.access_mode = Integer.toOctalString(temp);
7374
on_failure:
7475
- set:

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_aue_execve.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ processors:
134134
source: |
135135
def args_list = new ArrayList();
136136
ctx.process.args = args_list;
137-
for (Map.Entry m : ctx.json?.args.entrySet()) {
138-
ctx.process?.args.add(m.getValue());
137+
if (ctx.json?.args != null) {
138+
for (Map.Entry m : ctx.json.args.entrySet()) {
139+
ctx.process.args.add(m.getValue());
140+
}
139141
}
140142
- script:
141143
description: Convert Decimal into Octal.
142144
lang: painless
145+
if: ctx.json?.file_access_mode != null
143146
source: |
144-
int temp = (int)ctx.json?.file_access_mode;
147+
int temp = (int)ctx.json.file_access_mode;
145148
ctx.jamf_compliance_reporter.log.attributes.file.access_mode = Integer.toOctalString(temp);
146149
on_failure:
147150
- set:

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_aue_mount.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ processors:
7777
- script:
7878
description: Convert Decimal into Octal.
7979
lang: painless
80+
if: ctx.json?.file_access_mode != null
8081
source: |
8182
int temp = (int)ctx.json?.file_access_mode;
8283
ctx.jamf_compliance_reporter.log.attributes.file.access_mode = Integer.toOctalString(temp);

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_aue_posix_spawn.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ processors:
4040
source: |
4141
def args_list = new ArrayList();
4242
ctx.process.args = args_list;
43-
for (Map.Entry m : ctx.json?.args.entrySet()) {
44-
ctx.process?.args.add(m.getValue());
43+
if (ctx.json?.args != null) {
44+
for (Map.Entry m : ctx.json.args.entrySet()) {
45+
ctx.process.args.add(m.getValue());
46+
}
4547
}
4648
- pipeline:
4749
name: '{{ IngestPipeline "pipeline_identity_object" }}'

packages/jamf_compliance_reporter/data_stream/log/elasticsearch/ingest_pipeline/pipeline_aue_unmount.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ processors:
6767
- script:
6868
description: Convert Decimal into Octal.
6969
lang: painless
70+
if: ctx.json?.file_access_mode != null
7071
source: |
71-
int temp = (int)ctx.json?.file_access_mode;
72+
int temp = (int)ctx.json.file_access_mode;
7273
ctx.jamf_compliance_reporter.log.attributes.file.access_mode = Integer.toOctalString(temp);
7374
on_failure:
7475
- set:

0 commit comments

Comments
 (0)