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

Changed auditd fields for ECS #10195

Merged
merged 2 commits into from
Jan 21, 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
7 changes: 7 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Auditbeat*
- Rename `process.exe` to `process.executable` in auditd module to align with ECS. {pull}9949[9949]
- Rename `process.cwd` to `process.working_directory` in auditd module to align with ECS. {pull}10195[10195]
- Change data type of `process.pid` and `process.ppid` to number in JSON output
of the auditd module. {pull}10195[10195]
- Change data type of `file.uid` and `file.gid` to string in JSON output of the
FIM module. {pull}10195[10195]

*Filebeat*

Expand Down Expand Up @@ -133,6 +138,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
*Auditbeat*

- Add system module. {pull}9546[9546]
- Add `user.id` (UID) and `user.name` for ECS. {pull}10195[10195]
- Add `group.id` (GID) and `group.name` for ECS. {pull}10195[10195]

*Filebeat*

Expand Down
14 changes: 14 additions & 0 deletions auditbeat/docs/breaking.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ In version 7.0 the following fields were renamed.
[frame="topbot",options="header"]
|======================
|Old Field|New Field
|`process.cwd` |`process.working_directory`
|`source.hostname` |`source.domain`
|======================

The JSON data types produced by the output have been changed to align with
the data types used in the Elasticsearch index template.

.Type Changes in 7.0
[frame="topbot",options="header"]
|======================
|Field|Old Type|New Type
|`file.gid` |number |string
|`file.uid` |number |string
|`process.pid` |string |number
|`process.ppid` |string |number
|======================

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this file. All Beats should have that!

cc @ruflin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping to generate something like this out of our migration file.

== Breaking changes in 6.2

As a general rule, we strive to keep backwards compatibility between minor
Expand Down
4 changes: 3 additions & 1 deletion auditbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ Process attributes.
*`process.cwd`*::
+
--
type: keyword
type: alias

alias to: process.working_directory

The current working directory.

Expand Down
10 changes: 8 additions & 2 deletions auditbeat/module/auditd/_meta/accept.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@
"module": "auditd",
"type": "syscall"
},
"group": {
"id": "0",
"name": "root"
},
"network": {
"direction": "incoming"
},
"process": {
"executable": "/usr/sbin/sshd",
"name": "sshd",
"pid": "1663",
"ppid": "1",
"pid": 1663,
"ppid": 1,
"title": "(sshd)"
},
"service": {
Expand All @@ -64,6 +68,8 @@
"fsgid": "0",
"fsuid": "0",
"gid": "0",
"id": "0",
"name": "root",
"name_map": {
"egid": "root",
"euid": "root",
Expand Down
4 changes: 3 additions & 1 deletion auditbeat/module/auditd/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"process": {
"executable": "/usr/sbin/sshd",
"pid": "12635"
"pid": 12635
},
"service": {
"type": "auditd"
Expand All @@ -47,6 +47,8 @@
},
"user": {
"auid": "unset",
"id": "0",
"name": "root",
"name_map": {
"uid": "root"
},
Expand Down
12 changes: 8 additions & 4 deletions auditbeat/module/auditd/_meta/execve.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@
"path": "/bin/uname",
"uid": "0"
},
"group": {
"id": "1002"
},
"process": {
"args": [
"uname",
"-a"
],
"cwd": "/home/andrew_kroh",
"executable": "/bin/uname",
"name": "uname",
"pid": "10043",
"ppid": "10027",
"title": "uname -a"
"pid": 10043,
"ppid": 10027,
"title": "uname -a",
"working_directory": "/home/andrew_kroh"
},
"service": {
"type": "auditd"
Expand All @@ -91,6 +94,7 @@
"fsgid": "1002",
"fsuid": "1001",
"gid": "1002",
"id": "1001",
"sgid": "1002",
"suid": "1001",
"uid": "1001"
Expand Down
4 changes: 3 additions & 1 deletion auditbeat/module/auditd/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@
description: Process attributes.
fields:
- name: cwd
type: keyword
type: alias
path: process.working_directory
migration: true
description: The current working directory.

- name: source
Expand Down
30 changes: 27 additions & 3 deletions auditbeat/module/auditd/audit_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ func buildMetricbeatEvent(msgs []*auparse.AuditMessage, config Config) mb.Event

// Add root level fields.
addUser(auditEvent.User, out.RootFields)
addGroup(auditEvent.User, out.RootFields)
addProcess(auditEvent.Process, out.RootFields)
addFile(auditEvent.File, out.RootFields)
addAddress(auditEvent.Source, "source", out.RootFields)
Expand Down Expand Up @@ -546,6 +547,25 @@ func addUser(u aucoalesce.User, m common.MapStr) {
user["name_map"] = u.Names
}
}
if uid, found := u.IDs["uid"]; found {
user["id"] = uid
}
if uidName, found := u.Names["uid"]; found {
user["name"] = uidName
}
}

func addGroup(u aucoalesce.User, m common.MapStr) {
group := make(common.MapStr, 2)
if gid, found := u.IDs["gid"]; found {
group["id"] = gid
}
if gidName, found := u.Names["gid"]; found {
group["name"] = gidName
}
if len(group) > 0 {
m.Put("group", group)
}
}

func addProcess(p aucoalesce.Process, m common.MapStr) {
Expand All @@ -556,10 +576,14 @@ func addProcess(p aucoalesce.Process, m common.MapStr) {
process := common.MapStr{}
m.Put("process", process)
if p.PID != "" {
process["pid"] = p.PID
if pid, err := strconv.Atoi(p.PID); err == nil {
process["pid"] = pid
}
}
if p.PPID != "" {
process["ppid"] = p.PPID
if ppid, err := strconv.Atoi(p.PPID); err == nil {
process["ppid"] = ppid
}
}
if p.Title != "" {
process["title"] = p.Title
Expand All @@ -571,7 +595,7 @@ func addProcess(p aucoalesce.Process, m common.MapStr) {
process["executable"] = p.Exe
}
if p.CWD != "" {
process["cwd"] = p.CWD
process["working_directory"] = p.CWD
}
if len(p.Args) > 0 {
process["args"] = p.Args
Expand Down
2 changes: 1 addition & 1 deletion auditbeat/module/auditd/audit_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func assertHasBinCatExecve(t *testing.T, events []mb.Event) {
t.Helper()

for _, e := range events {
v, err := e.RootFields.GetValue("process.exe")
v, err := e.RootFields.GetValue("process.executable")
if err == nil {
if exe, ok := v.(string); ok && exe == "/bin/cat" {
return
Expand Down
2 changes: 1 addition & 1 deletion auditbeat/module/auditd/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions auditbeat/module/file_integrity/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
"created",
"updated"
],
"dataset": "file",
"module": "file_integrity"
},
"file": {
"ctime": "2018-01-05T03:28:26Z",
"gid": 20,
"ctime": "2019-01-19T15:21:37.939882147Z",
"gid": "20",
"group": "staff",
"inode": "20164115",
"inode": "8028777",
"mode": "0600",
"mtime": "2018-01-05T03:28:26Z",
"mtime": "2019-01-19T15:21:37.939882147Z",
"owner": "akroh",
"path": "/private/var/folders/8x/rnyk6yxn6w97lddn3bs02gf00000gn/T/audit-file864778064/file.data",
"path": "/private/var/folders/kx/7y5ztvx100z148jvds11c6rh0000gn/T/audit-file418060202/file.data",
"size": 11,
"type": "file",
"uid": 501
"uid": "501"
},
"hash": {
"sha1": "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"
},
"service": {
"type": "file_integrity"
}
}
4 changes: 2 additions & 2 deletions auditbeat/module/file_integrity/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ func buildMetricbeatEvent(e *Event, existedBefore bool) mb.Event {
file["uid"] = info.SID
}
} else {
file["uid"] = info.UID
file["gid"] = info.GID
file["uid"] = strconv.Itoa(int(info.UID))
file["gid"] = strconv.Itoa(int(info.GID))
file["mode"] = fmt.Sprintf("%#04o", uint32(info.Mode))
}

Expand Down
4 changes: 4 additions & 0 deletions dev-tools/ecs-migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,10 @@
to: process.executable
alias: true

- from: process.cwd
to: process.working_directory
alias: true


# Metricbeat

Expand Down