diff --git a/lib/bpf/bpf.go b/lib/bpf/bpf.go index 819adff97be45..3deb36aebe8f9 100644 --- a/lib/bpf/bpf.go +++ b/lib/bpf/bpf.go @@ -35,6 +35,7 @@ import ( "github.com/gravitational/trace" "github.com/gravitational/ttlmap" + ossteleport "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/constants" apievents "github.com/gravitational/teleport/api/types/events" controlgroup "github.com/gravitational/teleport/lib/cgroup" @@ -392,6 +393,7 @@ func (s *Service) emitCommandEvent(eventBytes []byte) { Code: events.SessionCommandCode, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: ossteleport.Version, ServerID: ctx.ServerID, ServerHostname: ctx.ServerHostname, ServerNamespace: ctx.Namespace, @@ -450,6 +452,7 @@ func (s *Service) emitDiskEvent(eventBytes []byte) { Code: events.SessionDiskCode, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: ossteleport.Version, ServerID: ctx.ServerID, ServerHostname: ctx.ServerHostname, ServerNamespace: ctx.Namespace, @@ -504,6 +507,7 @@ func (s *Service) emit4NetworkEvent(eventBytes []byte) { Code: events.SessionNetworkCode, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: ossteleport.Version, ServerID: ctx.ServerID, ServerHostname: ctx.ServerHostname, ServerNamespace: ctx.Namespace, @@ -560,6 +564,7 @@ func (s *Service) emit6NetworkEvent(eventBytes []byte) { Code: events.SessionNetworkCode, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: ossteleport.Version, ServerID: ctx.ServerID, ServerHostname: ctx.ServerHostname, ServerNamespace: ctx.Namespace, diff --git a/lib/events/eventstest/generate.go b/lib/events/eventstest/generate.go index b6de4008a450f..25633ad2c3165 100644 --- a/lib/events/eventstest/generate.go +++ b/lib/events/eventstest/generate.go @@ -23,6 +23,7 @@ import ( "github.com/google/uuid" "github.com/jonboulle/clockwork" + "github.com/gravitational/teleport" apievents "github.com/gravitational/teleport/api/types/events" "github.com/gravitational/teleport/lib/events" ) @@ -71,7 +72,8 @@ func GenerateTestSession(params SessionParams) []apievents.AuditEvent { ClusterName: params.ClusterName, }, ServerMetadata: apievents.ServerMetadata{ - ServerID: params.ServerID, + ServerVersion: teleport.Version, + ServerID: params.ServerID, ServerLabels: map[string]string{ "kernel": "5.3.0-42-generic", "date": "Mon Mar 30 08:58:54 PDT 2020", @@ -103,6 +105,7 @@ func GenerateTestSession(params SessionParams) []apievents.AuditEvent { Time: params.Clock.Now().UTC().Add(time.Hour + time.Second + 7*time.Millisecond), }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: params.ServerID, ServerNamespace: "default", }, diff --git a/lib/srv/app/common/audit.go b/lib/srv/app/common/audit.go index 8ff08da6d62ef..fc7b53101bbc4 100644 --- a/lib/srv/app/common/audit.go +++ b/lib/srv/app/common/audit.go @@ -24,6 +24,7 @@ import ( "github.com/gravitational/trace" "github.com/sirupsen/logrus" + "github.com/gravitational/teleport" apidefaults "github.com/gravitational/teleport/api/defaults" "github.com/gravitational/teleport/api/types" apievents "github.com/gravitational/teleport/api/types/events" @@ -103,6 +104,7 @@ func (a *audit) OnSessionStart(ctx context.Context, serverID string, identity *t ClusterName: identity.RouteToApp.ClusterName, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: serverID, ServerNamespace: apidefaults.Namespace, }, @@ -129,6 +131,7 @@ func (a *audit) OnSessionEnd(ctx context.Context, serverID string, identity *tls ClusterName: identity.RouteToApp.ClusterName, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: serverID, ServerNamespace: apidefaults.Namespace, }, @@ -155,6 +158,7 @@ func (a *audit) OnSessionChunk(ctx context.Context, serverID, chunkID string, id ClusterName: identity.RouteToApp.ClusterName, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: serverID, ServerNamespace: apidefaults.Namespace, }, diff --git a/lib/srv/ctx.go b/lib/srv/ctx.go index 6383d98e1d73c..707b50172ca2f 100644 --- a/lib/srv/ctx.go +++ b/lib/srv/ctx.go @@ -1374,6 +1374,7 @@ func (c *ServerContext) GetExecRequest() (Exec, error) { func (c *ServerContext) GetServerMetadata() apievents.ServerMetadata { return apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: c.srv.HostUUID(), ServerHostname: c.srv.GetInfo().GetHostname(), ServerNamespace: c.srv.GetNamespace(), diff --git a/lib/srv/db/common/audit.go b/lib/srv/db/common/audit.go index 73eef8119e968..5a92f1480fcb8 100644 --- a/lib/srv/db/common/audit.go +++ b/lib/srv/db/common/audit.go @@ -22,6 +22,7 @@ import ( "github.com/gravitational/trace" "github.com/sirupsen/logrus" + "github.com/gravitational/teleport" apidefaults "github.com/gravitational/teleport/api/defaults" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/api/types/events" @@ -198,6 +199,7 @@ func MakeEventMetadata(session *Session, eventType, eventCode string) events.Met // MakeServerMetadata returns common server metadata for database session. func MakeServerMetadata(session *Session) events.ServerMetadata { return events.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: session.HostID, ServerNamespace: apidefaults.Namespace, } diff --git a/lib/srv/forward/sshserver.go b/lib/srv/forward/sshserver.go index 6e2d5164f1da6..379f826d5bb30 100644 --- a/lib/srv/forward/sshserver.go +++ b/lib/srv/forward/sshserver.go @@ -409,6 +409,7 @@ func (s *Server) TargetMetadata() apievents.ServerMetadata { } return apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerNamespace: s.GetNamespace(), ServerID: s.targetID, ServerAddr: s.targetAddr, diff --git a/lib/srv/monitor.go b/lib/srv/monitor.go index 4229795cb83fd..a61f822d9a456 100644 --- a/lib/srv/monitor.go +++ b/lib/srv/monitor.go @@ -29,6 +29,7 @@ import ( log "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" + "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/constants" "github.com/gravitational/teleport/api/types" apievents "github.com/gravitational/teleport/api/types/events" @@ -455,7 +456,8 @@ func (w *Monitor) emitDisconnectEvent(reason string) error { RemoteAddr: w.Conn.RemoteAddr().String(), }, ServerMetadata: apievents.ServerMetadata{ - ServerID: w.ServerID, + ServerVersion: teleport.Version, + ServerID: w.ServerID, }, Reason: reason, } diff --git a/lib/srv/regular/sshserver.go b/lib/srv/regular/sshserver.go index 4cf276ea04577..fe6e393889dd4 100644 --- a/lib/srv/regular/sshserver.go +++ b/lib/srv/regular/sshserver.go @@ -242,6 +242,7 @@ type Server struct { // TargetMetadata returns metadata about the server. func (s *Server) TargetMetadata() apievents.ServerMetadata { return apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerNamespace: s.GetNamespace(), ServerID: s.ID(), ServerAddr: s.Addr(), @@ -1371,6 +1372,7 @@ func (s *Server) HandleNewChan(ctx context.Context, ccx *sshutils.ConnectionCont RemoteAddr: ccx.ServerConn.RemoteAddr().String(), }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: s.uuid, ServerNamespace: s.GetNamespace(), }, diff --git a/lib/srv/sess_test.go b/lib/srv/sess_test.go index dc718da6e687b..a3017e0daf698 100644 --- a/lib/srv/sess_test.go +++ b/lib/srv/sess_test.go @@ -880,6 +880,7 @@ func TestTrackingSession(t *testing.T) { }, }, serverMeta: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerHostname: "test", ServerID: "123", }, diff --git a/lib/srv/session_control.go b/lib/srv/session_control.go index d6dd6093eac60..d5e60d8594d47 100644 --- a/lib/srv/session_control.go +++ b/lib/srv/session_control.go @@ -331,6 +331,7 @@ func (s *SessionController) emitRejection(ctx context.Context, userMetadata apie RemoteAddr: remoteAddr, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: s.cfg.ServerID, ServerNamespace: apidefaults.Namespace, }, diff --git a/lib/web/apps.go b/lib/web/apps.go index 2c6a1b7b1ee51..8faf3b587e1ff 100644 --- a/lib/web/apps.go +++ b/lib/web/apps.go @@ -26,6 +26,7 @@ import ( "github.com/gravitational/trace" "github.com/julienschmidt/httprouter" + "github.com/gravitational/teleport" apiclient "github.com/gravitational/teleport/api/client" "github.com/gravitational/teleport/api/client/proto" apidefaults "github.com/gravitational/teleport/api/defaults" @@ -274,6 +275,7 @@ func (h *Handler) createAppSession(w http.ResponseWriter, r *http.Request, p htt ClusterName: identity.RouteToApp.ClusterName, }, ServerMetadata: apievents.ServerMetadata{ + ServerVersion: teleport.Version, ServerID: h.cfg.HostUUID, ServerNamespace: apidefaults.Namespace, },