Skip to content

Commit

Permalink
Cherry-pick #22991 to 7.x: [Auditbeat] system/socket: Use ingress/egr…
Browse files Browse the repository at this point in the history
…ess for network direction (#23007)

* [Auditbeat] system/socket: Use ingress/egress for network direction (#22991)

* [Auditbeat] system/socket: Use ingress/egress for network direction

* Add changelog entry

(cherry picked from commit 52fc1cf)

* Fix up changelog

* Remove stray changelog entry
  • Loading branch information
Andrew Stucki authored Dec 9, 2020
1 parent 16a550b commit dcfe745
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Auditbeat*

- Use ECS 1.7 ingress/egress network directions instead of inbound/outbound for system/socket. {pull}22991[22991]
- Use ingress/egress instead of inbound/outbound for ECS 1.7 in auditd module. {pull}23000[23000]

*Filebeat*
Expand Down
16 changes: 8 additions & 8 deletions x-pack/auditbeat/module/system/socket/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (e *tcpConnectResult) Update(s *state) error {
pid: e.Meta.PID,
inetType: inetTypeIPv4,
proto: protoTCP,
dir: directionOutbound,
dir: directionEgress,
complete: true,
lastSeen: kernelTime(call.Meta.Timestamp),
local: newEndpointIPv4(call.LAddr, call.LPort, 0, 0),
Expand All @@ -147,7 +147,7 @@ func (e *tcpConnectResult) Update(s *state) error {
pid: e.Meta.PID,
inetType: inetTypeIPv6,
proto: protoTCP,
dir: directionOutbound,
dir: directionEgress,
complete: true,
lastSeen: kernelTime(call.Meta.Timestamp),
local: newEndpointIPv6(call.LAddrA, call.LAddrB, call.LPort, 0, 0),
Expand Down Expand Up @@ -193,7 +193,7 @@ func (e *tcpAcceptResult) asFlow() flow {
pid: e.Meta.PID,
inetType: inetType(e.Af),
proto: protoTCP,
dir: directionInbound,
dir: directionIngress,
complete: true,
lastSeen: kernelTime(e.Meta.Timestamp),
}
Expand Down Expand Up @@ -237,7 +237,7 @@ func (e *tcpAcceptResult4) asFlow() flow {
pid: e.Meta.PID,
inetType: inetType(e.Af),
proto: protoTCP,
dir: directionInbound,
dir: directionIngress,
complete: true,
lastSeen: kernelTime(e.Meta.Timestamp),
}
Expand Down Expand Up @@ -551,7 +551,7 @@ func (e *udpSendMsgCall) asFlow() flow {
pid: e.Meta.PID,
inetType: inetTypeIPv4,
proto: protoUDP,
dir: directionOutbound,
dir: directionEgress,
lastSeen: kernelTime(e.Meta.Timestamp),
local: newEndpointIPv4(e.LAddr, e.LPort, 1, uint64(e.Size)+minIPv4UdpPacketSize),
remote: newEndpointIPv4(raddr, rport, 0, 0),
Expand Down Expand Up @@ -605,7 +605,7 @@ func (e *udpv6SendMsgCall) asFlow() flow {
pid: e.Meta.PID,
inetType: inetTypeIPv6,
proto: protoUDP,
dir: directionOutbound,
dir: directionEgress,
lastSeen: kernelTime(e.Meta.Timestamp),
// In IPv6, udpv6_sendmsg increments local counters as there is no
// corresponding ip6_local_out call.
Expand Down Expand Up @@ -665,7 +665,7 @@ func (e *udpQueueRcvSkb) asFlow() flow {
pid: e.Meta.PID,
inetType: inetTypeIPv4,
proto: protoUDP,
dir: directionInbound,
dir: directionIngress,
lastSeen: kernelTime(e.Meta.Timestamp),
local: newEndpointIPv4(e.LAddr, e.LPort, 0, 0),
}
Expand Down Expand Up @@ -739,7 +739,7 @@ func (e *udpv6QueueRcvSkb) asFlow() flow {
pid: e.Meta.PID,
inetType: inetTypeIPv6,
proto: protoUDP,
dir: directionInbound,
dir: directionIngress,
lastSeen: kernelTime(e.Meta.Timestamp),
local: newEndpointIPv6(e.LAddrA, e.LAddrB, e.LPort, 0, 0),
}
Expand Down
14 changes: 7 additions & 7 deletions x-pack/auditbeat/module/system/socket/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ type flowDirection uint8

const (
directionUnknown flowDirection = iota
directionInbound
directionOutbound
directionIngress
directionEgress
)

// String returns the textual representation of the flowDirection.
func (d flowDirection) String() string {
switch d {
case directionInbound:
return "inbound"
case directionOutbound:
return "outbound"
case directionIngress:
return "ingress"
case directionEgress:
return "egress"
default:
return "unknown"
}
Expand Down Expand Up @@ -900,7 +900,7 @@ func (f *flow) toEvent(final bool) (ev mb.Event, err error) {
}

src, dst := local, remote
if f.dir == directionInbound {
if f.dir == directionIngress {
src, dst = dst, src
}

Expand Down
8 changes: 4 additions & 4 deletions x-pack/auditbeat/module/system/socket/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestTCPConnWithProcess(t *testing.T) {
"destination.bytes": uint64(19),
"server.ip": remoteIP,
"server.port": remotePort,
"network.direction": "outbound",
"network.direction": "egress",
"network.transport": "tcp",
"network.type": "ipv4",
"process.pid": 1234,
Expand Down Expand Up @@ -245,7 +245,7 @@ func TestTCPConnWithProcessSocketTimeouts(t *testing.T) {
"destination.bytes": uint64(19),
"server.ip": remoteIP,
"server.port": remotePort,
"network.direction": "outbound",
"network.direction": "egress",
"network.transport": "tcp",
"network.type": "ipv4",
"process.pid": 1234,
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestUDPOutgoingSinglePacketWithProcess(t *testing.T) {
"destination.bytes": uint64(0),
"server.ip": remoteIP,
"server.port": remotePort,
"network.direction": "outbound",
"network.direction": "egress",
"network.transport": "udp",
"network.type": "ipv4",
"process.pid": 1234,
Expand Down Expand Up @@ -453,7 +453,7 @@ func TestUDPIncomingSinglePacketWithProcess(t *testing.T) {
"destination.bytes": uint64(0),
"server.ip": localIP,
"server.port": localPort,
"network.direction": "inbound",
"network.direction": "ingress",
"network.transport": "udp",
"network.type": "ipv4",
"process.pid": 1234,
Expand Down
20 changes: 10 additions & 10 deletions x-pack/auditbeat/tests/system/test_system_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def expected(self):
"server.port": self.server_addr[1],
"network.transport": "tcp",
"network.type": "ipv4",
"network.direction": "outbound",
"network.direction": "egress",
"group.id": str(os.getgid()),
"user.id": str(os.getuid()),
"process.pid": os.getpid(),
Expand Down Expand Up @@ -265,7 +265,7 @@ def expected(self):
"destination.packets": 1,
"destination.port": self.server_addr[1],
"group.id": str(os.getgid()),
"network.direction": "outbound",
"network.direction": "egress",
"network.packets": 4,
"network.transport": "udp",
"network.type": "ipv4",
Expand Down Expand Up @@ -308,7 +308,7 @@ def expected(self):
"source.packets": 5,
"source.port": self.server_addr[1],
"group.id": str(os.getgid()),
"network.direction": "inbound",
"network.direction": "ingress",
"network.packets": 7,
"network.transport": "udp",
"network.type": "ipv4",
Expand Down Expand Up @@ -355,7 +355,7 @@ def expected(self):
"source.packets": 5,
"source.port": self.server_addr[1],
"group.id": str(os.getgid()),
"network.direction": "inbound",
"network.direction": "ingress",
"network.packets": 7,
"network.transport": "udp",
"network.type": "ipv6",
Expand Down Expand Up @@ -398,7 +398,7 @@ def expected(self):
"destination.packets": 1,
"destination.port": self.server_addr[1],
"group.id": str(os.getgid()),
"network.direction": "outbound",
"network.direction": "egress",
"network.packets": 4,
"network.transport": "udp",
"network.type": "ipv6",
Expand Down Expand Up @@ -439,7 +439,7 @@ def expected(self):
"destination.packets": 1,
"destination.port": self.server_addr[0][1],
"group.id": str(os.getgid()),
"network.direction": "outbound",
"network.direction": "egress",
"network.packets": 2,
"network.transport": "udp",
"network.type": "ipv4",
Expand All @@ -460,7 +460,7 @@ def expected(self):
"destination.packets": 1,
"destination.port": self.server_addr[1][1],
"group.id": str(os.getgid()),
"network.direction": "outbound",
"network.direction": "egress",
"network.packets": 2,
"network.transport": "udp",
"network.type": "ipv4",
Expand All @@ -481,7 +481,7 @@ def expected(self):
"destination.packets": 1,
"destination.port": self.server_addr[2][1],
"group.id": str(os.getgid()),
"network.direction": "outbound",
"network.direction": "egress",
"network.packets": 2,
"network.transport": "udp",
"network.type": "ipv4",
Expand Down Expand Up @@ -622,7 +622,7 @@ def expected(self):
"event.kind": "event",
"event.module": "system",
"network.bytes": Comparison(operator.gt, 60),
"network.direction": "inbound",
"network.direction": "ingress",
"network.packets": 2,
"network.transport": "udp",
"network.type": self.socket_factory.network,
Expand Down Expand Up @@ -653,7 +653,7 @@ def expected(self):
"event.kind": "event",
"event.module": "system",
"network.packets": net_bytes,
"network.direction": "inbound",
"network.direction": "ingress",
"network.packets": net_packets,
"network.transport": self.socket_factory.transport,
"network.type": self.socket_factory.network,
Expand Down

0 comments on commit dcfe745

Please sign in to comment.