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

[Auditbeat] Field cleanup for 8.0 #28378

Merged
merged 4 commits into from
Oct 15, 2021
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
3 changes: 2 additions & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ https:/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

- File integrity dataset (macOS): Replace unnecessary `file.origin.raw` (type keyword) with `file.origin.text` (type `text`). {issue}12423[12423] {pull}15630[15630]
- Change event.kind=error to event.kind=event to comply with ECS. {issue}18870[18870] {pull}20685[20685]

- File integrity dataset: Remove non-ECS `hash.*` fields. Hashes are under `file.hash.*`. {issue}19039[19039] {pull}28378[28378]
- Auditd dataset: Removes the authentication_success and authentication_failure event.type values for user logins. {issue}19039[19039] {pull}28378[28378]

*Filebeat*

Expand Down
27 changes: 2 additions & 25 deletions auditbeat/module/auditd/audit_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,35 +657,12 @@ func buildMetricbeatEvent(msgs []*auparse.AuditMessage, config Config) mb.Event
}

func normalizeEventFields(event *aucoalesce.Event, m common.MapStr) {
// we need to merge types for backwards compatibility
types := event.ECS.Event.Type

// Remove this block in 8.x
{
getFieldAsStr := func(key string) (s string, found bool) {
iface, err := m.GetValue(key)
if err != nil {
return
}
s, found = iface.(string)
return
}
oldCategory, ok1 := getFieldAsStr("event.category")
oldAction, ok2 := getFieldAsStr("event.action")
oldOutcome, ok3 := getFieldAsStr("event.outcome")
if ok1 && ok2 && ok3 {
if oldCategory == "user-login" && oldAction == "logged-in" { // USER_LOGIN
types = append(types, fmt.Sprintf("authentication_%s", oldOutcome))
}
}
}

m.Put("event.kind", "event")
if len(event.ECS.Event.Category) > 0 {
m.Put("event.category", event.ECS.Event.Category)
}
if len(types) > 0 {
m.Put("event.type", types)
if len(event.ECS.Event.Type) > 0 {
m.Put("event.type", event.ECS.Event.Type)
}
if event.ECS.Event.Outcome != "" {
m.Put("event.outcome", event.ECS.Event.Outcome)
Expand Down
4 changes: 2 additions & 2 deletions auditbeat/module/auditd/audit_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ func TestLoginType(t *testing.T) {
for idx, expected := range []common.MapStr{
{
"event.category": []string{"authentication"},
"event.type": []string{"start", "authentication_failure"},
"event.type": []string{"start"},
"event.outcome": "failure",
"user.effective.name": "(invalid user)",
"user.id": nil,
"session": nil,
},
{
"event.category": []string{"authentication"},
"event.type": []string{"start", "authentication_success"},
"event.type": []string{"start"},
"event.outcome": "success",
"user.effective.name": "adrian",
"user.audit.id": nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
],
"outcome": "failure",
"type": [
"start",
"authentication_failure"
"start"
]
},
"network": {
Expand Down Expand Up @@ -98,8 +97,7 @@
],
"outcome": "success",
"type": [
"start",
"authentication_success"
"start"
]
},
"network": {
Expand Down Expand Up @@ -254,4 +252,4 @@
"name": "alice"
}
}
]
]
2 changes: 0 additions & 2 deletions auditbeat/module/file_integrity/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ func buildMetricbeatEvent(e *Event, existedBefore bool) mb.Event {
hashes[string(hashType)] = digest
}
file["hash"] = hashes
// Remove this for 8.x
out.MetricSetFields.Put("hash", hashes)
}

out.MetricSetFields.Put("event.kind", "event")
Expand Down
3 changes: 0 additions & 3 deletions auditbeat/module/file_integrity/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,6 @@ func TestBuildEvent(t *testing.T) {

assertHasKey(t, fields, "file.hash.sha1")
assertHasKey(t, fields, "file.hash.sha256")
// Remove in 8.x
assertHasKey(t, fields, "hash.sha1")
assertHasKey(t, fields, "hash.sha256")
})
if runtime.GOOS == "windows" {
t.Run("drive letter", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions auditbeat/tests/system/test_file_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def escape_path(path):
def has_file(objs, path, sha1hash):
found = False
for obj in objs:
if 'file.path' in obj and 'hash.sha1' in obj \
and obj['file.path'].lower() == path.lower() and obj['hash.sha1'] == sha1hash:
if 'file.path' in obj and 'file.hash.sha1' in obj \
and obj['file.path'].lower() == path.lower() and obj['file.hash.sha1'] == sha1hash:
found = True
break
assert found, "File '{0}' with sha1sum '{1}' not found".format(path, sha1hash)
Expand Down