Skip to content

[Auditbeat] Remove unset auid and session fields #11815

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

Merged
merged 2 commits into from
Apr 18, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
*Auditbeat*

- Auditd module: Normalized value of `event.category` field from `user-login` to `authentication`. {pull}11432[11432]
- Auditd module: Unset `auditd.session` and `user.audit.id` fields are removed from audit events. {issue}11431[11431] {pull}11815[11815]

*Filebeat*

Expand Down
8 changes: 7 additions & 1 deletion auditbeat/module/auditd/audit_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (

unicast = "unicast"
multicast = "multicast"
uidUnset = "unset"

lostEventsUpdateInterval = time.Second * 15
maxDefaultStreamBufferConsumers = 4
Expand Down Expand Up @@ -485,10 +486,12 @@ func buildMetricbeatEvent(msgs []*auparse.AuditMessage, config Config) mb.Event
"message_type": strings.ToLower(auditEvent.Type.String()),
"sequence": auditEvent.Sequence,
"result": auditEvent.Result,
"session": auditEvent.Session,
"data": createAuditdData(auditEvent.Data),
},
}
if auditEvent.Session != uidUnset {
out.ModuleFields.Put("session", auditEvent.Session)
}

// Add root level fields.
addUser(auditEvent.User, out.RootFields)
Expand Down Expand Up @@ -596,6 +599,9 @@ func addUser(u aucoalesce.User, m common.MapStr) {
m.Put("user", user)

for id, value := range u.IDs {
if value == uidUnset {
continue
}
switch id {
case "uid":
user["id"] = value
Expand Down
8 changes: 7 additions & 1 deletion auditbeat/module/auditd/audit_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,23 @@ func TestLoginType(t *testing.T) {
"event.outcome": "failure",
"user.name": "(invalid user)",
"user.id": nil,
"session": nil,
},
{
"event.category": "authentication",
"event.type": "authentication_success",
"event.outcome": "success",
"user.name": "adrian",
"user.audit.id": nil,
"auditd.session": nil,
},
{
"event.category": "user-login",
"event.outcome": "success",
"user.name": "root",
"user.id": "0",
"user.audit.id": "0",
"auditd.session": "62",
},
} {
beatEvent := mbtest.StandardizeEvent(ms, events[idx], core.AddDatasetToEvent)
Expand All @@ -169,7 +174,8 @@ func TestLoginType(t *testing.T) {
assert.NoError(t, err, msg)
assert.Equal(t, v, cur, msg)
} else {
assert.Error(t, err, msg)
_, err := beatEvent.GetValue(k)
assert.Equal(t, common.ErrKeyNotFound, err, msg)
}
}
}
Expand Down