Skip to content

Commit

Permalink
Cherry-pick #10137 to 6.6: Teach elasticsearch/audit fileset to parse…
Browse files Browse the repository at this point in the history
… out some more fields (#10484)

Cherry-pick of PR #10137 to 6.6 branch. Original message: 

Resolves #10134.

This PR teaches the `elasticsearch/audit` fileset to parse out a few more fields, viz:

* `elasticsearch.audit.realm`,
* `elasticsearch.audit.roles`
* `elasticsearch.audit.indices`

It also teaches the fileset to parse `elasticsearch.audit.action` values that themselves contain `[` and `]` delimiters around sub-actions, e.g. `action=[indices:data/read/search[free_context]]`.
  • Loading branch information
ycombinator authored Feb 1, 2019
1 parent 148c283 commit c105e53
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ https://github.com/elastic/beats/compare/1035569addc4a3b29ffa14f8a08c27c1ace16ef

*Filebeat*

- Teach elasticsearch/audit fileset to parse out some more fields. {issue}10134[10134] {pull}10137[10137]

*Heartbeat*

*Journalbeat*
Expand Down
31 changes: 31 additions & 0 deletions filebeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,26 @@ The principal (username) that failed authentication
--
*`elasticsearch.audit.realm`*::
+
--
type: keyword
The authentication realm
--
*`elasticsearch.audit.roles`*::
+
--
type: array
example: ['kibana_user', 'beats_admin']
Roles to which the principal belongs
--
*`elasticsearch.audit.action`*::
+
--
Expand All @@ -1076,6 +1096,17 @@ The REST endpoint URI
--
*`elasticsearch.audit.indices`*::
+
--
type: array
example: ['foo-2019.01.04', 'foo-2019.01.03', 'foo-2019.01.06']
Indices accessed by action
--
*`elasticsearch.audit.request`*::
+
--
Expand Down
2 changes: 1 addition & 1 deletion filebeat/include/fields.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions filebeat/module/elasticsearch/audit/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
description: "The principal (username) that failed authentication"
example: "_anonymous"
type: keyword
- name: realm
description: "The authentication realm"
example": "active_directory"
type: keyword
- name: roles
description: "Roles to which the principal belongs"
example: [ "kibana_user", "beats_admin" ]
type: array
- name: action
description: "The name of the action that was executed"
example: "cluster:monitor/main"
Expand All @@ -30,6 +38,10 @@
description: "The REST endpoint URI"
example: /_xpack/security/_authenticate
type: keyword
- name: indices
description: "Indices accessed by action"
example: [ "foo-2019.01.04", "foo-2019.01.03", "foo-2019.01.06" ]
type: array
- name: request
description: "The type of request that was executed"
example: "ClearScrollRequest"
Expand Down
33 changes: 31 additions & 2 deletions filebeat/module/elasticsearch/audit/ingest/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,45 @@
"ES_AUDIT_ORIGIN_TYPE": "(origin_type\\=\\[%{WORD:elasticsearch.audit.origin_type}\\])?",
"ES_AUDIT_ORIGIN_ADDRESS": "(origin_address\\=\\[%{IPORHOST:elasticsearch.audit.origin_address}\\])?",
"ES_AUDIT_PRINCIPAL": "(principal\\=\\[%{WORD:elasticsearch.audit.principal}\\])?",
"ES_AUDIT_ACTION": "(action\\=\\[%{DATA:elasticsearch.audit.action}\\])?",
"ES_AUDIT_REALM": "(realm\\=\\[%{WORD:elasticsearch.audit.realm}\\])?",
"ES_AUDIT_ROLES": "(roles\\=\\[%{DATA:elasticsearch.audit.roles}\\])?",
"ES_AUDIT_ACTION": "(action\\=\\[%{DATA:elasticsearch.audit.action}(\\[%{DATA:elasticsearch.audit.sub_action}\\])?\\])?",
"ES_AUDIT_URI": "(uri=\\[%{DATA:elasticsearch.audit.uri}\\])?",
"ES_AUDIT_INDICES": "(indices\\=\\[%{DATA:elasticsearch.audit.indices}\\])?",
"ES_AUDIT_REQUEST": "(request\\=\\[%{WORD:elasticsearch.audit.request}\\])?",
"ES_AUDIT_REQUEST_BODY": "(request_body\\=\\[%{DATA:elasticsearch.audit.request_body}\\])?"
},
"patterns": [
"%{ES_TIMESTAMP}\\s*%{ES_NODE_NAME}\\s*%{ES_AUDIT_LAYER}\\s*%{ES_AUDIT_EVENT_TYPE}\\s*%{ES_AUDIT_ORIGIN_TYPE},?\\s*%{ES_AUDIT_ORIGIN_ADDRESS},?\\s*%{ES_AUDIT_PRINCIPAL},?\\s*%{ES_AUDIT_ACTION},?\\s*%{ES_AUDIT_URI},?\\s*%{ES_AUDIT_REQUEST},?\\s*%{ES_AUDIT_REQUEST_BODY},?"
"%{ES_TIMESTAMP}\\s*%{ES_NODE_NAME}\\s*%{ES_AUDIT_LAYER}\\s*%{ES_AUDIT_EVENT_TYPE}\\s*%{ES_AUDIT_ORIGIN_TYPE},?\\s*%{ES_AUDIT_ORIGIN_ADDRESS},?\\s*%{ES_AUDIT_PRINCIPAL},?\\s*%{ES_AUDIT_REALM},?\\s*%{ES_AUDIT_ROLES},?\\s*%{ES_AUDIT_ACTION},?\\s*%{ES_AUDIT_INDICES},?\\s*%{ES_AUDIT_URI},?\\s*%{ES_AUDIT_REQUEST},?\\s*%{ES_AUDIT_REQUEST_BODY},?"
]
}
},
{
"split": {
"field": "elasticsearch.audit.roles",
"separator": ",",
"ignore_missing": true
}
},
{
"split": {
"field": "elasticsearch.audit.indices",
"separator": ",",
"ignore_missing": true
}
},
{
"script": {
"lang": "painless",
"source": "if (ctx.elasticsearch.audit.sub_action != null) { ctx.elasticsearch.audit.action += '[' + ctx.elasticsearch.audit.sub_action + ']' }"
}
},
{
"remove": {
"field": "elasticsearch.audit.sub_action",
"ignore_missing": true
}
},
{
"date": {
"field": "elasticsearch.audit.timestamp",
Expand Down
16 changes: 16 additions & 0 deletions filebeat/module/elasticsearch/audit/test/test.log-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,27 @@
},
{
"@timestamp": "2019-01-08T14:15:02.011Z",
"elasticsearch.audit.action": "indices:data/read/search[free_context]",
"elasticsearch.audit.event_type": "access_granted",
"elasticsearch.audit.indices": [
"foo-2019.01.04",
"foo-2019.01.03",
"foo-2019.01.06",
"foo-2019.01.05",
"foo-2019.01.08",
"servicelog-2019.01.07"
],
"elasticsearch.audit.layer": "transport",
"elasticsearch.audit.origin_address": "192.168.2.1",
"elasticsearch.audit.origin_type": "transport",
"elasticsearch.audit.principal": "username",
"elasticsearch.audit.realm": "active_directory",
"elasticsearch.audit.request": "SearchFreeContextRequest",
"elasticsearch.audit.roles": [
"kibana_user",
"my_custom_role_1",
"foo_reader"
],
"elasticsearch.node.name": "NodeName-0",
"event.dataset": "elasticsearch.audit",
"fileset.module": "elasticsearch",
Expand Down

0 comments on commit c105e53

Please sign in to comment.