Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cyberarkpas] Clean up null handling, formatting #9182

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/cyberarkpas/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# newer versions go on top
- version: "2.19.3"
changes:
- description: Clean up null handling, formatting
type: bugfix
link: https://github.com/elastic/integrations/pull/9182
- version: "2.19.2"
changes:
- description: Changed owners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ processors:
- rename:
field: message
target_field: event.original
if: 'ctx.event?.original == null'
if: ctx.event?.original == null
ignore_missing: true
#
# Parse syslog headers (if any) and extract JSON payload.
Expand Down Expand Up @@ -75,7 +75,7 @@ processors:
# - Syslog header timestamp. Either ISO8601 or legacy MMM dd HH:mm:ss, depending on the syslog format in use.
# - Original @timestamp from Filebeat.
- date:
if: 'ctx.cyberarkpas.audit.IsoTimestamp != null'
if: ctx.cyberarkpas.audit.IsoTimestamp != null
field: cyberarkpas.audit.IsoTimestamp
target_field: _tmp.timestamp
formats:
Expand Down Expand Up @@ -115,7 +115,7 @@ processors:
value: "failed to parse timestamp field: {{{cyberarkpas.audit.Timestamp}}}: {{{_ingest.on_failure_message}}}"

- date:
if: 'ctx._tmp.timestamp == null && ctx._tmp.syslog_ts != null && ctx.event?.timezone == null'
if: ctx._tmp.timestamp == null && ctx._tmp.syslog_ts != null && ctx.event?.timezone == null
field: _tmp.syslog_ts
target_field: _tmp.timestamp
formats:
Expand Down Expand Up @@ -144,7 +144,7 @@ processors:
value: "failed to parse legacy syslog timestamp: {{{_tmp.syslog_ts}}}: {{{_ingest.on_failure_message}}}"

- date:
if: 'ctx._tmp.timestamp == null && ctx._tmp.syslog_ts != null && ctx.event?.timezone != null'
if: ctx._tmp.timestamp == null && ctx._tmp.syslog_ts != null && ctx.event?.timezone != null
field: _tmp.syslog_ts
target_field: _tmp.timestamp
timezone: '{{{event.timezone}}}'
Expand Down Expand Up @@ -187,7 +187,7 @@ processors:
description: "Converts CAProperties into an array if necessary"
source: >
def props = ctx.cyberarkpas?.audit?.CAProperties?.CAProperty;
if (props != null && props instanceof Map) {
if (props instanceof Map) {
ctx.cyberarkpas.audit.CAProperties.CAProperty = [ props ];
}

Expand Down Expand Up @@ -295,7 +295,7 @@ processors:
return object.entrySet().stream().collect(
Collectors.toMap(
e -> to_snake_case(e.getKey()),
e -> e.getValue() instanceof Map? keys_to_snake_case_recursive(e.getValue()) : e.getValue()
e -> e.getValue() instanceof Map ? keys_to_snake_case_recursive(e.getValue()) : e.getValue()
)
);
}
Expand Down Expand Up @@ -348,7 +348,7 @@ processors:
- set:
field: event.type
value: [error]
if: 'ctx.event?.severity > 6'
if: ctx.event?.severity != null && ctx.event.severity > 6

- rename:
field: cyberarkpas.audit.message_id
Expand All @@ -368,7 +368,7 @@ processors:
- set:
field: file.path
value: '{{{cyberarkpas.audit.file}}}'
if: 'ctx.cyberarkpas.audit?.file != null'
if: ctx.cyberarkpas.audit?.file != null

#
# Observer fields
Expand All @@ -394,7 +394,7 @@ processors:
field: _tmp.hostname
target_field: observer.hostname
ignore_missing: true
if: 'ctx.observer?.hostname == null'
if: ctx.observer?.hostname == null
#
# Enrichment based on message_id
#
Expand Down Expand Up @@ -927,13 +927,13 @@ processors:

source: >
def clone(def val) {
return val instanceof List? new ArrayList(val) : val;
return val instanceof List ? new ArrayList(val) : val;
}
def read_field(def map, String name) {
if (map == null || !(map instanceof Map)) return null;
int pos = name.indexOf(".");
return pos == -1? map[name]
: read_field(map[name.substring(0, pos)], name.substring(pos+1));
return pos == -1 ? map[name]
: read_field(map[name.substring(0, pos)], name.substring(pos+1));
}
String msgID = ctx.event?.code;
def actions = params.get(msgID);
Expand Down Expand Up @@ -974,7 +974,7 @@ processors:
- script:
lang: painless
description: 'Set event.duration from the session duration ("hh:mm:ss")'
if: "ctx._tmp?.duration_hms != null"
if: ctx._tmp?.duration_hms != null
source: >
long parse_hms(String s) {
long cur = 0, total = 0;
Expand Down Expand Up @@ -1021,22 +1021,22 @@ processors:
- append:
field: related.ip
value: '{{{source.ip}}}'
if: 'ctx.source?.ip != null'
if: ctx.source?.ip != null
allow_duplicates: false
- append:
field: related.ip
value: '{{{destination.ip}}}'
if: 'ctx.destination?.ip != null'
if: ctx.destination?.ip != null
allow_duplicates: false
- append:
field: related.ip
value: '{{{cyberarkpas.audit.station}}}'
if: 'ctx.cyberarkpas.audit.station != null'
if: ctx.cyberarkpas.audit.station != null
allow_duplicates: false
- append:
field: related.ip
value: '{{{cyberarkpas.audit.gateway_station}}}'
if: 'ctx.cyberarkpas.audit.gateway_station != null'
if: ctx.cyberarkpas.audit.gateway_station != null
allow_duplicates: false

#
Expand All @@ -1045,22 +1045,22 @@ processors:
- append:
field: related.user
value: '{{{user.name}}}'
if: 'ctx.user?.name != null'
if: ctx.user?.name != null
allow_duplicates: false
- append:
field: related.user
value: '{{{source.user.name}}}'
if: 'ctx.source?.user?.name != null'
if: ctx.source?.user?.name != null
allow_duplicates: false
- append:
field: related.user
value: '{{{destination.user.name}}}'
if: 'ctx.destination?.user?.name != null'
if: ctx.destination?.user?.name != null
allow_duplicates: false
- append:
field: related.user
value: '{{{user.target.name}}}'
if: 'ctx.user?.target?.name != null'
if: ctx.user?.target?.name != null
allow_duplicates: false

#
Expand Down Expand Up @@ -1089,7 +1089,7 @@ processors:
field: host.name
value: '{{{observer.hostname}}}'
ignore_empty_value: true
if: 'ctx.host?.name == null'
if: ctx.host?.name == null

- network_direction:
ignore_missing: true
Expand All @@ -1102,7 +1102,7 @@ processors:
field: process.pid
type: long
ignore_missing: true

#
# Save only interesting fields under extra_fields and ca_properties
# to prevent mapping explosion. Keep the rest under .other (type flattened).
Expand Down Expand Up @@ -1176,7 +1176,7 @@ processors:
ignore_missing: true
- remove:
field: event.original
if: "ctx?.tags == null || !(ctx.tags.contains('preserve_original_event'))"
if: ctx.tags?.contains('preserve_original_event') != true
ignore_failure: true
ignore_missing: true
on_failure:
Expand Down
2 changes: 1 addition & 1 deletion packages/cyberarkpas/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: cyberarkpas
title: CyberArk Privileged Access Security
version: "2.19.2"
version: "2.19.3"
description: Collect logs from CyberArk Privileged Access Security with Elastic Agent.
type: integration
format_version: "3.0.0"
Expand Down