From 556d5dec05e4ec82deae5e477afcdff8fbd5e2e1 Mon Sep 17 00:00:00 2001 From: Gabriel Corado Date: Mon, 3 Feb 2025 14:06:49 -0300 Subject: [PATCH] [v17] Add database User Agent to session start usage event (#51705) * feat(usagereporter): add user agent to database session start usage event (#51591) * Reconcile prehog protos (#51563) --------- Co-authored-by: Noah Stride --- gen/proto/go/prehog/v1alpha/teleport.pb.go | 27 ++++++++++----- gen/proto/ts/prehog/v1alpha/teleport_pb.ts | 16 ++++++++- lib/usagereporter/teleport/audit.go | 1 + lib/usagereporter/teleport/audit_test.go | 39 ++++++++++++++++++++++ lib/usagereporter/teleport/types.go | 1 + proto/prehog/v1alpha/teleport.proto | 2 ++ 6 files changed, 77 insertions(+), 9 deletions(-) diff --git a/gen/proto/go/prehog/v1alpha/teleport.pb.go b/gen/proto/go/prehog/v1alpha/teleport.pb.go index b8a734f93a883..4eb575cc171ec 100644 --- a/gen/proto/go/prehog/v1alpha/teleport.pb.go +++ b/gen/proto/go/prehog/v1alpha/teleport.pb.go @@ -1665,6 +1665,8 @@ type SessionStartDatabaseMetadata struct { DbProtocol string `protobuf:"bytes,2,opt,name=db_protocol,json=dbProtocol,proto3" json:"db_protocol,omitempty"` // database origin source. DbOrigin string `protobuf:"bytes,3,opt,name=db_origin,json=dbOrigin,proto3" json:"db_origin,omitempty"` + // Indicates the client used on the session. + UserAgent string `protobuf:"bytes,4,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"` } func (x *SessionStartDatabaseMetadata) Reset() { @@ -1718,6 +1720,13 @@ func (x *SessionStartDatabaseMetadata) GetDbOrigin() string { return "" } +func (x *SessionStartDatabaseMetadata) GetUserAgent() string { + if x != nil { + return x.UserAgent + } + return "" +} + // SessionStartDesktop Metadata contains additional information about // a desktop session. type SessionStartDesktopMetadata struct { @@ -9529,14 +9538,16 @@ var file_prehog_v1alpha_teleport_proto_rawDesc = []byte{ 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x41, 0x70, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x03, - 0x61, 0x70, 0x70, 0x22, 0x75, 0x0a, 0x1c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, - 0x61, 0x72, 0x74, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, - 0x64, 0x62, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x64, 0x62, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x1b, 0x0a, - 0x09, 0x64, 0x62, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x64, 0x62, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x22, 0xc1, 0x01, 0x0a, 0x1b, 0x53, + 0x61, 0x70, 0x70, 0x22, 0x94, 0x01, 0x0a, 0x1c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, + 0x0b, 0x64, 0x62, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x64, 0x62, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x1b, + 0x0a, 0x09, 0x64, 0x62, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x64, 0x62, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x75, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x22, 0xc1, 0x01, 0x0a, 0x1b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x44, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, diff --git a/gen/proto/ts/prehog/v1alpha/teleport_pb.ts b/gen/proto/ts/prehog/v1alpha/teleport_pb.ts index 07701164559c8..e9a89c0d86438 100644 --- a/gen/proto/ts/prehog/v1alpha/teleport_pb.ts +++ b/gen/proto/ts/prehog/v1alpha/teleport_pb.ts @@ -303,6 +303,12 @@ export interface SessionStartDatabaseMetadata { * @generated from protobuf field: string db_origin = 3; */ dbOrigin: string; + /** + * Indicates the client used on the session. + * + * @generated from protobuf field: string user_agent = 4; + */ + userAgent: string; } /** * SessionStartDesktop Metadata contains additional information about @@ -4478,7 +4484,8 @@ class SessionStartDatabaseMetadata$Type extends MessageType): SessionStartDatabaseMetadata { @@ -4486,6 +4493,7 @@ class SessionStartDatabaseMetadata$Type extends MessageType(this, message, value); return message; @@ -4504,6 +4512,9 @@ class SessionStartDatabaseMetadata$Type extends MessageType