Skip to content

Commit 8130976

Browse files
authored
[gcp] Add policy_violation_info metadata and related fields to GCP audit logs (#10886)
* add missing fields gcp audit logs * update changelog entry
1 parent 1664d36 commit 8130976

File tree

10 files changed

+587
-15
lines changed

10 files changed

+587
-15
lines changed

packages/gcp/changelog.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# newer versions go on top
2+
- version: "2.38.0"
3+
changes:
4+
- description: Add `policy_violation_info`, `metadata` and `related` fields to audit logs.
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/10886
7+
- description: Update GCP audit log dashboard to use correct `email` field.
8+
type: bugfix
9+
link: https://github.com/elastic/integrations/pull/10886
210
- version: "2.37.2"
311
changes:
412
- description: Fix definition of subfields of nested objects

packages/gcp/data_stream/audit/_dev/test/pipeline/test-audit.log

Lines changed: 8 additions & 4 deletions
Large diffs are not rendered by default.

packages/gcp/data_stream/audit/_dev/test/pipeline/test-audit.log-expected.json

Lines changed: 452 additions & 9 deletions
Large diffs are not rendered by default.

packages/gcp/data_stream/audit/_dev/test/pipeline/test-sdh-3695.log-expected.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
"level": "INFO",
4040
"logger": "organizations/123456789098/logs/cloudaudit.googleapis.com%2Fdata_access"
4141
},
42+
"related": {
43+
"user": [
44+
"joel.miller@contoso.com"
45+
]
46+
},
4247
"service": {
4348
"name": "cloudresourcemanager.googleapis.com"
4449
},

packages/gcp/data_stream/audit/elasticsearch/ingest_pipeline/default.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ processors:
178178
field: gcp.audit.labels
179179
copy_from: json.labels
180180
if: ctx.json?.labels != null
181+
181182
##
182183
# RequestMetadata
183184
# .protoPayload.requestMetadata
@@ -196,6 +197,48 @@ processors:
196197
- user_agent:
197198
field: user_agent.original
198199
ignore_missing: true
200+
201+
##
202+
# Metadata
203+
# .protoPayload.metadata
204+
# https://cloud.google.com/logging/docs/reference/audit/auditlog/rest/Shared.Types/AuditLog
205+
##
206+
- set:
207+
field: gcp.audit.metadata
208+
copy_from: json.protoPayload.metadata
209+
if: ctx.json?.protoPayload?.metadata != null
210+
211+
##
212+
# PolicyViolationInfo
213+
# .protoPayload.orgPolicyViolationInfo
214+
# https://cloud.google.com/logging/docs/reference/audit/auditlog/rest/Shared.Types/AuditLog#policyviolationinfo
215+
##
216+
- set:
217+
field: gcp.audit.policy_violation_info.violations
218+
copy_from: json.protoPayload.policyViolationInfo.orgPolicyViolationInfo.violationInfo
219+
ignore_failure: true
220+
- foreach:
221+
field: gcp.audit.policy_violation_info.violations
222+
ignore_missing: true
223+
ignore_failure: true
224+
processor:
225+
rename:
226+
field: _ingest._value.resourceAttributes
227+
target_field: _ingest._value.resource_attributes
228+
if: ctx.gcp?.audit?.policy_violation_info instanceof List
229+
- rename:
230+
field: json.protoPayload.policyViolationInfo.orgPolicyViolationInfo.payload
231+
target_field: gcp.audit.policy_violation_info.payload
232+
ignore_failure: true
233+
- rename:
234+
field: json.protoPayload.policyViolationInfo.orgPolicyViolationInfo.resourceType
235+
target_field: gcp.audit.policy_violation_info.resource_type
236+
ignore_failure: true
237+
- rename:
238+
field: json.protoPayload.policyViolationInfo.orgPolicyViolationInfo.resourceTags
239+
target_field: gcp.audit.policy_violation_info.resource_tags
240+
ignore_failure: true
241+
199242
##
200243
# LogEntryOperation
201244
# .operation
@@ -300,6 +343,10 @@ processors:
300343
field: gcp.audit.status.message
301344
copy_from: json.protoPayload.status.message
302345
ignore_failure: true
346+
- set:
347+
field: gcp.audit.status.details
348+
copy_from: json.protoPayload.status.details
349+
ignore_empty_value: true
303350
- set:
304351
field: event.outcome
305352
value: success
@@ -365,6 +412,16 @@ processors:
365412
target_field: source.as.organization.name
366413
ignore_missing: true
367414

415+
# Related fields
416+
- append:
417+
field: related.ip
418+
value: "{{{source.ip}}}"
419+
allow_duplicates: false
420+
- append:
421+
field: related.user
422+
value: "{{{client.user.email}}}"
423+
if: ctx.client?.user?.email != null
424+
allow_duplicates: false
368425
##
369426
# clean-up
370427
##

packages/gcp/data_stream/audit/fields/fields.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
- name: last
7373
type: boolean
7474
description: "Optional. Set this to True if this is the last log entry in the operation."
75+
- name: metadata
76+
type: flattened
77+
description: |
78+
Service-specific data about the request, response, and other information associated with the current audited event.
7579
- name: method_name
7680
type: keyword
7781
description: |
@@ -80,6 +84,35 @@
8084
type: long
8185
description: |
8286
The number of items returned from a List or Query API method, if applicable.
87+
- name: policy_violation_info
88+
type: group
89+
fields:
90+
- name: payload
91+
type: flattened
92+
description: Resource payload that is currently in scope and is subjected to orgpolicy conditions.
93+
- name: resource_tags
94+
type: flattened
95+
description: Tags referenced on the resource at the time of evaluation.
96+
- name: resource_type
97+
type: keyword
98+
description: Resource type that the orgpolicy is checked against.
99+
- name: violations
100+
type: nested
101+
description: |
102+
Provides information about the Policy violation info for the request.
103+
fields:
104+
- name: constraint
105+
type: keyword
106+
description: "Constraint name."
107+
- name: errorMessage
108+
type: keyword
109+
description: "Error message that policy is indicating."
110+
- name: checkedValue
111+
type: keyword
112+
description: "Value that is being checked for the policy."
113+
- name: policyType
114+
type: keyword
115+
description: "Indicates the type of the policy."
83116
- name: request
84117
type: flattened
85118
- name: request_metadata
@@ -121,6 +154,10 @@
121154
- name: message
122155
type: keyword
123156
description: "A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client."
157+
- name: details
158+
type: flattened
159+
description: |
160+
A list of messages that carry the error details.
124161
- name: flattened
125162
type: flattened
126163
description: Contains the full audit document as sent by GCP.

packages/gcp/docs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,16 @@ Please refer to the following [document](https://www.elastic.co/guide/en/ecs/cur
249249
| gcp.audit.logentry_operation.id | Optional. An arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation. | keyword |
250250
| gcp.audit.logentry_operation.last | Optional. Set this to True if this is the last log entry in the operation. | boolean |
251251
| gcp.audit.logentry_operation.producer | Optional. An arbitrary producer identifier. The combination of id and producer must be globally unique. | keyword |
252+
| gcp.audit.metadata | Service-specific data about the request, response, and other information associated with the current audited event. | flattened |
252253
| gcp.audit.method_name | The name of the service method or operation. For API calls, this should be the name of the API method. For example, 'google.datastore.v1.Datastore.RunQuery'. | keyword |
253254
| gcp.audit.num_response_items | The number of items returned from a List or Query API method, if applicable. | long |
255+
| gcp.audit.policy_violation_info.payload | Resource payload that is currently in scope and is subjected to orgpolicy conditions. | flattened |
256+
| gcp.audit.policy_violation_info.resource_tags | Tags referenced on the resource at the time of evaluation. | flattened |
257+
| gcp.audit.policy_violation_info.resource_type | Resource type that the orgpolicy is checked against. | keyword |
258+
| gcp.audit.policy_violation_info.violations.checkedValue | Value that is being checked for the policy. | keyword |
259+
| gcp.audit.policy_violation_info.violations.constraint | Constraint name. | keyword |
260+
| gcp.audit.policy_violation_info.violations.errorMessage | Error message that policy is indicating. | keyword |
261+
| gcp.audit.policy_violation_info.violations.policyType | Indicates the type of the policy. | keyword |
254262
| gcp.audit.request | | flattened |
255263
| gcp.audit.request_metadata.caller_ip | The IP address of the caller. | ip |
256264
| gcp.audit.request_metadata.caller_supplied_user_agent | The user agent of the caller. This information is not authenticated and should be treated accordingly. | keyword |
@@ -260,6 +268,7 @@ Please refer to the following [document](https://www.elastic.co/guide/en/ecs/cur
260268
| gcp.audit.response | | flattened |
261269
| gcp.audit.service_name | The name of the API service performing the operation. For example, datastore.googleapis.com. | keyword |
262270
| gcp.audit.status.code | The status code, which should be an enum value of google.rpc.Code. | integer |
271+
| gcp.audit.status.details | A list of messages that carry the error details. | flattened |
263272
| gcp.audit.status.message | A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. | keyword |
264273
| gcp.audit.type | Type property. | keyword |
265274
| gcp.destination.instance.project_id | ID of the project containing the VM. | keyword |

packages/gcp/docs/audit.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ Please refer to the following [document](https://www.elastic.co/guide/en/ecs/cur
3838
| gcp.audit.logentry_operation.id | Optional. An arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation. | keyword |
3939
| gcp.audit.logentry_operation.last | Optional. Set this to True if this is the last log entry in the operation. | boolean |
4040
| gcp.audit.logentry_operation.producer | Optional. An arbitrary producer identifier. The combination of id and producer must be globally unique. | keyword |
41+
| gcp.audit.metadata | Service-specific data about the request, response, and other information associated with the current audited event. | flattened |
4142
| gcp.audit.method_name | The name of the service method or operation. For API calls, this should be the name of the API method. For example, 'google.datastore.v1.Datastore.RunQuery'. | keyword |
4243
| gcp.audit.num_response_items | The number of items returned from a List or Query API method, if applicable. | long |
44+
| gcp.audit.policy_violation_info.payload | Resource payload that is currently in scope and is subjected to orgpolicy conditions. | flattened |
45+
| gcp.audit.policy_violation_info.resource_tags | Tags referenced on the resource at the time of evaluation. | flattened |
46+
| gcp.audit.policy_violation_info.resource_type | Resource type that the orgpolicy is checked against. | keyword |
47+
| gcp.audit.policy_violation_info.violations.checkedValue | Value that is being checked for the policy. | keyword |
48+
| gcp.audit.policy_violation_info.violations.constraint | Constraint name. | keyword |
49+
| gcp.audit.policy_violation_info.violations.errorMessage | Error message that policy is indicating. | keyword |
50+
| gcp.audit.policy_violation_info.violations.policyType | Indicates the type of the policy. | keyword |
4351
| gcp.audit.request | | flattened |
4452
| gcp.audit.request_metadata.caller_ip | The IP address of the caller. | ip |
4553
| gcp.audit.request_metadata.caller_supplied_user_agent | The user agent of the caller. This information is not authenticated and should be treated accordingly. | keyword |
@@ -49,6 +57,7 @@ Please refer to the following [document](https://www.elastic.co/guide/en/ecs/cur
4957
| gcp.audit.response | | flattened |
5058
| gcp.audit.service_name | The name of the API service performing the operation. For example, datastore.googleapis.com. | keyword |
5159
| gcp.audit.status.code | The status code, which should be an enum value of google.rpc.Code. | integer |
60+
| gcp.audit.status.details | A list of messages that carry the error details. | flattened |
5261
| gcp.audit.status.message | A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. | keyword |
5362
| gcp.audit.type | Type property. | keyword |
5463
| gcp.destination.instance.project_id | ID of the project containing the VM. | keyword |

packages/gcp/kibana/search/gcp-d88364c0-73a1-11ea-a345-f985c61fe654.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"attributes": {
33
"columns": [
44
"event.action",
5-
"user.email",
5+
"client.user.email",
66
"service.name",
77
"gcp.audit.type",
88
"event.outcome",

packages/gcp/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: gcp
22
title: Google Cloud Platform
3-
version: "2.37.2"
3+
version: "2.38.0"
44
description: Collect logs and metrics from Google Cloud Platform with Elastic Agent.
55
type: integration
66
icons:

0 commit comments

Comments
 (0)