Skip to content

Commit a0ce92f

Browse files
authored
google_workspace: fix JSON error and login challenge_status handling (#13070)
Also improve error reporting for cases where JSON parsing cannot be successfully carried out. Previously JSON parsing failures would be silently ignored leaving no indication that that was the cause of a document not being processed correctly. With the changes here, failing to parse the JSON results in pipeline termination with an informative message since no furthe work can be done without the parsed JSON.
1 parent a316378 commit a0ce92f

File tree

12 files changed

+114
-24
lines changed

12 files changed

+114
-24
lines changed

packages/google_workspace/changelog.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
# newer versions go on top
2+
- version: "2.34.0"
3+
changes:
4+
- description: Improve error handling in ingest pipeline.
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/13070
7+
- description: Improve handling of JSON parsing failures.
8+
type: enhancement
9+
link: https://github.com/elastic/integrations/pull/13070
10+
- description: Fix handing of `google_workspace.login.challenge_status`.
11+
type: bugfix
12+
link: https://github.com/elastic/integrations/pull/13070
213
- version: "2.33.0"
314
changes:
415
- description: Enable request trace log removal.

packages/google_workspace/data_stream/admin/elasticsearch/ingest_pipeline/default.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ processors:
2020
- json:
2121
field: event.original
2222
target_field: json
23-
ignore_failure: true
2423
- set:
2524
field: event.kind
2625
value: event
@@ -834,4 +833,7 @@ on_failure:
834833
allow_duplicates: false
835834
- append:
836835
field: error.message
837-
value: '{{{ _ingest.on_failure_message }}}'
836+
value: >-
837+
Processor '{{{ _ingest.on_failure_processor_type }}}'
838+
{{{#_ingest.on_failure_processor_tag}}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
839+
{{{/_ingest.on_failure_processor_tag}}}failed with message '{{{ _ingest.on_failure_message }}}'

packages/google_workspace/data_stream/alert/elasticsearch/ingest_pipeline/default.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ processors:
1717
- json:
1818
field: event.original
1919
target_field: json
20-
ignore_failure: true
2120
- append:
2221
field: event.type
2322
value: info
@@ -1067,4 +1066,7 @@ on_failure:
10671066
allow_duplicates: false
10681067
- append:
10691068
field: error.message
1070-
value: '{{{ _ingest.on_failure_message }}}'
1069+
value: >-
1070+
Processor '{{{ _ingest.on_failure_processor_type }}}'
1071+
{{{#_ingest.on_failure_processor_tag}}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
1072+
{{{/_ingest.on_failure_processor_tag}}}failed with message '{{{ _ingest.on_failure_message }}}'

packages/google_workspace/data_stream/drive/elasticsearch/ingest_pipeline/default.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ processors:
2323
- json:
2424
field: event.original
2525
target_field: json
26-
ignore_failure: true
2726
- date:
2827
field: json.id.time
2928
if: ctx.json?.id?.time != null && ctx.json.id.time != ''
@@ -287,4 +286,7 @@ on_failure:
287286
allow_duplicates: false
288287
- append:
289288
field: error.message
290-
value: '{{{ _ingest.on_failure_message }}}'
289+
value: >-
290+
Processor '{{{ _ingest.on_failure_processor_type }}}'
291+
{{{#_ingest.on_failure_processor_tag}}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
292+
{{{/_ingest.on_failure_processor_tag}}}failed with message '{{{ _ingest.on_failure_message }}}'

packages/google_workspace/data_stream/groups/elasticsearch/ingest_pipeline/default.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ processors:
2626
- json:
2727
field: event.original
2828
target_field: json
29-
ignore_failure: true
3029
- date:
3130
field: json.id.time
3231
if: ctx.json?.id?.time != null && ctx.json.id.time != ''
@@ -318,4 +317,7 @@ on_failure:
318317
allow_duplicates: false
319318
- append:
320319
field: error.message
321-
value: '{{{ _ingest.on_failure_message }}}'
320+
value: >-
321+
Processor '{{{ _ingest.on_failure_processor_type }}}'
322+
{{{#_ingest.on_failure_processor_tag}}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
323+
{{{/_ingest.on_failure_processor_tag}}}failed with message '{{{ _ingest.on_failure_message }}}'

packages/google_workspace/data_stream/login/_dev/test/pipeline/test-login.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
{"kind":"admin#reports#activity","id":{"time":"2020-10-02T15:00:00Z","uniqueQualifier":1,"applicationName":"login","customerId":"1"},"actor":{"callerType":"USER","email":"foo@bar.com","profileId":1},"ownerDomain":"elastic.com","ipAddress":"67.43.156.13","events":{"type":"login","name":"logout","parameters":[{"name":"login_type","value":"exchange"}]}}
1414
{"kind":"admin#reports#activity","id":{"time":"2020-10-02T15:00:00Z","uniqueQualifier":1,"applicationName":"login","customerId":"1"},"actor":{"callerType":"USER","email":"foo@bar.com","profileId":1},"ownerDomain":"elastic.com","ipAddress":"67.43.156.13","events":{"type":"login","name":"login_success","parameters":[{"name":"login_challenge_method","value":"backup_code"},{"name":"is_suspicious","boolValue":false},{"name":"login_type","value":"exchange"}]}}
1515
{"kind":"admin#reports#activity","id":{"time":"2020-10-02T15:00:00Z","uniqueQualifier":1,"applicationName":"login","customerId":"1"},"actor":{"callerType":"USER","email":"foo@bar.com","profileId":1},"ownerDomain":"elastic.com","ipAddress":"67.43.156.13","events":{"type":"login","name":"login_success","parameters":[{"name":"login_challenge_method","value":"password"},{"name":"is_suspicious","boolValue":true},{"name":"login_type","value":"google_password"}]}}
16-
16+
{"actor":{"email":"tl.zeous.daclitan@company.com","profileId":"111111111"},"etag":"Q2W123123123123","events":{"name":"login_verification","parameters":[{"name":"login_type","value":"google_password"},{"multiValue":["security_key"],"name":"login_challenge_method"},{"name":"login_challenge_status","value":"passed"},{"boolValue":true,"name":"is_second_factor"}],"type":"login"},"id":{"applicationName":"login","customerId":"123","time":"2025-02-27T05:59:58.481Z","uniqueQualifier":"123"},"ipAddress":"81.2.69.144","kind":"admin#reports#activity"}

packages/google_workspace/data_stream/login/_dev/test/pipeline/test-login.log-expected.json

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@
817817
"id": "1",
818818
"kind": "event",
819819
"original": "{\"kind\":\"admin#reports#activity\",\"id\":{\"time\":\"2020-10-02T15:00:00Z\",\"uniqueQualifier\":1,\"applicationName\":\"login\",\"customerId\":\"1\"},\"actor\":{\"callerType\":\"USER\",\"email\":\"foo@bar.com\",\"profileId\":1},\"ownerDomain\":\"elastic.com\",\"ipAddress\":\"67.43.156.13\",\"events\":{\"type\":\"login\",\"name\":\"login_challenge\",\"parameters\":[{\"name\":\"login_challenge_method\",\"value\":\"backup_code\"},{\"name\":\"login_challenge_status\",\"value\":\"Challenge Passed.\"},{\"name\":\"login_type\",\"value\":\"exchange\"}]}}",
820-
"outcome": "failure",
820+
"outcome": "success",
821821
"provider": "login",
822822
"type": [
823823
"info"
@@ -895,7 +895,7 @@
895895
"id": "1",
896896
"kind": "event",
897897
"original": "{\"kind\":\"admin#reports#activity\",\"id\":{\"time\":\"2020-10-02T15:00:00Z\",\"uniqueQualifier\":1,\"applicationName\":\"login\",\"customerId\":\"1\"},\"actor\":{\"callerType\":\"USER\",\"email\":\"foo@bar.com\",\"profileId\":1},\"ownerDomain\":\"elastic.com\",\"ipAddress\":\"67.43.156.13\",\"events\":{\"type\":\"login\",\"name\":\"login_verification\",\"parameters\":[{\"name\":\"is_second_factor\",\"boolValue\":false},{\"name\":\"login_challenge_method\",\"value\":\"backup_code\"},{\"name\":\"login_challenge_status\",\"value\":\"Challenge Passed.\"},{\"name\":\"login_type\",\"value\":\"exchange\"}]}}",
898-
"outcome": "failure",
898+
"outcome": "success",
899899
"provider": "login",
900900
"type": [
901901
"info"
@@ -1196,16 +1196,79 @@
11961196
}
11971197
},
11981198
{
1199+
"@timestamp": "2025-02-27T05:59:58.481Z",
11991200
"ecs": {
12001201
"version": "8.16.0"
12011202
},
12021203
"event": {
1204+
"action": "login_verification",
1205+
"category": [
1206+
"authentication"
1207+
],
1208+
"id": "123",
12031209
"kind": "event",
1204-
"original": ""
1210+
"original": "{\"actor\":{\"email\":\"tl.zeous.daclitan@company.com\",\"profileId\":\"111111111\"},\"etag\":\"Q2W123123123123\",\"events\":{\"name\":\"login_verification\",\"parameters\":[{\"name\":\"login_type\",\"value\":\"google_password\"},{\"multiValue\":[\"security_key\"],\"name\":\"login_challenge_method\"},{\"name\":\"login_challenge_status\",\"value\":\"passed\"},{\"boolValue\":true,\"name\":\"is_second_factor\"}],\"type\":\"login\"},\"id\":{\"applicationName\":\"login\",\"customerId\":\"123\",\"time\":\"2025-02-27T05:59:58.481Z\",\"uniqueQualifier\":\"123\"},\"ipAddress\":\"81.2.69.144\",\"kind\":\"admin#reports#activity\"}",
1211+
"outcome": "success",
1212+
"provider": "login",
1213+
"type": [
1214+
"info"
1215+
]
1216+
},
1217+
"google_workspace": {
1218+
"event": {
1219+
"type": "login"
1220+
},
1221+
"kind": "admin#reports#activity",
1222+
"login": {
1223+
"challenge_method": [
1224+
"security_key"
1225+
],
1226+
"challenge_status": "passed",
1227+
"is_second_factor": true,
1228+
"type": "google_password"
1229+
}
1230+
},
1231+
"organization": {
1232+
"id": "123"
1233+
},
1234+
"related": {
1235+
"ip": [
1236+
"81.2.69.144"
1237+
],
1238+
"user": [
1239+
"tl.zeous.daclitan"
1240+
]
1241+
},
1242+
"source": {
1243+
"geo": {
1244+
"city_name": "London",
1245+
"continent_name": "Europe",
1246+
"country_iso_code": "GB",
1247+
"country_name": "United Kingdom",
1248+
"location": {
1249+
"lat": 51.5142,
1250+
"lon": -0.0931
1251+
},
1252+
"region_iso_code": "GB-ENG",
1253+
"region_name": "England"
1254+
},
1255+
"ip": "81.2.69.144",
1256+
"user": {
1257+
"domain": "company.com",
1258+
"email": "tl.zeous.daclitan@company.com",
1259+
"id": "111111111",
1260+
"name": "tl.zeous.daclitan"
1261+
}
12051262
},
12061263
"tags": [
12071264
"preserve_original_event"
1208-
]
1265+
],
1266+
"user": {
1267+
"domain": "company.com",
1268+
"email": "tl.zeous.daclitan@company.com",
1269+
"id": "111111111",
1270+
"name": "tl.zeous.daclitan"
1271+
}
12091272
}
12101273
]
12111274
}

packages/google_workspace/data_stream/login/elasticsearch/ingest_pipeline/default.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ processors:
1717
- json:
1818
field: event.original
1919
target_field: json
20-
ignore_failure: true
2120
- set:
2221
field: event.kind
2322
value: event
@@ -216,11 +215,11 @@ processors:
216215
- set:
217216
field: event.outcome
218217
value: success
219-
if: 'ctx?.google_workspace?.login?.challenge_status != null && ctx?.event?.outcome == null && ctx?.google_workspace?.login?.challenge_status == "Challenge Passed"'
218+
if: ctx.event?.outcome == null && ctx.google_workspace?.login?.challenge_status?.toLowerCase()?.contains('passed') == true
220219
- set:
221220
field: event.outcome
222221
value: failure
223-
if: 'ctx?.google_workspace?.login?.challenge_status != null && ctx?.event?.outcome == null'
222+
if: 'ctx.google_workspace?.login?.challenge_status != null && ctx.event?.outcome == null'
224223
- script:
225224
lang: painless
226225
if: 'ctx?.google_workspace?.login?.affected_email_address != null && ctx?.google_workspace?.login?.affected_email_address.contains("@")'
@@ -279,4 +278,7 @@ on_failure:
279278
allow_duplicates: false
280279
- append:
281280
field: error.message
282-
value: '{{{ _ingest.on_failure_message }}}'
281+
value: >-
282+
Processor '{{{ _ingest.on_failure_processor_type }}}'
283+
{{{#_ingest.on_failure_processor_tag}}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
284+
{{{/_ingest.on_failure_processor_tag}}}failed with message '{{{ _ingest.on_failure_message }}}'

packages/google_workspace/data_stream/rules/elasticsearch/ingest_pipeline/default.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ processors:
1717
- json:
1818
field: event.original
1919
target_field: json
20-
ignore_failure: true
2120
- date:
2221
field: json.id.time
2322
if: ctx.json?.id?.time != null && ctx.json.id.time != ''
@@ -538,4 +537,7 @@ on_failure:
538537
allow_duplicates: false
539538
- append:
540539
field: error.message
541-
value: '{{{ _ingest.on_failure_message }}}'
540+
value: >-
541+
Processor '{{{ _ingest.on_failure_processor_type }}}'
542+
{{{#_ingest.on_failure_processor_tag}}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
543+
{{{/_ingest.on_failure_processor_tag}}}failed with message '{{{ _ingest.on_failure_message }}}'

packages/google_workspace/data_stream/saml/elasticsearch/ingest_pipeline/default.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ processors:
2929
- json:
3030
field: event.original
3131
target_field: json
32-
ignore_failure: true
3332
- date:
3433
field: json.id.time
3534
if: ctx.json?.id?.time != null && ctx.json.id.time != ''
@@ -199,4 +198,7 @@ on_failure:
199198
allow_duplicates: false
200199
- append:
201200
field: error.message
202-
value: '{{{ _ingest.on_failure_message }}}'
201+
value: >-
202+
Processor '{{{ _ingest.on_failure_processor_type }}}'
203+
{{{#_ingest.on_failure_processor_tag}}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
204+
{{{/_ingest.on_failure_processor_tag}}}failed with message '{{{ _ingest.on_failure_message }}}'

0 commit comments

Comments
 (0)