diff --git a/gen/proto/go/prehog/v1/prehogv1connect/teleport.connect.go b/gen/proto/go/prehog/v1/prehogv1connect/teleport.connect.go new file mode 100644 index 0000000000000..775547de1d47c --- /dev/null +++ b/gen/proto/go/prehog/v1/prehogv1connect/teleport.connect.go @@ -0,0 +1,87 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: prehog/v1/teleport.proto + +package prehogv1connect + +import ( + context "context" + errors "errors" + connect_go "github.com/bufbuild/connect-go" + v1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect_go.IsAtLeastVersion0_1_0 + +const ( + // TeleportReportingServiceName is the fully-qualified name of the TeleportReportingService service. + TeleportReportingServiceName = "prehog.v1.TeleportReportingService" +) + +// TeleportReportingServiceClient is a client for the prehog.v1.TeleportReportingService service. +type TeleportReportingServiceClient interface { + SubmitUsageReports(context.Context, *connect_go.Request[v1.SubmitUsageReportsRequest]) (*connect_go.Response[v1.SubmitUsageReportsResponse], error) +} + +// NewTeleportReportingServiceClient constructs a client for the prehog.v1.TeleportReportingService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewTeleportReportingServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) TeleportReportingServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &teleportReportingServiceClient{ + submitUsageReports: connect_go.NewClient[v1.SubmitUsageReportsRequest, v1.SubmitUsageReportsResponse]( + httpClient, + baseURL+"/prehog.v1.TeleportReportingService/SubmitUsageReports", + opts..., + ), + } +} + +// teleportReportingServiceClient implements TeleportReportingServiceClient. +type teleportReportingServiceClient struct { + submitUsageReports *connect_go.Client[v1.SubmitUsageReportsRequest, v1.SubmitUsageReportsResponse] +} + +// SubmitUsageReports calls prehog.v1.TeleportReportingService.SubmitUsageReports. +func (c *teleportReportingServiceClient) SubmitUsageReports(ctx context.Context, req *connect_go.Request[v1.SubmitUsageReportsRequest]) (*connect_go.Response[v1.SubmitUsageReportsResponse], error) { + return c.submitUsageReports.CallUnary(ctx, req) +} + +// TeleportReportingServiceHandler is an implementation of the prehog.v1.TeleportReportingService +// service. +type TeleportReportingServiceHandler interface { + SubmitUsageReports(context.Context, *connect_go.Request[v1.SubmitUsageReportsRequest]) (*connect_go.Response[v1.SubmitUsageReportsResponse], error) +} + +// NewTeleportReportingServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewTeleportReportingServiceHandler(svc TeleportReportingServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { + mux := http.NewServeMux() + mux.Handle("/prehog.v1.TeleportReportingService/SubmitUsageReports", connect_go.NewUnaryHandler( + "/prehog.v1.TeleportReportingService/SubmitUsageReports", + svc.SubmitUsageReports, + opts..., + )) + return "/prehog.v1.TeleportReportingService/", mux +} + +// UnimplementedTeleportReportingServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedTeleportReportingServiceHandler struct{} + +func (UnimplementedTeleportReportingServiceHandler) SubmitUsageReports(context.Context, *connect_go.Request[v1.SubmitUsageReportsRequest]) (*connect_go.Response[v1.SubmitUsageReportsResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("prehog.v1.TeleportReportingService.SubmitUsageReports is not implemented")) +} diff --git a/gen/proto/go/prehog/v1/teleport.pb.go b/gen/proto/go/prehog/v1/teleport.pb.go new file mode 100644 index 0000000000000..8d5dc217f75c8 --- /dev/null +++ b/gen/proto/go/prehog/v1/teleport.pb.go @@ -0,0 +1,536 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc (unknown) +// source: prehog/v1/teleport.proto + +package prehogv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UserActivityReport struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // randomly generated UUID for this specific report, 16 bytes (in string order) + ReportUuid []byte `protobuf:"bytes,1,opt,name=report_uuid,json=reportUuid,proto3" json:"report_uuid,omitempty"` + // anonymized, 32 bytes (HMAC-SHA-256) + ClusterName []byte `protobuf:"bytes,2,opt,name=cluster_name,json=clusterName,proto3" json:"cluster_name,omitempty"` + // anonymized, 32 bytes (HMAC-SHA-256) + ReporterHostid []byte `protobuf:"bytes,3,opt,name=reporter_hostid,json=reporterHostid,proto3" json:"reporter_hostid,omitempty"` + // beginning of the time window for this data; ending is not specified but is + // intended to be at most 15 minutes + StartTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + Records []*UserActivityRecord `protobuf:"bytes,5,rep,name=records,proto3" json:"records,omitempty"` +} + +func (x *UserActivityReport) Reset() { + *x = UserActivityReport{} + if protoimpl.UnsafeEnabled { + mi := &file_prehog_v1_teleport_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserActivityReport) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserActivityReport) ProtoMessage() {} + +func (x *UserActivityReport) ProtoReflect() protoreflect.Message { + mi := &file_prehog_v1_teleport_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserActivityReport.ProtoReflect.Descriptor instead. +func (*UserActivityReport) Descriptor() ([]byte, []int) { + return file_prehog_v1_teleport_proto_rawDescGZIP(), []int{0} +} + +func (x *UserActivityReport) GetReportUuid() []byte { + if x != nil { + return x.ReportUuid + } + return nil +} + +func (x *UserActivityReport) GetClusterName() []byte { + if x != nil { + return x.ClusterName + } + return nil +} + +func (x *UserActivityReport) GetReporterHostid() []byte { + if x != nil { + return x.ReporterHostid + } + return nil +} + +func (x *UserActivityReport) GetStartTime() *timestamppb.Timestamp { + if x != nil { + return x.StartTime + } + return nil +} + +func (x *UserActivityReport) GetRecords() []*UserActivityRecord { + if x != nil { + return x.Records + } + return nil +} + +type UserActivityRecord struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // anonymized, 32 bytes (HMAC-SHA-256) + UserName []byte `protobuf:"bytes,1,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"` + // counter of user.login events + Logins uint64 `protobuf:"varint,2,opt,name=logins,proto3" json:"logins,omitempty"` + // counter of session.start events (non-Kube) + SshSessions uint64 `protobuf:"varint,3,opt,name=ssh_sessions,json=sshSessions,proto3" json:"ssh_sessions,omitempty"` + // counter of app.session.start events (non-TCP) + AppSessions uint64 `protobuf:"varint,4,opt,name=app_sessions,json=appSessions,proto3" json:"app_sessions,omitempty"` + // counter of session.start events (only Kube) + KubeSessions uint64 `protobuf:"varint,5,opt,name=kube_sessions,json=kubeSessions,proto3" json:"kube_sessions,omitempty"` + // counter of db.session.start events + DbSessions uint64 `protobuf:"varint,6,opt,name=db_sessions,json=dbSessions,proto3" json:"db_sessions,omitempty"` + // counter of windows.desktop.session.start events + DesktopSessions uint64 `protobuf:"varint,7,opt,name=desktop_sessions,json=desktopSessions,proto3" json:"desktop_sessions,omitempty"` + // counter of app.session.start events (only TCP) + AppTcpSessions uint64 `protobuf:"varint,8,opt,name=app_tcp_sessions,json=appTcpSessions,proto3" json:"app_tcp_sessions,omitempty"` + // counter of port events + SshPortSessions uint64 `protobuf:"varint,9,opt,name=ssh_port_sessions,json=sshPortSessions,proto3" json:"ssh_port_sessions,omitempty"` + // counter of kube.request events + KubeRequests uint64 `protobuf:"varint,10,opt,name=kube_requests,json=kubeRequests,proto3" json:"kube_requests,omitempty"` + // counter of sftp events + SftpEvents uint64 `protobuf:"varint,11,opt,name=sftp_events,json=sftpEvents,proto3" json:"sftp_events,omitempty"` +} + +func (x *UserActivityRecord) Reset() { + *x = UserActivityRecord{} + if protoimpl.UnsafeEnabled { + mi := &file_prehog_v1_teleport_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserActivityRecord) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserActivityRecord) ProtoMessage() {} + +func (x *UserActivityRecord) ProtoReflect() protoreflect.Message { + mi := &file_prehog_v1_teleport_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserActivityRecord.ProtoReflect.Descriptor instead. +func (*UserActivityRecord) Descriptor() ([]byte, []int) { + return file_prehog_v1_teleport_proto_rawDescGZIP(), []int{1} +} + +func (x *UserActivityRecord) GetUserName() []byte { + if x != nil { + return x.UserName + } + return nil +} + +func (x *UserActivityRecord) GetLogins() uint64 { + if x != nil { + return x.Logins + } + return 0 +} + +func (x *UserActivityRecord) GetSshSessions() uint64 { + if x != nil { + return x.SshSessions + } + return 0 +} + +func (x *UserActivityRecord) GetAppSessions() uint64 { + if x != nil { + return x.AppSessions + } + return 0 +} + +func (x *UserActivityRecord) GetKubeSessions() uint64 { + if x != nil { + return x.KubeSessions + } + return 0 +} + +func (x *UserActivityRecord) GetDbSessions() uint64 { + if x != nil { + return x.DbSessions + } + return 0 +} + +func (x *UserActivityRecord) GetDesktopSessions() uint64 { + if x != nil { + return x.DesktopSessions + } + return 0 +} + +func (x *UserActivityRecord) GetAppTcpSessions() uint64 { + if x != nil { + return x.AppTcpSessions + } + return 0 +} + +func (x *UserActivityRecord) GetSshPortSessions() uint64 { + if x != nil { + return x.SshPortSessions + } + return 0 +} + +func (x *UserActivityRecord) GetKubeRequests() uint64 { + if x != nil { + return x.KubeRequests + } + return 0 +} + +func (x *UserActivityRecord) GetSftpEvents() uint64 { + if x != nil { + return x.SftpEvents + } + return 0 +} + +type SubmitUsageReportsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // at most 10 in a single RPC, each shouldn't exceed 128KiB or so + UserActivity []*UserActivityReport `protobuf:"bytes,1,rep,name=user_activity,json=userActivity,proto3" json:"user_activity,omitempty"` +} + +func (x *SubmitUsageReportsRequest) Reset() { + *x = SubmitUsageReportsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_prehog_v1_teleport_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SubmitUsageReportsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitUsageReportsRequest) ProtoMessage() {} + +func (x *SubmitUsageReportsRequest) ProtoReflect() protoreflect.Message { + mi := &file_prehog_v1_teleport_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitUsageReportsRequest.ProtoReflect.Descriptor instead. +func (*SubmitUsageReportsRequest) Descriptor() ([]byte, []int) { + return file_prehog_v1_teleport_proto_rawDescGZIP(), []int{2} +} + +func (x *SubmitUsageReportsRequest) GetUserActivity() []*UserActivityReport { + if x != nil { + return x.UserActivity + } + return nil +} + +type SubmitUsageReportsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // randomly generated UUID for this specific batch, 16 bytes (in string order) + BatchUuid []byte `protobuf:"bytes,1,opt,name=batch_uuid,json=batchUuid,proto3" json:"batch_uuid,omitempty"` +} + +func (x *SubmitUsageReportsResponse) Reset() { + *x = SubmitUsageReportsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_prehog_v1_teleport_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SubmitUsageReportsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitUsageReportsResponse) ProtoMessage() {} + +func (x *SubmitUsageReportsResponse) ProtoReflect() protoreflect.Message { + mi := &file_prehog_v1_teleport_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitUsageReportsResponse.ProtoReflect.Descriptor instead. +func (*SubmitUsageReportsResponse) Descriptor() ([]byte, []int) { + return file_prehog_v1_teleport_proto_rawDescGZIP(), []int{3} +} + +func (x *SubmitUsageReportsResponse) GetBatchUuid() []byte { + if x != nil { + return x.BatchUuid + } + return nil +} + +var File_prehog_v1_teleport_proto protoreflect.FileDescriptor + +var file_prehog_v1_teleport_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x6c, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x65, 0x68, + 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf5, 0x01, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1f, 0x0a, + 0x0b, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x55, 0x75, 0x69, 0x64, 0x12, 0x21, + 0x0a, 0x0c, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x68, 0x6f, + 0x73, 0x74, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x72, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x48, 0x6f, 0x73, 0x74, 0x69, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, + 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0x9c, + 0x03, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x06, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x73, + 0x68, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0b, 0x73, 0x73, 0x68, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, + 0x0c, 0x61, 0x70, 0x70, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0b, 0x61, 0x70, 0x70, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x12, 0x23, 0x0a, 0x0d, 0x6b, 0x75, 0x62, 0x65, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6b, 0x75, 0x62, 0x65, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x62, 0x5f, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x64, 0x62, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, + 0x70, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0f, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x12, 0x28, 0x0a, 0x10, 0x61, 0x70, 0x70, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x61, 0x70, 0x70, + 0x54, 0x63, 0x70, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x73, + 0x73, 0x68, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x73, 0x73, 0x68, 0x50, 0x6f, 0x72, 0x74, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x6b, 0x75, 0x62, 0x65, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, + 0x6b, 0x75, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x1f, 0x0a, 0x0b, + 0x73, 0x66, 0x74, 0x70, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0a, 0x73, 0x66, 0x74, 0x70, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x5f, 0x0a, + 0x19, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0d, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x52, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x22, 0x3b, + 0x0a, 0x1a, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, + 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x09, 0x62, 0x61, 0x74, 0x63, 0x68, 0x55, 0x75, 0x69, 0x64, 0x32, 0x7f, 0x0a, 0x18, 0x54, + 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x63, 0x0a, 0x12, 0x53, 0x75, 0x62, 0x6d, 0x69, + 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x24, 0x2e, + 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, + 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, + 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x43, 0x5a, 0x41, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x70, + 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x76, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_prehog_v1_teleport_proto_rawDescOnce sync.Once + file_prehog_v1_teleport_proto_rawDescData = file_prehog_v1_teleport_proto_rawDesc +) + +func file_prehog_v1_teleport_proto_rawDescGZIP() []byte { + file_prehog_v1_teleport_proto_rawDescOnce.Do(func() { + file_prehog_v1_teleport_proto_rawDescData = protoimpl.X.CompressGZIP(file_prehog_v1_teleport_proto_rawDescData) + }) + return file_prehog_v1_teleport_proto_rawDescData +} + +var file_prehog_v1_teleport_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_prehog_v1_teleport_proto_goTypes = []interface{}{ + (*UserActivityReport)(nil), // 0: prehog.v1.UserActivityReport + (*UserActivityRecord)(nil), // 1: prehog.v1.UserActivityRecord + (*SubmitUsageReportsRequest)(nil), // 2: prehog.v1.SubmitUsageReportsRequest + (*SubmitUsageReportsResponse)(nil), // 3: prehog.v1.SubmitUsageReportsResponse + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp +} +var file_prehog_v1_teleport_proto_depIdxs = []int32{ + 4, // 0: prehog.v1.UserActivityReport.start_time:type_name -> google.protobuf.Timestamp + 1, // 1: prehog.v1.UserActivityReport.records:type_name -> prehog.v1.UserActivityRecord + 0, // 2: prehog.v1.SubmitUsageReportsRequest.user_activity:type_name -> prehog.v1.UserActivityReport + 2, // 3: prehog.v1.TeleportReportingService.SubmitUsageReports:input_type -> prehog.v1.SubmitUsageReportsRequest + 3, // 4: prehog.v1.TeleportReportingService.SubmitUsageReports:output_type -> prehog.v1.SubmitUsageReportsResponse + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_prehog_v1_teleport_proto_init() } +func file_prehog_v1_teleport_proto_init() { + if File_prehog_v1_teleport_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_prehog_v1_teleport_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserActivityReport); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prehog_v1_teleport_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserActivityRecord); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prehog_v1_teleport_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SubmitUsageReportsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prehog_v1_teleport_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SubmitUsageReportsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_prehog_v1_teleport_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_prehog_v1_teleport_proto_goTypes, + DependencyIndexes: file_prehog_v1_teleport_proto_depIdxs, + MessageInfos: file_prehog_v1_teleport_proto_msgTypes, + }.Build() + File_prehog_v1_teleport_proto = out.File + file_prehog_v1_teleport_proto_rawDesc = nil + file_prehog_v1_teleport_proto_goTypes = nil + file_prehog_v1_teleport_proto_depIdxs = nil +} diff --git a/gen/proto/go/prehog/v1alpha/connect.pb.go b/gen/proto/go/prehog/v1alpha/connect.pb.go index 37f4c943f5384..d00f0cc12d7a3 100644 --- a/gen/proto/go/prehog/v1alpha/connect.pb.go +++ b/gen/proto/go/prehog/v1alpha/connect.pb.go @@ -18,7 +18,7 @@ // protoc (unknown) // source: prehog/v1alpha/connect.proto -package v1alpha +package prehogv1alpha import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -831,12 +831,12 @@ var file_prehog_v1alpha_connect_proto_rawDesc = []byte{ 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x65, 0x68, - 0x6f, 0x67, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6f, 0x67, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x3b, 0x70, 0x72, 0x65, 0x68, 0x6f, + 0x67, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/proto/go/prehog/v1alpha/v1alphaconnect/connect.connect.go b/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/connect.connect.go similarity index 99% rename from gen/proto/go/prehog/v1alpha/v1alphaconnect/connect.connect.go rename to gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/connect.connect.go index 86e50b2b42fcb..3862625d2985b 100644 --- a/gen/proto/go/prehog/v1alpha/v1alphaconnect/connect.connect.go +++ b/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/connect.connect.go @@ -2,7 +2,7 @@ // // Source: prehog/v1alpha/connect.proto -package v1alphaconnect +package prehogv1alphaconnect import ( context "context" diff --git a/gen/proto/go/prehog/v1alpha/v1alphaconnect/tbot.connect.go b/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/tbot.connect.go similarity index 99% rename from gen/proto/go/prehog/v1alpha/v1alphaconnect/tbot.connect.go rename to gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/tbot.connect.go index 602372d02e8f9..58e9f5e860f78 100644 --- a/gen/proto/go/prehog/v1alpha/v1alphaconnect/tbot.connect.go +++ b/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/tbot.connect.go @@ -2,7 +2,7 @@ // // Source: prehog/v1alpha/tbot.proto -package v1alphaconnect +package prehogv1alphaconnect import ( context "context" diff --git a/gen/proto/go/prehog/v1alpha/v1alphaconnect/teleport.connect.go b/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/teleport.connect.go similarity index 99% rename from gen/proto/go/prehog/v1alpha/v1alphaconnect/teleport.connect.go rename to gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/teleport.connect.go index 7c154b1438eac..8ced4f3e66918 100644 --- a/gen/proto/go/prehog/v1alpha/v1alphaconnect/teleport.connect.go +++ b/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect/teleport.connect.go @@ -2,7 +2,7 @@ // // Source: prehog/v1alpha/teleport.proto -package v1alphaconnect +package prehogv1alphaconnect import ( context "context" diff --git a/gen/proto/go/prehog/v1alpha/tbot.pb.go b/gen/proto/go/prehog/v1alpha/tbot.pb.go index 2bfd67aafc601..4157b7cf5261a 100644 --- a/gen/proto/go/prehog/v1alpha/tbot.pb.go +++ b/gen/proto/go/prehog/v1alpha/tbot.pb.go @@ -18,7 +18,7 @@ // protoc (unknown) // source: prehog/v1alpha/tbot.proto -package v1alpha +package prehogv1alpha import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -384,11 +384,12 @@ var file_prehog_v1alpha_tbot_proto_rawDesc = []byte{ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x54, 0x62, 0x6f, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x00, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x61, 0x3b, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/proto/go/prehog/v1alpha/teleport.pb.go b/gen/proto/go/prehog/v1alpha/teleport.pb.go index 6f77c16fc470f..50ffd9d6042b4 100644 --- a/gen/proto/go/prehog/v1alpha/teleport.pb.go +++ b/gen/proto/go/prehog/v1alpha/teleport.pb.go @@ -18,7 +18,7 @@ // protoc (unknown) // source: prehog/v1alpha/teleport.proto -package v1alpha +package prehogv1alpha import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -4153,11 +4153,12 @@ var file_prehog_v1alpha_teleport_proto_rawDesc = []byte{ 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x54, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x3b, 0x70, 0x72, 0x65, 0x68, 0x6f, 0x67, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/proto/js/prehog/v1/teleport_grpc_pb.d.ts b/gen/proto/js/prehog/v1/teleport_grpc_pb.d.ts new file mode 100644 index 0000000000000..1cc55c98a2328 --- /dev/null +++ b/gen/proto/js/prehog/v1/teleport_grpc_pb.d.ts @@ -0,0 +1,42 @@ +// package: prehog.v1 +// file: prehog/v1/teleport.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "grpc"; +import * as prehog_v1_teleport_pb from "../../prehog/v1/teleport_pb"; +import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; + +interface ITeleportReportingServiceService extends grpc.ServiceDefinition { + submitUsageReports: ITeleportReportingServiceService_ISubmitUsageReports; +} + +interface ITeleportReportingServiceService_ISubmitUsageReports extends grpc.MethodDefinition { + path: "/prehog.v1.TeleportReportingService/SubmitUsageReports"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const TeleportReportingServiceService: ITeleportReportingServiceService; + +export interface ITeleportReportingServiceServer { + submitUsageReports: grpc.handleUnaryCall; +} + +export interface ITeleportReportingServiceClient { + submitUsageReports(request: prehog_v1_teleport_pb.SubmitUsageReportsRequest, callback: (error: grpc.ServiceError | null, response: prehog_v1_teleport_pb.SubmitUsageReportsResponse) => void): grpc.ClientUnaryCall; + submitUsageReports(request: prehog_v1_teleport_pb.SubmitUsageReportsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: prehog_v1_teleport_pb.SubmitUsageReportsResponse) => void): grpc.ClientUnaryCall; + submitUsageReports(request: prehog_v1_teleport_pb.SubmitUsageReportsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: prehog_v1_teleport_pb.SubmitUsageReportsResponse) => void): grpc.ClientUnaryCall; +} + +export class TeleportReportingServiceClient extends grpc.Client implements ITeleportReportingServiceClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); + public submitUsageReports(request: prehog_v1_teleport_pb.SubmitUsageReportsRequest, callback: (error: grpc.ServiceError | null, response: prehog_v1_teleport_pb.SubmitUsageReportsResponse) => void): grpc.ClientUnaryCall; + public submitUsageReports(request: prehog_v1_teleport_pb.SubmitUsageReportsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: prehog_v1_teleport_pb.SubmitUsageReportsResponse) => void): grpc.ClientUnaryCall; + public submitUsageReports(request: prehog_v1_teleport_pb.SubmitUsageReportsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: prehog_v1_teleport_pb.SubmitUsageReportsResponse) => void): grpc.ClientUnaryCall; +} diff --git a/gen/proto/js/prehog/v1/teleport_grpc_pb.js b/gen/proto/js/prehog/v1/teleport_grpc_pb.js new file mode 100644 index 0000000000000..db0f294b7001c --- /dev/null +++ b/gen/proto/js/prehog/v1/teleport_grpc_pb.js @@ -0,0 +1,60 @@ +// GENERATED CODE -- DO NOT EDIT! + +// Original file comments: +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +'use strict'; +var grpc = require('@grpc/grpc-js'); +var prehog_v1_teleport_pb = require('../../prehog/v1/teleport_pb.js'); +var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); + +function serialize_prehog_v1_SubmitUsageReportsRequest(arg) { + if (!(arg instanceof prehog_v1_teleport_pb.SubmitUsageReportsRequest)) { + throw new Error('Expected argument of type prehog.v1.SubmitUsageReportsRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_prehog_v1_SubmitUsageReportsRequest(buffer_arg) { + return prehog_v1_teleport_pb.SubmitUsageReportsRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_prehog_v1_SubmitUsageReportsResponse(arg) { + if (!(arg instanceof prehog_v1_teleport_pb.SubmitUsageReportsResponse)) { + throw new Error('Expected argument of type prehog.v1.SubmitUsageReportsResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_prehog_v1_SubmitUsageReportsResponse(buffer_arg) { + return prehog_v1_teleport_pb.SubmitUsageReportsResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var TeleportReportingServiceService = exports.TeleportReportingServiceService = { + submitUsageReports: { + path: '/prehog.v1.TeleportReportingService/SubmitUsageReports', + requestStream: false, + responseStream: false, + requestType: prehog_v1_teleport_pb.SubmitUsageReportsRequest, + responseType: prehog_v1_teleport_pb.SubmitUsageReportsResponse, + requestSerialize: serialize_prehog_v1_SubmitUsageReportsRequest, + requestDeserialize: deserialize_prehog_v1_SubmitUsageReportsRequest, + responseSerialize: serialize_prehog_v1_SubmitUsageReportsResponse, + responseDeserialize: deserialize_prehog_v1_SubmitUsageReportsResponse, + }, +}; + +exports.TeleportReportingServiceClient = grpc.makeGenericClientConstructor(TeleportReportingServiceService); diff --git a/gen/proto/js/prehog/v1/teleport_pb.d.ts b/gen/proto/js/prehog/v1/teleport_pb.d.ts new file mode 100644 index 0000000000000..d003066d5b8c1 --- /dev/null +++ b/gen/proto/js/prehog/v1/teleport_pb.d.ts @@ -0,0 +1,165 @@ +// package: prehog.v1 +// file: prehog/v1/teleport.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; + +export class UserActivityReport extends jspb.Message { + getReportUuid(): Uint8Array | string; + getReportUuid_asU8(): Uint8Array; + getReportUuid_asB64(): string; + setReportUuid(value: Uint8Array | string): UserActivityReport; + + getClusterName(): Uint8Array | string; + getClusterName_asU8(): Uint8Array; + getClusterName_asB64(): string; + setClusterName(value: Uint8Array | string): UserActivityReport; + + getReporterHostid(): Uint8Array | string; + getReporterHostid_asU8(): Uint8Array; + getReporterHostid_asB64(): string; + setReporterHostid(value: Uint8Array | string): UserActivityReport; + + + hasStartTime(): boolean; + clearStartTime(): void; + getStartTime(): google_protobuf_timestamp_pb.Timestamp | undefined; + setStartTime(value?: google_protobuf_timestamp_pb.Timestamp): UserActivityReport; + + clearRecordsList(): void; + getRecordsList(): Array; + setRecordsList(value: Array): UserActivityReport; + addRecords(value?: UserActivityRecord, index?: number): UserActivityRecord; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserActivityReport.AsObject; + static toObject(includeInstance: boolean, msg: UserActivityReport): UserActivityReport.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserActivityReport, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserActivityReport; + static deserializeBinaryFromReader(message: UserActivityReport, reader: jspb.BinaryReader): UserActivityReport; +} + +export namespace UserActivityReport { + export type AsObject = { + reportUuid: Uint8Array | string, + clusterName: Uint8Array | string, + reporterHostid: Uint8Array | string, + startTime?: google_protobuf_timestamp_pb.Timestamp.AsObject, + recordsList: Array, + } +} + +export class UserActivityRecord extends jspb.Message { + getUserName(): Uint8Array | string; + getUserName_asU8(): Uint8Array; + getUserName_asB64(): string; + setUserName(value: Uint8Array | string): UserActivityRecord; + + getLogins(): number; + setLogins(value: number): UserActivityRecord; + + getSshSessions(): number; + setSshSessions(value: number): UserActivityRecord; + + getAppSessions(): number; + setAppSessions(value: number): UserActivityRecord; + + getKubeSessions(): number; + setKubeSessions(value: number): UserActivityRecord; + + getDbSessions(): number; + setDbSessions(value: number): UserActivityRecord; + + getDesktopSessions(): number; + setDesktopSessions(value: number): UserActivityRecord; + + getAppTcpSessions(): number; + setAppTcpSessions(value: number): UserActivityRecord; + + getSshPortSessions(): number; + setSshPortSessions(value: number): UserActivityRecord; + + getKubeRequests(): number; + setKubeRequests(value: number): UserActivityRecord; + + getSftpEvents(): number; + setSftpEvents(value: number): UserActivityRecord; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserActivityRecord.AsObject; + static toObject(includeInstance: boolean, msg: UserActivityRecord): UserActivityRecord.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UserActivityRecord, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserActivityRecord; + static deserializeBinaryFromReader(message: UserActivityRecord, reader: jspb.BinaryReader): UserActivityRecord; +} + +export namespace UserActivityRecord { + export type AsObject = { + userName: Uint8Array | string, + logins: number, + sshSessions: number, + appSessions: number, + kubeSessions: number, + dbSessions: number, + desktopSessions: number, + appTcpSessions: number, + sshPortSessions: number, + kubeRequests: number, + sftpEvents: number, + } +} + +export class SubmitUsageReportsRequest extends jspb.Message { + clearUserActivityList(): void; + getUserActivityList(): Array; + setUserActivityList(value: Array): SubmitUsageReportsRequest; + addUserActivity(value?: UserActivityReport, index?: number): UserActivityReport; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SubmitUsageReportsRequest.AsObject; + static toObject(includeInstance: boolean, msg: SubmitUsageReportsRequest): SubmitUsageReportsRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SubmitUsageReportsRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SubmitUsageReportsRequest; + static deserializeBinaryFromReader(message: SubmitUsageReportsRequest, reader: jspb.BinaryReader): SubmitUsageReportsRequest; +} + +export namespace SubmitUsageReportsRequest { + export type AsObject = { + userActivityList: Array, + } +} + +export class SubmitUsageReportsResponse extends jspb.Message { + getBatchUuid(): Uint8Array | string; + getBatchUuid_asU8(): Uint8Array; + getBatchUuid_asB64(): string; + setBatchUuid(value: Uint8Array | string): SubmitUsageReportsResponse; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SubmitUsageReportsResponse.AsObject; + static toObject(includeInstance: boolean, msg: SubmitUsageReportsResponse): SubmitUsageReportsResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SubmitUsageReportsResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SubmitUsageReportsResponse; + static deserializeBinaryFromReader(message: SubmitUsageReportsResponse, reader: jspb.BinaryReader): SubmitUsageReportsResponse; +} + +export namespace SubmitUsageReportsResponse { + export type AsObject = { + batchUuid: Uint8Array | string, + } +} diff --git a/gen/proto/js/prehog/v1/teleport_pb.js b/gen/proto/js/prehog/v1/teleport_pb.js new file mode 100644 index 0000000000000..b2d63f9e17d56 --- /dev/null +++ b/gen/proto/js/prehog/v1/teleport_pb.js @@ -0,0 +1,1249 @@ +// source: prehog/v1/teleport.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); + +var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); +goog.object.extend(proto, google_protobuf_timestamp_pb); +goog.exportSymbol('proto.prehog.v1.SubmitUsageReportsRequest', null, global); +goog.exportSymbol('proto.prehog.v1.SubmitUsageReportsResponse', null, global); +goog.exportSymbol('proto.prehog.v1.UserActivityRecord', null, global); +goog.exportSymbol('proto.prehog.v1.UserActivityReport', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.prehog.v1.UserActivityReport = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.prehog.v1.UserActivityReport.repeatedFields_, null); +}; +goog.inherits(proto.prehog.v1.UserActivityReport, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.prehog.v1.UserActivityReport.displayName = 'proto.prehog.v1.UserActivityReport'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.prehog.v1.UserActivityRecord = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.prehog.v1.UserActivityRecord, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.prehog.v1.UserActivityRecord.displayName = 'proto.prehog.v1.UserActivityRecord'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.prehog.v1.SubmitUsageReportsRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.prehog.v1.SubmitUsageReportsRequest.repeatedFields_, null); +}; +goog.inherits(proto.prehog.v1.SubmitUsageReportsRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.prehog.v1.SubmitUsageReportsRequest.displayName = 'proto.prehog.v1.SubmitUsageReportsRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.prehog.v1.SubmitUsageReportsResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.prehog.v1.SubmitUsageReportsResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.prehog.v1.SubmitUsageReportsResponse.displayName = 'proto.prehog.v1.SubmitUsageReportsResponse'; +} + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.prehog.v1.UserActivityReport.repeatedFields_ = [5]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.prehog.v1.UserActivityReport.prototype.toObject = function(opt_includeInstance) { + return proto.prehog.v1.UserActivityReport.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.prehog.v1.UserActivityReport} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.UserActivityReport.toObject = function(includeInstance, msg) { + var f, obj = { + reportUuid: msg.getReportUuid_asB64(), + clusterName: msg.getClusterName_asB64(), + reporterHostid: msg.getReporterHostid_asB64(), + startTime: (f = msg.getStartTime()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), + recordsList: jspb.Message.toObjectList(msg.getRecordsList(), + proto.prehog.v1.UserActivityRecord.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.prehog.v1.UserActivityReport} + */ +proto.prehog.v1.UserActivityReport.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.prehog.v1.UserActivityReport; + return proto.prehog.v1.UserActivityReport.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.prehog.v1.UserActivityReport} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.prehog.v1.UserActivityReport} + */ +proto.prehog.v1.UserActivityReport.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setReportUuid(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setClusterName(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setReporterHostid(value); + break; + case 4: + var value = new google_protobuf_timestamp_pb.Timestamp; + reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); + msg.setStartTime(value); + break; + case 5: + var value = new proto.prehog.v1.UserActivityRecord; + reader.readMessage(value,proto.prehog.v1.UserActivityRecord.deserializeBinaryFromReader); + msg.addRecords(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.prehog.v1.UserActivityReport.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.prehog.v1.UserActivityReport.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.prehog.v1.UserActivityReport} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.UserActivityReport.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getReportUuid_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getClusterName_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } + f = message.getReporterHostid_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getStartTime(); + if (f != null) { + writer.writeMessage( + 4, + f, + google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter + ); + } + f = message.getRecordsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 5, + f, + proto.prehog.v1.UserActivityRecord.serializeBinaryToWriter + ); + } +}; + + +/** + * optional bytes report_uuid = 1; + * @return {!(string|Uint8Array)} + */ +proto.prehog.v1.UserActivityReport.prototype.getReportUuid = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes report_uuid = 1; + * This is a type-conversion wrapper around `getReportUuid()` + * @return {string} + */ +proto.prehog.v1.UserActivityReport.prototype.getReportUuid_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getReportUuid())); +}; + + +/** + * optional bytes report_uuid = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getReportUuid()` + * @return {!Uint8Array} + */ +proto.prehog.v1.UserActivityReport.prototype.getReportUuid_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getReportUuid())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.prehog.v1.UserActivityReport} returns this + */ +proto.prehog.v1.UserActivityReport.prototype.setReportUuid = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bytes cluster_name = 2; + * @return {!(string|Uint8Array)} + */ +proto.prehog.v1.UserActivityReport.prototype.getClusterName = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes cluster_name = 2; + * This is a type-conversion wrapper around `getClusterName()` + * @return {string} + */ +proto.prehog.v1.UserActivityReport.prototype.getClusterName_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getClusterName())); +}; + + +/** + * optional bytes cluster_name = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getClusterName()` + * @return {!Uint8Array} + */ +proto.prehog.v1.UserActivityReport.prototype.getClusterName_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getClusterName())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.prehog.v1.UserActivityReport} returns this + */ +proto.prehog.v1.UserActivityReport.prototype.setClusterName = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + +/** + * optional bytes reporter_hostid = 3; + * @return {!(string|Uint8Array)} + */ +proto.prehog.v1.UserActivityReport.prototype.getReporterHostid = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes reporter_hostid = 3; + * This is a type-conversion wrapper around `getReporterHostid()` + * @return {string} + */ +proto.prehog.v1.UserActivityReport.prototype.getReporterHostid_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getReporterHostid())); +}; + + +/** + * optional bytes reporter_hostid = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getReporterHostid()` + * @return {!Uint8Array} + */ +proto.prehog.v1.UserActivityReport.prototype.getReporterHostid_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getReporterHostid())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.prehog.v1.UserActivityReport} returns this + */ +proto.prehog.v1.UserActivityReport.prototype.setReporterHostid = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + +/** + * optional google.protobuf.Timestamp start_time = 4; + * @return {?proto.google.protobuf.Timestamp} + */ +proto.prehog.v1.UserActivityReport.prototype.getStartTime = function() { + return /** @type{?proto.google.protobuf.Timestamp} */ ( + jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 4)); +}; + + +/** + * @param {?proto.google.protobuf.Timestamp|undefined} value + * @return {!proto.prehog.v1.UserActivityReport} returns this +*/ +proto.prehog.v1.UserActivityReport.prototype.setStartTime = function(value) { + return jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.prehog.v1.UserActivityReport} returns this + */ +proto.prehog.v1.UserActivityReport.prototype.clearStartTime = function() { + return this.setStartTime(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.prehog.v1.UserActivityReport.prototype.hasStartTime = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * repeated UserActivityRecord records = 5; + * @return {!Array} + */ +proto.prehog.v1.UserActivityReport.prototype.getRecordsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.prehog.v1.UserActivityRecord, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.prehog.v1.UserActivityReport} returns this +*/ +proto.prehog.v1.UserActivityReport.prototype.setRecordsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 5, value); +}; + + +/** + * @param {!proto.prehog.v1.UserActivityRecord=} opt_value + * @param {number=} opt_index + * @return {!proto.prehog.v1.UserActivityRecord} + */ +proto.prehog.v1.UserActivityReport.prototype.addRecords = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, proto.prehog.v1.UserActivityRecord, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.prehog.v1.UserActivityReport} returns this + */ +proto.prehog.v1.UserActivityReport.prototype.clearRecordsList = function() { + return this.setRecordsList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.prehog.v1.UserActivityRecord.prototype.toObject = function(opt_includeInstance) { + return proto.prehog.v1.UserActivityRecord.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.prehog.v1.UserActivityRecord} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.UserActivityRecord.toObject = function(includeInstance, msg) { + var f, obj = { + userName: msg.getUserName_asB64(), + logins: jspb.Message.getFieldWithDefault(msg, 2, 0), + sshSessions: jspb.Message.getFieldWithDefault(msg, 3, 0), + appSessions: jspb.Message.getFieldWithDefault(msg, 4, 0), + kubeSessions: jspb.Message.getFieldWithDefault(msg, 5, 0), + dbSessions: jspb.Message.getFieldWithDefault(msg, 6, 0), + desktopSessions: jspb.Message.getFieldWithDefault(msg, 7, 0), + appTcpSessions: jspb.Message.getFieldWithDefault(msg, 8, 0), + sshPortSessions: jspb.Message.getFieldWithDefault(msg, 9, 0), + kubeRequests: jspb.Message.getFieldWithDefault(msg, 10, 0), + sftpEvents: jspb.Message.getFieldWithDefault(msg, 11, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.prehog.v1.UserActivityRecord} + */ +proto.prehog.v1.UserActivityRecord.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.prehog.v1.UserActivityRecord; + return proto.prehog.v1.UserActivityRecord.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.prehog.v1.UserActivityRecord} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.prehog.v1.UserActivityRecord} + */ +proto.prehog.v1.UserActivityRecord.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setUserName(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint64()); + msg.setLogins(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint64()); + msg.setSshSessions(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint64()); + msg.setAppSessions(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint64()); + msg.setKubeSessions(value); + break; + case 6: + var value = /** @type {number} */ (reader.readUint64()); + msg.setDbSessions(value); + break; + case 7: + var value = /** @type {number} */ (reader.readUint64()); + msg.setDesktopSessions(value); + break; + case 8: + var value = /** @type {number} */ (reader.readUint64()); + msg.setAppTcpSessions(value); + break; + case 9: + var value = /** @type {number} */ (reader.readUint64()); + msg.setSshPortSessions(value); + break; + case 10: + var value = /** @type {number} */ (reader.readUint64()); + msg.setKubeRequests(value); + break; + case 11: + var value = /** @type {number} */ (reader.readUint64()); + msg.setSftpEvents(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.prehog.v1.UserActivityRecord.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.prehog.v1.UserActivityRecord.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.prehog.v1.UserActivityRecord} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.UserActivityRecord.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserName_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getLogins(); + if (f !== 0) { + writer.writeUint64( + 2, + f + ); + } + f = message.getSshSessions(); + if (f !== 0) { + writer.writeUint64( + 3, + f + ); + } + f = message.getAppSessions(); + if (f !== 0) { + writer.writeUint64( + 4, + f + ); + } + f = message.getKubeSessions(); + if (f !== 0) { + writer.writeUint64( + 5, + f + ); + } + f = message.getDbSessions(); + if (f !== 0) { + writer.writeUint64( + 6, + f + ); + } + f = message.getDesktopSessions(); + if (f !== 0) { + writer.writeUint64( + 7, + f + ); + } + f = message.getAppTcpSessions(); + if (f !== 0) { + writer.writeUint64( + 8, + f + ); + } + f = message.getSshPortSessions(); + if (f !== 0) { + writer.writeUint64( + 9, + f + ); + } + f = message.getKubeRequests(); + if (f !== 0) { + writer.writeUint64( + 10, + f + ); + } + f = message.getSftpEvents(); + if (f !== 0) { + writer.writeUint64( + 11, + f + ); + } +}; + + +/** + * optional bytes user_name = 1; + * @return {!(string|Uint8Array)} + */ +proto.prehog.v1.UserActivityRecord.prototype.getUserName = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes user_name = 1; + * This is a type-conversion wrapper around `getUserName()` + * @return {string} + */ +proto.prehog.v1.UserActivityRecord.prototype.getUserName_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getUserName())); +}; + + +/** + * optional bytes user_name = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getUserName()` + * @return {!Uint8Array} + */ +proto.prehog.v1.UserActivityRecord.prototype.getUserName_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getUserName())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setUserName = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional uint64 logins = 2; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getLogins = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setLogins = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional uint64 ssh_sessions = 3; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getSshSessions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setSshSessions = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + +/** + * optional uint64 app_sessions = 4; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getAppSessions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setAppSessions = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); +}; + + +/** + * optional uint64 kube_sessions = 5; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getKubeSessions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setKubeSessions = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); +}; + + +/** + * optional uint64 db_sessions = 6; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getDbSessions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setDbSessions = function(value) { + return jspb.Message.setProto3IntField(this, 6, value); +}; + + +/** + * optional uint64 desktop_sessions = 7; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getDesktopSessions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 7, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setDesktopSessions = function(value) { + return jspb.Message.setProto3IntField(this, 7, value); +}; + + +/** + * optional uint64 app_tcp_sessions = 8; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getAppTcpSessions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 8, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setAppTcpSessions = function(value) { + return jspb.Message.setProto3IntField(this, 8, value); +}; + + +/** + * optional uint64 ssh_port_sessions = 9; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getSshPortSessions = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 9, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setSshPortSessions = function(value) { + return jspb.Message.setProto3IntField(this, 9, value); +}; + + +/** + * optional uint64 kube_requests = 10; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getKubeRequests = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 10, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setKubeRequests = function(value) { + return jspb.Message.setProto3IntField(this, 10, value); +}; + + +/** + * optional uint64 sftp_events = 11; + * @return {number} + */ +proto.prehog.v1.UserActivityRecord.prototype.getSftpEvents = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 11, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.prehog.v1.UserActivityRecord} returns this + */ +proto.prehog.v1.UserActivityRecord.prototype.setSftpEvents = function(value) { + return jspb.Message.setProto3IntField(this, 11, value); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.prehog.v1.SubmitUsageReportsRequest.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.prehog.v1.SubmitUsageReportsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.prehog.v1.SubmitUsageReportsRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.prehog.v1.SubmitUsageReportsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.SubmitUsageReportsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userActivityList: jspb.Message.toObjectList(msg.getUserActivityList(), + proto.prehog.v1.UserActivityReport.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.prehog.v1.SubmitUsageReportsRequest} + */ +proto.prehog.v1.SubmitUsageReportsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.prehog.v1.SubmitUsageReportsRequest; + return proto.prehog.v1.SubmitUsageReportsRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.prehog.v1.SubmitUsageReportsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.prehog.v1.SubmitUsageReportsRequest} + */ +proto.prehog.v1.SubmitUsageReportsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.prehog.v1.UserActivityReport; + reader.readMessage(value,proto.prehog.v1.UserActivityReport.deserializeBinaryFromReader); + msg.addUserActivity(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.prehog.v1.SubmitUsageReportsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.prehog.v1.SubmitUsageReportsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.prehog.v1.SubmitUsageReportsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.SubmitUsageReportsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserActivityList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.prehog.v1.UserActivityReport.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated UserActivityReport user_activity = 1; + * @return {!Array} + */ +proto.prehog.v1.SubmitUsageReportsRequest.prototype.getUserActivityList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.prehog.v1.UserActivityReport, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.prehog.v1.SubmitUsageReportsRequest} returns this +*/ +proto.prehog.v1.SubmitUsageReportsRequest.prototype.setUserActivityList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.prehog.v1.UserActivityReport=} opt_value + * @param {number=} opt_index + * @return {!proto.prehog.v1.UserActivityReport} + */ +proto.prehog.v1.SubmitUsageReportsRequest.prototype.addUserActivity = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.prehog.v1.UserActivityReport, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.prehog.v1.SubmitUsageReportsRequest} returns this + */ +proto.prehog.v1.SubmitUsageReportsRequest.prototype.clearUserActivityList = function() { + return this.setUserActivityList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.prehog.v1.SubmitUsageReportsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.prehog.v1.SubmitUsageReportsResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.prehog.v1.SubmitUsageReportsResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.SubmitUsageReportsResponse.toObject = function(includeInstance, msg) { + var f, obj = { + batchUuid: msg.getBatchUuid_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.prehog.v1.SubmitUsageReportsResponse} + */ +proto.prehog.v1.SubmitUsageReportsResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.prehog.v1.SubmitUsageReportsResponse; + return proto.prehog.v1.SubmitUsageReportsResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.prehog.v1.SubmitUsageReportsResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.prehog.v1.SubmitUsageReportsResponse} + */ +proto.prehog.v1.SubmitUsageReportsResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBatchUuid(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.prehog.v1.SubmitUsageReportsResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.prehog.v1.SubmitUsageReportsResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.prehog.v1.SubmitUsageReportsResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.prehog.v1.SubmitUsageReportsResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getBatchUuid_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } +}; + + +/** + * optional bytes batch_uuid = 1; + * @return {!(string|Uint8Array)} + */ +proto.prehog.v1.SubmitUsageReportsResponse.prototype.getBatchUuid = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes batch_uuid = 1; + * This is a type-conversion wrapper around `getBatchUuid()` + * @return {string} + */ +proto.prehog.v1.SubmitUsageReportsResponse.prototype.getBatchUuid_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBatchUuid())); +}; + + +/** + * optional bytes batch_uuid = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBatchUuid()` + * @return {!Uint8Array} + */ +proto.prehog.v1.SubmitUsageReportsResponse.prototype.getBatchUuid_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBatchUuid())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.prehog.v1.SubmitUsageReportsResponse} returns this + */ +proto.prehog.v1.SubmitUsageReportsResponse.prototype.setBatchUuid = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +goog.object.extend(exports, proto.prehog.v1); diff --git a/lib/service/service.go b/lib/service/service.go index 8e07a34c8586c..795b2fe3c8a11 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -121,6 +121,7 @@ import ( "github.com/gravitational/teleport/lib/srv/regular" "github.com/gravitational/teleport/lib/srv/transport/transportv1" "github.com/gravitational/teleport/lib/system" + usagereporter "github.com/gravitational/teleport/lib/usagereporter/teleport" "github.com/gravitational/teleport/lib/utils" "github.com/gravitational/teleport/lib/utils/cert" "github.com/gravitational/teleport/lib/web" @@ -1832,7 +1833,7 @@ func (process *TeleportProcess) initAuthService() error { } process.RegisterFunc("auth.heartbeat", heartbeat.Run) // execute this when process is asked to exit: - process.OnExit("auth.shutdown", func(payload interface{}) { + process.OnExit("auth.shutdown", func(payload any) { // The listeners have to be closed here, because if shutdown // was called before the start of the http server, // the http server would have not started tracking the listeners @@ -1847,6 +1848,7 @@ func (process *TeleportProcess) initAuthService() error { log.Info("Shutting down immediately.") warnOnErr(tlsServer.Close(), log) } else { + ctx := payloadContext(payload, log) log.Info("Shutting down immediately (auth service does not currently support graceful shutdown).") // NOTE: Graceful shutdown of auth.TLSServer is disabled right now, because we don't // have a good model for performing it. In particular, watchers and other GRPC streams @@ -1855,6 +1857,12 @@ func (process *TeleportProcess) initAuthService() error { // such as access workflow plugins from normal users. Without this, a graceful shutdown // of the auth server basically never exits. warnOnErr(tlsServer.Close(), log) + + if g, ok := authServer.Services.UsageReporter.(usagereporter.GracefulStopper); ok { + if err := g.GracefulStop(ctx); err != nil { + log.WithError(err).Warn("Error while gracefully stopping usage reporter.") + } + } } log.Info("Exited.") }) diff --git a/lib/usagereporter/daemon/usagereporter.go b/lib/usagereporter/daemon/usagereporter.go index acde2e3f8669e..5944200d45a15 100644 --- a/lib/usagereporter/daemon/usagereporter.go +++ b/lib/usagereporter/daemon/usagereporter.go @@ -23,8 +23,8 @@ import ( "github.com/google/uuid" "github.com/gravitational/trace" - prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" - prehogv1c "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha/v1alphaconnect" + prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" + prehogv1ac "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect" teletermv1 "github.com/gravitational/teleport/gen/proto/go/teleport/lib/teleterm/v1" "github.com/gravitational/teleport/lib/defaults" "github.com/gravitational/teleport/lib/usagereporter" @@ -61,9 +61,9 @@ const ( ) type ( - UsageReporter = usagereporter.UsageReporter[prehogv1.SubmitConnectEventRequest] - SubmitFunc = usagereporter.SubmitFunc[prehogv1.SubmitConnectEventRequest] - SubmittedEvent = usagereporter.SubmittedEvent[prehogv1.SubmitConnectEventRequest] + UsageReporter = usagereporter.UsageReporter[prehogv1a.SubmitConnectEventRequest] + SubmitFunc = usagereporter.SubmitFunc[prehogv1a.SubmitConnectEventRequest] + SubmittedEvent = usagereporter.SubmittedEvent[prehogv1a.SubmitConnectEventRequest] ) func NewConnectUsageReporter(ctx context.Context, prehogAddr string) (*UsageReporter, error) { @@ -71,7 +71,7 @@ func NewConnectUsageReporter(ctx context.Context, prehogAddr string) (*UsageRepo if err != nil { return nil, trace.Wrap(err) } - return usagereporter.NewUsageReporter(&usagereporter.Options[prehogv1.SubmitConnectEventRequest]{ + return usagereporter.NewUsageReporter(&usagereporter.Options[prehogv1a.SubmitConnectEventRequest]{ Submit: submitter, MinBatchSize: minBatchSize, MaxBatchSize: maxBatchSize, @@ -97,7 +97,7 @@ func newPrehogSubmitter(ctx context.Context, prehogEndpoint string) (SubmitFunc, Timeout: 5 * time.Second, } - client := prehogv1c.NewConnectReportingServiceClient(httpClient, prehogEndpoint) + client := prehogv1ac.NewConnectReportingServiceClient(httpClient, prehogEndpoint) return func(reporter *UsageReporter, events []*SubmittedEvent) ([]*SubmittedEvent, error) { var failed []*SubmittedEvent @@ -118,12 +118,12 @@ func newPrehogSubmitter(ctx context.Context, prehogEndpoint string) (SubmitFunc, }, nil } -func GetAnonymizedPrehogEvent(req *teletermv1.ReportUsageEventRequest) (*prehogv1.SubmitConnectEventRequest, error) { +func GetAnonymizedPrehogEvent(req *teletermv1.ReportUsageEventRequest) (*prehogv1a.SubmitConnectEventRequest, error) { prehogEvent := req.PrehogReq // non-anonymized switch prehogEvent.GetEvent().(type) { - case *prehogv1.SubmitConnectEventRequest_UserJobRoleUpdate: + case *prehogv1a.SubmitConnectEventRequest_UserJobRoleUpdate: return prehogEvent, nil } @@ -133,27 +133,27 @@ func GetAnonymizedPrehogEvent(req *teletermv1.ReportUsageEventRequest) (*prehogv return nil, trace.Wrap(err) } switch e := prehogEvent.GetEvent().(type) { - case *prehogv1.SubmitConnectEventRequest_ClusterLogin: + case *prehogv1a.SubmitConnectEventRequest_ClusterLogin: e.ClusterLogin.ClusterName = anonymizer.AnonymizeString(e.ClusterLogin.ClusterName) e.ClusterLogin.UserName = anonymizer.AnonymizeString(e.ClusterLogin.UserName) return prehogEvent, nil - case *prehogv1.SubmitConnectEventRequest_ProtocolUse: + case *prehogv1a.SubmitConnectEventRequest_ProtocolUse: e.ProtocolUse.ClusterName = anonymizer.AnonymizeString(e.ProtocolUse.ClusterName) e.ProtocolUse.UserName = anonymizer.AnonymizeString(e.ProtocolUse.UserName) return prehogEvent, nil - case *prehogv1.SubmitConnectEventRequest_AccessRequestCreate: + case *prehogv1a.SubmitConnectEventRequest_AccessRequestCreate: e.AccessRequestCreate.ClusterName = anonymizer.AnonymizeString(e.AccessRequestCreate.ClusterName) e.AccessRequestCreate.UserName = anonymizer.AnonymizeString(e.AccessRequestCreate.UserName) return prehogEvent, nil - case *prehogv1.SubmitConnectEventRequest_AccessRequestReview: + case *prehogv1a.SubmitConnectEventRequest_AccessRequestReview: e.AccessRequestReview.ClusterName = anonymizer.AnonymizeString(e.AccessRequestReview.ClusterName) e.AccessRequestReview.UserName = anonymizer.AnonymizeString(e.AccessRequestReview.UserName) return prehogEvent, nil - case *prehogv1.SubmitConnectEventRequest_AccessRequestAssumeRole: + case *prehogv1a.SubmitConnectEventRequest_AccessRequestAssumeRole: e.AccessRequestAssumeRole.ClusterName = anonymizer.AnonymizeString(e.AccessRequestAssumeRole.ClusterName) e.AccessRequestAssumeRole.UserName = anonymizer.AnonymizeString(e.AccessRequestAssumeRole.UserName) return prehogEvent, nil - case *prehogv1.SubmitConnectEventRequest_FileTransferRun: + case *prehogv1a.SubmitConnectEventRequest_FileTransferRun: e.FileTransferRun.ClusterName = anonymizer.AnonymizeString(e.FileTransferRun.ClusterName) e.FileTransferRun.UserName = anonymizer.AnonymizeString(e.FileTransferRun.UserName) return prehogEvent, nil diff --git a/lib/usagereporter/teleport/aggregating/reporter.go b/lib/usagereporter/teleport/aggregating/reporter.go new file mode 100644 index 0000000000000..527d2f79b1ece --- /dev/null +++ b/lib/usagereporter/teleport/aggregating/reporter.go @@ -0,0 +1,319 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aggregating + +import ( + "context" + "sync" + "time" + + "github.com/gravitational/trace" + "github.com/jonboulle/clockwork" + "github.com/sirupsen/logrus" + + "github.com/gravitational/teleport/api/types" + prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1" + "github.com/gravitational/teleport/lib/backend" + usagereporter "github.com/gravitational/teleport/lib/usagereporter/teleport" + "github.com/gravitational/teleport/lib/utils" +) + +const ( + reportGranularity = 15 * time.Minute + rollbackGrace = time.Minute + reportTTL = 60 * 24 * time.Hour + + checkInterval = time.Minute +) + +// ReporterConfig contains the configuration for a [Reporter]. +type ReporterConfig struct { + // Backend is the backend used to store reports. Required + Backend backend.Backend + // Log is the logger used for logging. Required. + Log logrus.FieldLogger + // Clock is the clock used for timestamping reports and deciding when to + // persist them to the backend. Optional, defaults to the real clock. + Clock clockwork.Clock + + // ClusterName is the ClusterName resource for the current cluster, used for + // anonymization and to report the cluster name itself. Required. + ClusterName types.ClusterName + // HostID is the host ID of the current Teleport instance, added to reports + // for auditing purposes. Required. + HostID string +} + +// CheckAndSetDefaults checks the [ReporterConfig] for validity, returning nil +// if there's no error. Idempotent but not concurrent safe, as it might need to +// write to the config to apply defaults. +func (cfg *ReporterConfig) CheckAndSetDefaults() error { + if cfg.Backend == nil { + return trace.BadParameter("missing Backend") + } + if cfg.Log == nil { + return trace.BadParameter("missing Log") + } + if cfg.Clock == nil { + cfg.Clock = clockwork.NewRealClock() + } + if cfg.ClusterName == nil { + return trace.BadParameter("missing ClusterName") + } + if cfg.HostID == "" { + return trace.BadParameter("missing HostID") + } + return nil +} + +// NewReporter returns a new running [Reporter]. To avoid resource leaks, +// GracefulStop must be called or the base context must be closed. The context +// will be used for all backend operations. +func NewReporter(ctx context.Context, cfg ReporterConfig) (*Reporter, error) { + if err := cfg.CheckAndSetDefaults(); err != nil { + return nil, trace.Wrap(err) + } + + anonymizer, err := utils.NewHMACAnonymizer(cfg.ClusterName.GetClusterID()) + if err != nil { + return nil, trace.Wrap(err) + } + + baseCtx, baseCancel := context.WithCancel(ctx) + + r := &Reporter{ + anonymizer: anonymizer, + svc: reportService{cfg.Backend}, + log: cfg.Log, + clock: cfg.Clock, + + ingest: make(chan usagereporter.Anonymizable), + closing: make(chan struct{}), + done: make(chan struct{}), + + clusterName: anonymizer.AnonymizeNonEmpty(cfg.ClusterName.GetClusterName()), + hostID: anonymizer.AnonymizeNonEmpty(cfg.HostID), + + baseCancel: baseCancel, + } + + go r.run(baseCtx) + + return r, nil +} + +// Reporter aggregates and persists usage events to the backend. +type Reporter struct { + anonymizer utils.Anonymizer + svc reportService + log logrus.FieldLogger + clock clockwork.Clock + + // ingest collects events from calls to [AnonymizeAndSubmit] to the + // background goroutine. + ingest chan usagereporter.Anonymizable + // closing is closed when we're not interested in collecting events anymore. + closing chan struct{} + // closingOnce closes [closing] once. + closingOnce sync.Once + // done is closed at the end of the background goroutine. + done chan struct{} + + // clusterName is the anonymized cluster name. + clusterName []byte + // hostID is the anonymized host ID of the reporter (this instance). + hostID []byte + + // baseCancel cancels the context used by the background goroutine. + baseCancel context.CancelFunc + + // ingested, if non-nil, received events after being added to the aggregated + // data. Used in tests. + ingested chan usagereporter.Anonymizable +} + +var _ usagereporter.GracefulStopper = (*Reporter)(nil) + +// GracefulStop implements [usagereporter.GracefulStopper]. +func (r *Reporter) GracefulStop(ctx context.Context) error { + r.closingOnce.Do(func() { close(r.closing) }) + + select { + case <-r.done: + return nil + case <-ctx.Done(): + } + + r.baseCancel() + <-r.done + + return ctx.Err() +} + +// AnonymizeAndSubmit implements [usagereporter.UsageReporter]. +func (r *Reporter) AnonymizeAndSubmit(events ...usagereporter.Anonymizable) { + filtered := events[:0] + for _, event := range events { + // this should drop all events that we don't care about + switch event.(type) { + case *usagereporter.UserLoginEvent, + *usagereporter.SessionStartEvent, + *usagereporter.KubeRequestEvent, + *usagereporter.SFTPEvent: + filtered = append(filtered, event) + } + } + if len(filtered) == 0 { + return + } + + // this function must not block + go r.anonymizeAndSubmit(filtered) +} + +func (r *Reporter) anonymizeAndSubmit(events []usagereporter.Anonymizable) { + for _, e := range events { + select { + case r.ingest <- e: + case <-r.closing: + return + } + } +} + +func (r *Reporter) run(ctx context.Context) { + defer r.baseCancel() + defer close(r.done) + + ticker := r.clock.NewTicker(checkInterval) + defer ticker.Stop() + + startTime := r.clock.Now().UTC().Truncate(reportGranularity) + windowStart := startTime.Add(-rollbackGrace) + windowEnd := startTime.Add(reportGranularity) + + userActivity := make(map[string]*prehogv1.UserActivityRecord) + + userRecord := func(userName string) *prehogv1.UserActivityRecord { + record := userActivity[userName] + if record == nil { + record = &prehogv1.UserActivityRecord{} + userActivity[userName] = record + } + return record + } + + var wg sync.WaitGroup + +Ingest: + for { + var ae usagereporter.Anonymizable + select { + case <-ticker.Chan(): + case ae = <-r.ingest: + + case <-ctx.Done(): + r.closingOnce.Do(func() { close(r.closing) }) + break Ingest + case <-r.closing: + break Ingest + } + + if now := r.clock.Now().UTC(); now.Before(windowStart) || !now.Before(windowEnd) { + if len(userActivity) > 0 { + wg.Add(1) + go func(ctx context.Context, startTime time.Time, userActivity map[string]*prehogv1.UserActivityRecord) { + defer wg.Done() + r.persistUserActivity(ctx, startTime, userActivity) + }(ctx, startTime, userActivity) + } + + startTime = now.Truncate(reportGranularity) + windowStart = startTime.Add(-rollbackGrace) + windowEnd = startTime.Add(reportGranularity) + userActivity = make(map[string]*prehogv1.UserActivityRecord, len(userActivity)) + } + + switch te := ae.(type) { + case *usagereporter.UserLoginEvent: + userRecord(te.UserName).Logins++ + case *usagereporter.SessionStartEvent: + switch te.SessionType { + case string(types.SSHSessionKind): + userRecord(te.UserName).SshSessions++ + case string(types.AppSessionKind): + userRecord(te.UserName).AppSessions++ + case string(types.KubernetesSessionKind): + userRecord(te.UserName).KubeSessions++ + case string(types.DatabaseSessionKind): + userRecord(te.UserName).DbSessions++ + case string(types.WindowsDesktopSessionKind): + userRecord(te.UserName).DesktopSessions++ + case usagereporter.PortSessionType: + userRecord(te.UserName).SshPortSessions++ + case usagereporter.TCPSessionType: + userRecord(te.UserName).AppTcpSessions++ + } + case *usagereporter.KubeRequestEvent: + userRecord(te.UserName).KubeRequests++ + case *usagereporter.SFTPEvent: + userRecord(te.UserName).SftpEvents++ + } + + if ae != nil && r.ingested != nil { + r.ingested <- ae + } + } + + if len(userActivity) > 0 { + r.persistUserActivity(ctx, startTime, userActivity) + } + + wg.Wait() +} + +func (r *Reporter) persistUserActivity(ctx context.Context, startTime time.Time, userActivity map[string]*prehogv1.UserActivityRecord) { + records := make([]*prehogv1.UserActivityRecord, 0, len(userActivity)) + for userName, record := range userActivity { + record.UserName = r.anonymizer.AnonymizeNonEmpty(userName) + records = append(records, record) + } + + for len(records) > 0 { + report, err := prepareUserActivityReport(r.clusterName, r.hostID, startTime, records) + if err != nil { + r.log.WithError(err).WithFields(logrus.Fields{ + "start_time": startTime, + "lost_records": len(records), + }).Error("Failed to prepare user activity report, dropping data.") + return + } + records = records[len(report.Records):] + + if err := r.svc.upsertUserActivityReport(ctx, report, reportTTL); err != nil { + r.log.WithError(err).WithFields(logrus.Fields{ + "start_time": startTime, + "lost_records": len(report.Records), + }).Error("Failed to persist user activity report, dropping data.") + continue + } + + r.log.WithFields(logrus.Fields{ + "report_uuid": report.ReportUuid, + "start_time": startTime, + "records": len(report.Records), + }).Debug("Persisted user activity report.") + } +} diff --git a/lib/usagereporter/teleport/aggregating/reporter_test.go b/lib/usagereporter/teleport/aggregating/reporter_test.go new file mode 100644 index 0000000000000..f15529a224878 --- /dev/null +++ b/lib/usagereporter/teleport/aggregating/reporter_test.go @@ -0,0 +1,148 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aggregating + +import ( + "bytes" + "context" + "testing" + "time" + + "github.com/google/uuid" + "github.com/jonboulle/clockwork" + "github.com/sirupsen/logrus" + "github.com/stretchr/testify/require" + + "github.com/gravitational/teleport/api/types" + "github.com/gravitational/teleport/lib/backend" + "github.com/gravitational/teleport/lib/backend/memory" + "github.com/gravitational/teleport/lib/services" + usagereporter "github.com/gravitational/teleport/lib/usagereporter/teleport" +) + +func TestReporter(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + clk := clockwork.NewFakeClock() + bk, err := memory.New(memory.Config{ + Clock: clk, + }) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, bk.Close()) }) + // we set up a watcher to not have to poll the backend for newly added items + // we expect + w, err := bk.NewWatcher(ctx, backend.Watch{}) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, w.Close()) }) + recvBackendEvent := func() backend.Event { + select { + case e := <-w.Events(): + return e + case <-time.After(time.Second): + t.Fatal("failed to get backend event") + return backend.Event{} + } + } + require.Equal(t, types.OpInit, recvBackendEvent().Type) + + clusterName, err := services.NewClusterNameWithRandomID(types.ClusterNameSpecV2{ + ClusterName: "clustername", + }) + require.NoError(t, err) + + r, err := NewReporter(ctx, ReporterConfig{ + Backend: bk, + Log: logrus.StandardLogger(), + Clock: clk, + ClusterName: clusterName, + HostID: uuid.NewString(), + }) + require.NoError(t, err) + + svc := reportService{bk} + + r.ingested = make(chan usagereporter.Anonymizable, 3) + recvIngested := func() { + select { + case <-r.ingested: + case <-time.After(time.Second): + t.Fatal("failed to receive ingested event") + } + } + r.AnonymizeAndSubmit(&usagereporter.UserLoginEvent{ + UserName: "alice", + }) + r.AnonymizeAndSubmit(&usagereporter.SessionStartEvent{ + UserName: "alice", + SessionType: "ssh", + }) + r.AnonymizeAndSubmit(&usagereporter.SessionStartEvent{ + UserName: "alice", + SessionType: "ssh", + }) + recvIngested() + recvIngested() + recvIngested() + r.ingested = nil + + clk.BlockUntil(1) + clk.Advance(reportGranularity) + + require.Equal(t, types.OpPut, recvBackendEvent().Type) + + reports, err := svc.listUserActivityReports(ctx, 10) + require.NoError(t, err) + require.Len(t, reports, 1) + require.Len(t, reports[0].Records, 1) + record := reports[0].Records[0] + require.Equal(t, uint64(1), record.Logins) + require.Equal(t, uint64(2), record.SshSessions) + + require.NoError(t, svc.deleteUserActivityReport(ctx, reports[0])) + require.Equal(t, types.OpDelete, recvBackendEvent().Type) + + // on a GracefulStop there's no need to advance the clock, all processed + // data is emitted immediately + r.ingested = make(chan usagereporter.Anonymizable, 3) + r.AnonymizeAndSubmit(&usagereporter.UserLoginEvent{ + UserName: "alice", + }) + r.AnonymizeAndSubmit(&usagereporter.UserLoginEvent{ + UserName: "bob", + }) + r.AnonymizeAndSubmit(&usagereporter.SessionStartEvent{ + UserName: "bob", + SessionType: "k8s", + }) + recvIngested() + recvIngested() + recvIngested() + r.ingested = nil + + require.NoError(t, r.GracefulStop(ctx)) + reports, err = svc.listUserActivityReports(ctx, 10) + require.NoError(t, err) + require.Len(t, reports, 1) + require.Len(t, reports[0].Records, 2) + rec1, rec2 := reports[0].Records[0], reports[0].Records[1] + // record.UserName is alice + if !bytes.Equal(record.UserName, rec1.UserName) { + rec1, rec2 = rec2, rec1 + } + require.Equal(t, uint64(1), rec1.Logins) + require.Equal(t, uint64(1), rec2.Logins) + require.Equal(t, uint64(0), rec1.KubeSessions) + require.Equal(t, uint64(1), rec2.KubeSessions) +} diff --git a/lib/usagereporter/teleport/aggregating/service.go b/lib/usagereporter/teleport/aggregating/service.go new file mode 100644 index 0000000000000..e8cafb6dae08e --- /dev/null +++ b/lib/usagereporter/teleport/aggregating/service.go @@ -0,0 +1,158 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aggregating + +import ( + "context" + "time" + + "github.com/google/uuid" + "github.com/gravitational/trace" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" + + prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1" + "github.com/gravitational/teleport/lib/backend" +) + +const ( + // maxItemSize is the maximum size for a backend value; dynamodb has a limit of + // 400KiB per item, we store values in base64, there's some framing, and a + // healthy 50% margin gets us to about 128KiB. + maxItemSize = 128 * 1024 +) + +const ( + userActivityReportsPrefix = "userActivityReports" + userActivityReportsLock = "userActivityReportsLock" +) + +// userActivityReportKey returns the backend key for a user activity report with +// a given UUID and start time, such that reports with an earlier start time +// will appear earlier in lexicographic ordering. +func userActivityReportKey(reportUUID uuid.UUID, startTime time.Time) []byte { + return backend.Key(userActivityReportsPrefix, startTime.Format(time.RFC3339), reportUUID.String()) +} + +func prepareUserActivityReport( + clusterName, reporterHostID []byte, + startTime time.Time, records []*prehogv1.UserActivityRecord, +) (*prehogv1.UserActivityReport, error) { + reportUUID := uuid.New() + report := &prehogv1.UserActivityReport{ + ReportUuid: reportUUID[:], + ClusterName: clusterName, + ReporterHostid: reporterHostID, + StartTime: timestamppb.New(startTime), + Records: records, + } + + for proto.Size(report) > maxItemSize { + if len(report.Records) <= 1 { + return nil, trace.LimitExceeded("failed to marshal user activity report within size limit (this is a bug)") + } + + report.Records = report.Records[:len(report.Records)/2] + } + + return report, nil +} + +// reportService is a [backend.Backend] wrapper that handles usage reports. +type reportService struct { + b backend.Backend +} + +func (r reportService) upsertUserActivityReport(ctx context.Context, report *prehogv1.UserActivityReport, ttl time.Duration) error { + wire, err := proto.Marshal(report) + if err != nil { + return trace.Wrap(err) + } + + reportUUID, err := uuid.FromBytes(report.GetReportUuid()) + if err != nil { + return trace.Wrap(err) + } + + startTime := report.GetStartTime().AsTime() + if startTime.IsZero() { + return trace.BadParameter("missing start_time") + } + + if _, err := r.b.Put(ctx, backend.Item{ + Key: userActivityReportKey(reportUUID, startTime), + Value: wire, + Expires: startTime.Add(ttl), + }); err != nil { + return trace.Wrap(err) + } + + return nil +} + +func (r reportService) deleteUserActivityReport(ctx context.Context, report *prehogv1.UserActivityReport) error { + reportUUID, err := uuid.FromBytes(report.GetReportUuid()) + if err != nil { + return trace.Wrap(err) + } + + startTime := report.GetStartTime().AsTime() + if startTime.IsZero() { + return trace.BadParameter("missing start_time") + } + + if err := r.b.Delete(ctx, userActivityReportKey(reportUUID, startTime)); err != nil { + return trace.Wrap(err) + } + + return nil +} + +// listUserActivityReports returns the first `count` user activity reports +// according to the key order; as we store them with time and uuid in the key, +// this results in returning earlier reports first. +func (r reportService) listUserActivityReports(ctx context.Context, count int) ([]*prehogv1.UserActivityReport, error) { + rangeStart := backend.ExactKey(userActivityReportsPrefix) + result, err := r.b.GetRange(ctx, rangeStart, backend.RangeEnd(rangeStart), count) + if err != nil { + return nil, trace.Wrap(err) + } + + reports := make([]*prehogv1.UserActivityReport, 0, len(result.Items)) + for _, item := range result.Items { + report := &prehogv1.UserActivityReport{} + if err := proto.Unmarshal(item.Value, report); err != nil { + return nil, trace.Wrap(err) + } + reports = append(reports, report) + } + + return reports, nil +} + +func (r reportService) createUserActivityReportsLock(ctx context.Context, ttl time.Duration, payload []byte) error { + if len(payload) == 0 { + payload = []byte("null") + } + if _, err := r.b.Create(ctx, backend.Item{ + Key: backend.Key(userActivityReportsLock), + Value: payload, + Expires: r.b.Clock().Now().UTC().Add(ttl), + }); err != nil { + return trace.Wrap(err) + } + + return nil +} diff --git a/lib/usagereporter/teleport/aggregating/service_test.go b/lib/usagereporter/teleport/aggregating/service_test.go new file mode 100644 index 0000000000000..d60d57c1d2289 --- /dev/null +++ b/lib/usagereporter/teleport/aggregating/service_test.go @@ -0,0 +1,107 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aggregating + +import ( + "context" + "testing" + "time" + + "github.com/google/uuid" + "github.com/gravitational/trace" + "github.com/jonboulle/clockwork" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" + + prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1" + "github.com/gravitational/teleport/lib/backend/memory" +) + +func newReport(startTime time.Time) *prehogv1.UserActivityReport { + u := uuid.New() + r := &prehogv1.UserActivityReport{ + ReportUuid: u[:], + StartTime: timestamppb.New(startTime), + } + return r +} + +func TestCRUD(t *testing.T) { + ctx := context.Background() + clk := clockwork.NewFakeClock() + bk, err := memory.New(memory.Config{ + Clock: clk, + EventsOff: true, + }) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, bk.Close()) }) + + svc := reportService{bk} + + r0 := newReport(clk.Now().Add(time.Minute)) + r1 := newReport(clk.Now().Add(time.Minute)) + r2 := newReport(clk.Now().Add(2 * time.Minute)) + + require.NoError(t, svc.upsertUserActivityReport(ctx, r0, time.Hour)) + require.NoError(t, svc.upsertUserActivityReport(ctx, r1, time.Hour)) + require.NoError(t, svc.upsertUserActivityReport(ctx, r2, time.Hour)) + + // we expect r0 and r1 in unspecified order + reports, err := svc.listUserActivityReports(ctx, 2) + require.NoError(t, err) + require.Len(t, reports, 2) + if proto.Equal(r0, reports[0]) { + require.True(t, proto.Equal(r1, reports[1])) + } else { + require.True(t, proto.Equal(r0, reports[1])) + require.True(t, proto.Equal(r1, reports[0])) + } + + require.NoError(t, svc.deleteUserActivityReport(ctx, r1)) + reports, err = svc.listUserActivityReports(ctx, 5) + require.NoError(t, err) + require.Len(t, reports, 2) + // r2 has a later start time, so it must appear later + require.True(t, proto.Equal(r0, reports[0])) + require.True(t, proto.Equal(r2, reports[1])) + + clk.Advance(time.Minute + time.Hour) + reports, err = svc.listUserActivityReports(ctx, 5) + require.NoError(t, err) + require.Len(t, reports, 1) + require.True(t, proto.Equal(r2, reports[0])) +} + +func TestLock(t *testing.T) { + ctx := context.Background() + clk := clockwork.NewFakeClock() + bk, err := memory.New(memory.Config{ + Clock: clk, + EventsOff: true, + }) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, bk.Close()) }) + + svc := reportService{bk} + + require.NoError(t, svc.createUserActivityReportsLock(ctx, 2*time.Minute, nil)) + clk.Advance(time.Minute) + err = svc.createUserActivityReportsLock(ctx, 2*time.Minute, nil) + require.Error(t, err) + require.True(t, trace.IsAlreadyExists(err)) + clk.Advance(time.Minute) + require.NoError(t, svc.createUserActivityReportsLock(ctx, 2*time.Minute, nil)) +} diff --git a/lib/usagereporter/teleport/aggregating/submitter.go b/lib/usagereporter/teleport/aggregating/submitter.go new file mode 100644 index 0000000000000..76d0864bfb5d9 --- /dev/null +++ b/lib/usagereporter/teleport/aggregating/submitter.go @@ -0,0 +1,206 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aggregating + +import ( + "context" + "fmt" + "time" + + "github.com/google/uuid" + "github.com/gravitational/trace" + "github.com/sirupsen/logrus" + + "github.com/gravitational/teleport/api/types" + "github.com/gravitational/teleport/api/utils/retryutils" + prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1" + "github.com/gravitational/teleport/lib/backend" + "github.com/gravitational/teleport/lib/services" + "github.com/gravitational/teleport/lib/utils" + "github.com/gravitational/teleport/lib/utils/interval" +) + +// UsageReportsSubmitter is almost SubmitUsageReports from +// prehog.v1alpha.TeleportReportingService, but instead of returning the raw +// response (and requiring wrapping the request in a [connect.Request]) it +// should parse the response and return the batch UUID. +type UsageReportsSubmitter func(context.Context, *prehogv1.SubmitUsageReportsRequest) (uuid.UUID, error) + +const ( + submitInterval = 5 * time.Minute + submitLockDuration = time.Minute + submitBatchSize = 10 + + alertGraceHours = 24 + alertGraceDuration = alertGraceHours * time.Hour + alertName = "reporting-failed" + alertLink = "https://goteleport.com/support/" +) + +const ( + defaultEndpointHostname = "reporting-teleport.teleportinfra.sh" + DefaultEndpoint = "https://" + defaultEndpointHostname +) + +var alertMessage = fmt.Sprintf("Teleport has failed to contact the usage reporting server for more than %v hours. "+ + "Please make sure that the Teleport Auth Server can connect to (%v). "+ + "Otherwise, contact Teleport Support at (%v).", + alertGraceHours, defaultEndpointHostname, alertLink) + +// SubmitterConfig contains the configuration for a [Submitter]. +type SubmitterConfig struct { + // Backend is the backend to use to read reports and apply locks. Required. + Backend backend.Backend + // Log is the [logrus.FieldLogger] used for logging. Required. + Log logrus.FieldLogger + // Status is used to create or clear cluster alerts on a failure. Required. + Status services.StatusInternal + // Submitter is used to submit usage reports. Required. + Submitter UsageReportsSubmitter + + // HostID is the host ID of the current Teleport instance, used in the lock + // payload and cluster alert description to help debugging. Optional. + HostID string +} + +// CheckAndSetDefaults checks the [SubmitterConfig] for validity, returning nil +// if there's no error. Idempotent but not concurrent safe, as it might need to +// write to the config to apply defaults. +func (cfg *SubmitterConfig) CheckAndSetDefaults() error { + if cfg.Backend == nil { + return trace.BadParameter("missing Backend") + } + if cfg.Log == nil { + return trace.BadParameter("missing Log") + } + if cfg.Status == nil { + return trace.BadParameter("missing Status") + } + if cfg.Submitter == nil { + return trace.BadParameter("missing Submitter") + } + return nil +} + +// RunSubmitter periodically fetches aggregated reports from the backend and +// sends them in small batches with the provided submitter, before deleting +// them. Must only be called after validating the config object with +// CheckAndSetDefaults, and should probably be called in a goroutine. +func RunSubmitter(ctx context.Context, cfg SubmitterConfig) { + iv := interval.New(interval.Config{ + FirstDuration: utils.HalfJitter(2 * submitInterval), + Duration: submitInterval, + Jitter: retryutils.NewSeventhJitter(), + }) + defer iv.Stop() + + for { + select { + case <-ctx.Done(): + return + case <-iv.Next(): + } + + submitOnce(ctx, cfg) + } +} + +func submitOnce(ctx context.Context, c SubmitterConfig) { + svc := reportService{c.Backend} + + reports, err := svc.listUserActivityReports(ctx, submitBatchSize) + if err != nil { + c.Log.WithError(err).Error("Failed to load usage reports for submission.") + return + } + + if len(reports) < 1 { + if _, err := c.Status.GetClusterAlerts(ctx, types.GetClusterAlertsRequest{ + AlertID: alertName, + }); err != nil && trace.IsNotFound(err) { + // if we can confirm that there's no cluster alert we go ahead and + // exit here without attempting the delete (reads are cheaper than + // writes) + return + } + err := c.Status.DeleteClusterAlert(ctx, alertName) + if err == nil { + c.Log.Infof("Deleted cluster alert %v after successfully clearing usage report backlog.", alertName) + } else if !trace.IsNotFound(err) { + c.Log.WithError(err).Errorf("Failed to delete cluster alert %v.", alertName) + } + return + } + + debugPayload := fmt.Sprintf("%v %q", time.Now().Round(0), c.HostID) + if err := svc.createUserActivityReportsLock(ctx, submitLockDuration, []byte(debugPayload)); err != nil { + if trace.IsAlreadyExists(err) { + c.Log.Debugf("Failed to acquire lock %v, already held.", userActivityReportsLock) + } else { + c.Log.WithError(err).Errorf("Failed to acquire lock %v.", userActivityReportsLock) + } + return + } + + lockCtx, cancel := context.WithTimeout(ctx, submitLockDuration*9/10) + defer cancel() + + batchUUID, err := c.Submitter(lockCtx, &prehogv1.SubmitUsageReportsRequest{ + UserActivity: reports, + }) + if err != nil { + c.Log.WithError(err).WithFields(logrus.Fields{ + "reports": len(reports), + "oldest_report": reports[0].GetStartTime().AsTime(), + "newest_report": reports[len(reports)-1].GetStartTime().AsTime(), + }).Error("Failed to send usage reports.") + + if time.Since(reports[0].StartTime.AsTime()) <= alertGraceDuration { + return + } + alert, err := types.NewClusterAlert( + alertName, + alertMessage, + types.WithAlertLabel(types.AlertOnLogin, "yes"), + types.WithAlertLabel(types.AlertPermitAll, "yes"), + types.WithAlertLabel(types.AlertLink, alertLink), + ) + if err != nil { + c.Log.WithError(err).Errorf("Failed to create cluster alert %v.", alertName) + return + } + alert.Metadata.Description = debugPayload + if err := c.Status.UpsertClusterAlert(ctx, alert); err != nil { + c.Log.WithError(err).Errorf("Failed to upsert cluster alert %v.", alertName) + } + return + } + + c.Log.WithFields(logrus.Fields{ + "batch_uuid": batchUUID, + "reports": len(reports), + "oldest_report": reports[0].GetStartTime().AsTime(), + }).Info("Successfully sent usage reports.") + + var lastErr error + for _, report := range reports { + if err := svc.deleteUserActivityReport(ctx, report); err != nil { + lastErr = err + } + } + if lastErr != nil { + c.Log.WithField("last_error", lastErr).Warn("Failed to delete some usage reports after successful send.") + } +} diff --git a/lib/usagereporter/teleport/aggregating/submitter_test.go b/lib/usagereporter/teleport/aggregating/submitter_test.go new file mode 100644 index 0000000000000..f7b5ffb37d906 --- /dev/null +++ b/lib/usagereporter/teleport/aggregating/submitter_test.go @@ -0,0 +1,132 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aggregating + +import ( + "context" + "errors" + "testing" + + "github.com/google/uuid" + "github.com/jonboulle/clockwork" + "github.com/sirupsen/logrus" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + + "github.com/gravitational/teleport/api/types" + prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1" + "github.com/gravitational/teleport/lib/backend/memory" + "github.com/gravitational/teleport/lib/services/local" +) + +// TestSubmitOnce tests the behavior of [submitOnce]; the [RunSubmitter] +// function is just a jittered periodic call to submitOnce, so testing it has +// very little use. +func TestSubmitOnce(t *testing.T) { + ctx := context.Background() + clk := clockwork.NewFakeClock() + bk, err := memory.New(memory.Config{ + Clock: clk, + EventsOff: true, + }) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, bk.Close()) }) + + svc := reportService{bk} + + var submitted []*prehogv1.UserActivityReport + submitOk := func(ctx context.Context, req *prehogv1.SubmitUsageReportsRequest) (uuid.UUID, error) { + submitted = append(submitted, req.UserActivity...) + return uuid.New(), nil + } + submitErr := func(ctx context.Context, req *prehogv1.SubmitUsageReportsRequest) (uuid.UUID, error) { + submitted = append(submitted, req.UserActivity...) + return uuid.Nil, errors.New("") + } + + scfg := SubmitterConfig{ + Backend: bk, + Log: logrus.StandardLogger(), + Status: local.NewStatusService(bk), + Submitter: submitOk, + } + require.NoError(t, scfg.CheckAndSetDefaults()) + + r0 := newReport(clk.Now()) + require.NoError(t, svc.upsertUserActivityReport(ctx, r0, reportTTL)) + + // successful submit, no alerts, no leftover reports + submitOnce(ctx, scfg) + require.Len(t, submitted, 1) + require.True(t, proto.Equal(r0, submitted[0])) + reports, err := svc.listUserActivityReports(ctx, 10) + require.NoError(t, err) + require.Empty(t, reports) + submitted = nil + + alerts, err := scfg.Status.GetClusterAlerts(ctx, types.GetClusterAlertsRequest{ + AlertID: alertName, + }) + require.NoError(t, err) + require.Empty(t, alerts) + + require.NoError(t, svc.upsertUserActivityReport(ctx, r0, reportTTL)) + + // failed submit past the grace time, we get the alert and the report is still there + clk.Advance(alertGraceDuration) + scfg.Submitter = submitErr + submitOnce(ctx, scfg) + require.Len(t, submitted, 1) + require.True(t, proto.Equal(r0, submitted[0])) + reports, err = svc.listUserActivityReports(ctx, 10) + require.NoError(t, err) + require.Len(t, reports, 1) + require.True(t, proto.Equal(r0, reports[0])) + submitted = nil + + alerts, err = scfg.Status.GetClusterAlerts(ctx, types.GetClusterAlertsRequest{ + AlertID: alertName, + }) + require.NoError(t, err) + require.Len(t, alerts, 1) + require.Equal(t, alertName, alerts[0].GetName()) + + scfg.Submitter = submitOk + // the lock is still held, nothing happens + submitOnce(ctx, scfg) + require.Empty(t, submitted) + + clk.Advance(submitLockDuration) + // successful submission, no remaining events but the alert stays for one more cycle + submitOnce(ctx, scfg) + require.Len(t, submitted, 1) + submitted = nil + + alerts, err = scfg.Status.GetClusterAlerts(ctx, types.GetClusterAlertsRequest{ + AlertID: alertName, + }) + require.NoError(t, err) + require.Len(t, alerts, 1) + require.Equal(t, alertName, alerts[0].GetName()) + + // nothing to submit, alert gone + submitOnce(ctx, scfg) + require.Empty(t, submitted) + alerts, err = scfg.Status.GetClusterAlerts(ctx, types.GetClusterAlertsRequest{ + AlertID: alertName, + }) + require.NoError(t, err) + require.Empty(t, alerts) +} diff --git a/lib/usagereporter/teleport/audit.go b/lib/usagereporter/teleport/audit.go index b3ac0331a18da..13845eb2cdded 100644 --- a/lib/usagereporter/teleport/audit.go +++ b/lib/usagereporter/teleport/audit.go @@ -22,12 +22,12 @@ import ( ) const ( - // tcpSessionType is the session_type in tp.session.start for TCP + // TCPSessionType is the session_type in tp.session.start for TCP // Application Access. - tcpSessionType = "app_tcp" - // portSessionType is the session_type in tp.session.start for SSH port + TCPSessionType = "app_tcp" + // PortSessionType is the session_type in tp.session.start for SSH port // forwarding. - portSessionType = "ssh_port" + PortSessionType = "ssh_port" ) func ConvertAuditEvent(event apievents.AuditEvent) Anonymizable { @@ -66,7 +66,7 @@ func ConvertAuditEvent(event apievents.AuditEvent) Anonymizable { case *apievents.PortForward: return &SessionStartEvent{ UserName: e.User, - SessionType: portSessionType, + SessionType: PortSessionType, } case *apievents.DatabaseSessionStart: return &SessionStartEvent{ @@ -76,7 +76,7 @@ func ConvertAuditEvent(event apievents.AuditEvent) Anonymizable { case *apievents.AppSessionStart: sessionType := string(types.AppSessionKind) if types.IsAppTCP(e.AppURI) { - sessionType = tcpSessionType + sessionType = TCPSessionType } return &SessionStartEvent{ UserName: e.User, diff --git a/lib/usagereporter/teleport/types.go b/lib/usagereporter/teleport/types.go index b9c8cbfe7b2ae..69b4badd571d1 100644 --- a/lib/usagereporter/teleport/types.go +++ b/lib/usagereporter/teleport/types.go @@ -23,7 +23,7 @@ import ( "github.com/gravitational/teleport" usageeventsv1 "github.com/gravitational/teleport/api/gen/proto/go/usageevents/v1" "github.com/gravitational/teleport/api/types" - prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" + prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" "github.com/gravitational/teleport/lib/utils" ) @@ -31,21 +31,21 @@ import ( type Anonymizable interface { // Anonymize uses the given anonymizer to anonymize the event and converts // it into a partially filled SubmitEventRequest. - Anonymize(utils.Anonymizer) prehogv1.SubmitEventRequest + Anonymize(utils.Anonymizer) prehogv1a.SubmitEventRequest } // UserLoginEvent is an event emitted when a user logs into Teleport, // potentially via SSO. -type UserLoginEvent prehogv1.UserLoginEvent +type UserLoginEvent prehogv1a.UserLoginEvent -func (u *UserLoginEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { +func (u *UserLoginEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { var deviceID string if u.DeviceId != "" { deviceID = a.AnonymizeString(u.DeviceId) } - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UserLogin{ - UserLogin: &prehogv1.UserLoginEvent{ + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UserLogin{ + UserLogin: &prehogv1a.UserLoginEvent{ UserName: a.AnonymizeString(u.UserName), ConnectorType: u.ConnectorType, DeviceId: deviceID, @@ -55,12 +55,12 @@ func (u *UserLoginEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventReque } // SSOCreateEvent is emitted when an SSO connector has been created. -type SSOCreateEvent prehogv1.SSOCreateEvent +type SSOCreateEvent prehogv1a.SSOCreateEvent -func (u *SSOCreateEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_SsoCreate{ - SsoCreate: &prehogv1.SSOCreateEvent{ +func (u *SSOCreateEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_SsoCreate{ + SsoCreate: &prehogv1a.SSOCreateEvent{ ConnectorType: u.ConnectorType, }, }, @@ -69,12 +69,12 @@ func (u *SSOCreateEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventReque // SessionStartEvent is an event emitted when some Teleport session has started // (ssh, etc). -type SessionStartEvent prehogv1.SessionStartEvent +type SessionStartEvent prehogv1a.SessionStartEvent -func (u *SessionStartEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_SessionStartV2{ - SessionStartV2: &prehogv1.SessionStartEvent{ +func (u *SessionStartEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_SessionStartV2{ + SessionStartV2: &prehogv1a.SessionStartEvent{ UserName: a.AnonymizeString(u.UserName), SessionType: u.SessionType, }, @@ -84,12 +84,12 @@ func (u *SessionStartEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRe // ResourceCreateEvent is an event emitted when various resource types have been // created. -type ResourceCreateEvent prehogv1.ResourceCreateEvent +type ResourceCreateEvent prehogv1a.ResourceCreateEvent -func (u *ResourceCreateEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_ResourceCreate{ - ResourceCreate: &prehogv1.ResourceCreateEvent{ +func (u *ResourceCreateEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_ResourceCreate{ + ResourceCreate: &prehogv1a.ResourceCreateEvent{ ResourceType: u.ResourceType, }, }, @@ -97,12 +97,12 @@ func (u *ResourceCreateEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEvent } // UIBannerClickEvent is a UI event sent when a banner is clicked. -type UIBannerClickEvent prehogv1.UIBannerClickEvent +type UIBannerClickEvent prehogv1a.UIBannerClickEvent -func (u *UIBannerClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiBannerClick{ - UiBannerClick: &prehogv1.UIBannerClickEvent{ +func (u *UIBannerClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiBannerClick{ + UiBannerClick: &prehogv1a.UIBannerClickEvent{ UserName: a.AnonymizeString(u.UserName), Alert: u.Alert, }, @@ -112,12 +112,12 @@ func (u *UIBannerClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventR // UIOnboardCompleteGoToDashboardClickEvent is a UI event sent when // onboarding is complete. -type UIOnboardCompleteGoToDashboardClickEvent prehogv1.UIOnboardCompleteGoToDashboardClickEvent +type UIOnboardCompleteGoToDashboardClickEvent prehogv1a.UIOnboardCompleteGoToDashboardClickEvent -func (u *UIOnboardCompleteGoToDashboardClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiOnboardCompleteGoToDashboardClick{ - UiOnboardCompleteGoToDashboardClick: &prehogv1.UIOnboardCompleteGoToDashboardClickEvent{ +func (u *UIOnboardCompleteGoToDashboardClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiOnboardCompleteGoToDashboardClick{ + UiOnboardCompleteGoToDashboardClick: &prehogv1a.UIOnboardCompleteGoToDashboardClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -126,12 +126,12 @@ func (u *UIOnboardCompleteGoToDashboardClickEvent) Anonymize(a utils.Anonymizer) // UIOnboardAddFirstResourceClickEvent is a UI event sent when a user // clicks the "add first resource" button. -type UIOnboardAddFirstResourceClickEvent prehogv1.UIOnboardAddFirstResourceClickEvent +type UIOnboardAddFirstResourceClickEvent prehogv1a.UIOnboardAddFirstResourceClickEvent -func (u *UIOnboardAddFirstResourceClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiOnboardAddFirstResourceClick{ - UiOnboardAddFirstResourceClick: &prehogv1.UIOnboardAddFirstResourceClickEvent{ +func (u *UIOnboardAddFirstResourceClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiOnboardAddFirstResourceClick{ + UiOnboardAddFirstResourceClick: &prehogv1a.UIOnboardAddFirstResourceClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -140,12 +140,12 @@ func (u *UIOnboardAddFirstResourceClickEvent) Anonymize(a utils.Anonymizer) preh // UIOnboardAddFirstResourceLaterClickEvent is a UI event sent when a user // clicks the "add first resource later" button. -type UIOnboardAddFirstResourceLaterClickEvent prehogv1.UIOnboardAddFirstResourceLaterClickEvent +type UIOnboardAddFirstResourceLaterClickEvent prehogv1a.UIOnboardAddFirstResourceLaterClickEvent -func (u *UIOnboardAddFirstResourceLaterClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiOnboardAddFirstResourceLaterClick{ - UiOnboardAddFirstResourceLaterClick: &prehogv1.UIOnboardAddFirstResourceLaterClickEvent{ +func (u *UIOnboardAddFirstResourceLaterClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiOnboardAddFirstResourceLaterClick{ + UiOnboardAddFirstResourceLaterClick: &prehogv1a.UIOnboardAddFirstResourceLaterClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -154,12 +154,12 @@ func (u *UIOnboardAddFirstResourceLaterClickEvent) Anonymize(a utils.Anonymizer) // UIOnboardSetCredentialSubmitEvent is an UI event sent during registration // when the user configures login credentials. -type UIOnboardSetCredentialSubmitEvent prehogv1.UIOnboardSetCredentialSubmitEvent +type UIOnboardSetCredentialSubmitEvent prehogv1a.UIOnboardSetCredentialSubmitEvent -func (u *UIOnboardSetCredentialSubmitEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiOnboardSetCredentialSubmit{ - UiOnboardSetCredentialSubmit: &prehogv1.UIOnboardSetCredentialSubmitEvent{ +func (u *UIOnboardSetCredentialSubmitEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiOnboardSetCredentialSubmit{ + UiOnboardSetCredentialSubmit: &prehogv1a.UIOnboardSetCredentialSubmitEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -168,12 +168,12 @@ func (u *UIOnboardSetCredentialSubmitEvent) Anonymize(a utils.Anonymizer) prehog // UIOnboardRegisterChallengeSubmitEvent is a UI event sent during registration // when the MFA challenge is completed. -type UIOnboardRegisterChallengeSubmitEvent prehogv1.UIOnboardRegisterChallengeSubmitEvent +type UIOnboardRegisterChallengeSubmitEvent prehogv1a.UIOnboardRegisterChallengeSubmitEvent -func (u *UIOnboardRegisterChallengeSubmitEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiOnboardRegisterChallengeSubmit{ - UiOnboardRegisterChallengeSubmit: &prehogv1.UIOnboardRegisterChallengeSubmitEvent{ +func (u *UIOnboardRegisterChallengeSubmitEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiOnboardRegisterChallengeSubmit{ + UiOnboardRegisterChallengeSubmit: &prehogv1a.UIOnboardRegisterChallengeSubmitEvent{ UserName: a.AnonymizeString(u.UserName), MfaType: u.MfaType, LoginFlow: u.LoginFlow, @@ -183,12 +183,12 @@ func (u *UIOnboardRegisterChallengeSubmitEvent) Anonymize(a utils.Anonymizer) pr } // UIRecoveryCodesContinueClickEvent is a UI event sent when a user configures recovery codes. -type UIRecoveryCodesContinueClickEvent prehogv1.UIRecoveryCodesContinueClickEvent +type UIRecoveryCodesContinueClickEvent prehogv1a.UIRecoveryCodesContinueClickEvent -func (u *UIRecoveryCodesContinueClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiRecoveryCodesContinueClick{ - UiRecoveryCodesContinueClick: &prehogv1.UIRecoveryCodesContinueClickEvent{ +func (u *UIRecoveryCodesContinueClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiRecoveryCodesContinueClick{ + UiRecoveryCodesContinueClick: &prehogv1a.UIRecoveryCodesContinueClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -196,12 +196,12 @@ func (u *UIRecoveryCodesContinueClickEvent) Anonymize(a utils.Anonymizer) prehog } // UIRecoveryCodesCopyClickEvent is a UI event sent when a user copies recovery codes. -type UIRecoveryCodesCopyClickEvent prehogv1.UIRecoveryCodesCopyClickEvent +type UIRecoveryCodesCopyClickEvent prehogv1a.UIRecoveryCodesCopyClickEvent -func (u *UIRecoveryCodesCopyClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiRecoveryCodesCopyClick{ - UiRecoveryCodesCopyClick: &prehogv1.UIRecoveryCodesCopyClickEvent{ +func (u *UIRecoveryCodesCopyClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiRecoveryCodesCopyClick{ + UiRecoveryCodesCopyClick: &prehogv1a.UIRecoveryCodesCopyClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -209,12 +209,12 @@ func (u *UIRecoveryCodesCopyClickEvent) Anonymize(a utils.Anonymizer) prehogv1.S } // UsageUIRecoveryCodesPrintClick is a UI event sent when a user prints recovery codes. -type UsageUIRecoveryCodesPrintClick prehogv1.UIRecoveryCodesPrintClickEvent +type UsageUIRecoveryCodesPrintClick prehogv1a.UIRecoveryCodesPrintClickEvent -func (u *UsageUIRecoveryCodesPrintClick) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiRecoveryCodesPrintClick{ - UiRecoveryCodesPrintClick: &prehogv1.UIRecoveryCodesPrintClickEvent{ +func (u *UsageUIRecoveryCodesPrintClick) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiRecoveryCodesPrintClick{ + UiRecoveryCodesPrintClick: &prehogv1a.UIRecoveryCodesPrintClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -222,17 +222,17 @@ func (u *UsageUIRecoveryCodesPrintClick) Anonymize(a utils.Anonymizer) prehogv1. } // RoleCreateEvent is an event emitted when a custom role is created. -type RoleCreateEvent prehogv1.RoleCreateEvent +type RoleCreateEvent prehogv1a.RoleCreateEvent -func (u *RoleCreateEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { +func (u *RoleCreateEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { role := u.RoleName if !slices.Contains(teleport.PresetRoles, u.RoleName) { role = a.AnonymizeString(u.RoleName) } - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_RoleCreate{ - RoleCreate: &prehogv1.RoleCreateEvent{ + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_RoleCreate{ + RoleCreate: &prehogv1a.RoleCreateEvent{ UserName: a.AnonymizeString(u.UserName), RoleName: role, }, @@ -241,12 +241,12 @@ func (u *RoleCreateEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequ } // UICreateNewRoleClickEvent is a UI event sent when a user prints recovery codes. -type UICreateNewRoleClickEvent prehogv1.UICreateNewRoleClickEvent +type UICreateNewRoleClickEvent prehogv1a.UICreateNewRoleClickEvent -func (u *UICreateNewRoleClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiCreateNewRoleClick{ - UiCreateNewRoleClick: &prehogv1.UICreateNewRoleClickEvent{ +func (u *UICreateNewRoleClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiCreateNewRoleClick{ + UiCreateNewRoleClick: &prehogv1a.UICreateNewRoleClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -254,12 +254,12 @@ func (u *UICreateNewRoleClickEvent) Anonymize(a utils.Anonymizer) prehogv1.Submi } // UICreateNewRoleSaveClickEvent is a UI event sent when a user prints recovery codes. -type UICreateNewRoleSaveClickEvent prehogv1.UICreateNewRoleSaveClickEvent +type UICreateNewRoleSaveClickEvent prehogv1a.UICreateNewRoleSaveClickEvent -func (u *UICreateNewRoleSaveClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiCreateNewRoleSaveClick{ - UiCreateNewRoleSaveClick: &prehogv1.UICreateNewRoleSaveClickEvent{ +func (u *UICreateNewRoleSaveClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiCreateNewRoleSaveClick{ + UiCreateNewRoleSaveClick: &prehogv1a.UICreateNewRoleSaveClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -267,12 +267,12 @@ func (u *UICreateNewRoleSaveClickEvent) Anonymize(a utils.Anonymizer) prehogv1.S } // UICreateNewRoleCancelClickEvent is a UI event sent when a user prints recovery codes. -type UICreateNewRoleCancelClickEvent prehogv1.UICreateNewRoleCancelClickEvent +type UICreateNewRoleCancelClickEvent prehogv1a.UICreateNewRoleCancelClickEvent -func (u *UICreateNewRoleCancelClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiCreateNewRoleCancelClick{ - UiCreateNewRoleCancelClick: &prehogv1.UICreateNewRoleCancelClickEvent{ +func (u *UICreateNewRoleCancelClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiCreateNewRoleCancelClick{ + UiCreateNewRoleCancelClick: &prehogv1a.UICreateNewRoleCancelClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -280,12 +280,12 @@ func (u *UICreateNewRoleCancelClickEvent) Anonymize(a utils.Anonymizer) prehogv1 } // UICreateNewRoleViewDocumentationClickEvent is a UI event sent when a user prints recovery codes. -type UICreateNewRoleViewDocumentationClickEvent prehogv1.UICreateNewRoleViewDocumentationClickEvent +type UICreateNewRoleViewDocumentationClickEvent prehogv1a.UICreateNewRoleViewDocumentationClickEvent -func (u *UICreateNewRoleViewDocumentationClickEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiCreateNewRoleViewDocumentationClick{ - UiCreateNewRoleViewDocumentationClick: &prehogv1.UICreateNewRoleViewDocumentationClickEvent{ +func (u *UICreateNewRoleViewDocumentationClickEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiCreateNewRoleViewDocumentationClick{ + UiCreateNewRoleViewDocumentationClick: &prehogv1a.UICreateNewRoleViewDocumentationClickEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -294,12 +294,12 @@ func (u *UICreateNewRoleViewDocumentationClickEvent) Anonymize(a utils.Anonymize // UserCertificateIssuedEvent is an event emitted when a certificate has been // issued, used to track the duration and restriction. -type UserCertificateIssuedEvent prehogv1.UserCertificateIssuedEvent +type UserCertificateIssuedEvent prehogv1a.UserCertificateIssuedEvent -func (u *UserCertificateIssuedEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UserCertificateIssuedEvent{ - UserCertificateIssuedEvent: &prehogv1.UserCertificateIssuedEvent{ +func (u *UserCertificateIssuedEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UserCertificateIssuedEvent{ + UserCertificateIssuedEvent: &prehogv1a.UserCertificateIssuedEvent{ UserName: a.AnonymizeString(u.UserName), Ttl: u.Ttl, IsBot: u.IsBot, @@ -314,12 +314,12 @@ func (u *UserCertificateIssuedEvent) Anonymize(a utils.Anonymizer) prehogv1.Subm // KubeRequestEvent is an event emitted when a Kubernetes API request is // handled. -type KubeRequestEvent prehogv1.KubeRequestEvent +type KubeRequestEvent prehogv1a.KubeRequestEvent -func (u *KubeRequestEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_KubeRequest{ - KubeRequest: &prehogv1.KubeRequestEvent{ +func (u *KubeRequestEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_KubeRequest{ + KubeRequest: &prehogv1a.KubeRequestEvent{ UserName: a.AnonymizeString(u.UserName), }, }, @@ -327,12 +327,12 @@ func (u *KubeRequestEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventReq } // SFTPEvent is an event emitted for each file operation in a SFTP connection. -type SFTPEvent prehogv1.SFTPEvent +type SFTPEvent prehogv1a.SFTPEvent -func (u *SFTPEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_Sftp{ - Sftp: &prehogv1.SFTPEvent{ +func (u *SFTPEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_Sftp{ + Sftp: &prehogv1a.SFTPEvent{ UserName: a.AnonymizeString(u.UserName), Action: u.Action, }, @@ -341,12 +341,12 @@ func (u *SFTPEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { } // AgentMetadataEvent is an event emitted after an agent first connects to the auth server. -type AgentMetadataEvent prehogv1.AgentMetadataEvent +type AgentMetadataEvent prehogv1a.AgentMetadataEvent -func (u *AgentMetadataEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_AgentMetadataEvent{ - AgentMetadataEvent: &prehogv1.AgentMetadataEvent{ +func (u *AgentMetadataEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_AgentMetadataEvent{ + AgentMetadataEvent: &prehogv1a.AgentMetadataEvent{ Version: u.Version, HostId: a.AnonymizeString(u.HostId), Services: u.Services, @@ -363,15 +363,15 @@ func (u *AgentMetadataEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventR } } -type ResourceKind = prehogv1.ResourceKind +type ResourceKind = prehogv1a.ResourceKind const ( - ResourceKindNode = prehogv1.ResourceKind_RESOURCE_KIND_NODE - ResourceKindAppServer = prehogv1.ResourceKind_RESOURCE_KIND_APP_SERVER - ResourceKindKubeServer = prehogv1.ResourceKind_RESOURCE_KIND_KUBE_SERVER - ResourceKindDBServer = prehogv1.ResourceKind_RESOURCE_KIND_DB_SERVER - ResourceKindWindowsDesktop = prehogv1.ResourceKind_RESOURCE_KIND_WINDOWS_DESKTOP - ResourceKindNodeOpenSSH = prehogv1.ResourceKind_RESOURCE_KIND_NODE_OPENSSH + ResourceKindNode = prehogv1a.ResourceKind_RESOURCE_KIND_NODE + ResourceKindAppServer = prehogv1a.ResourceKind_RESOURCE_KIND_APP_SERVER + ResourceKindKubeServer = prehogv1a.ResourceKind_RESOURCE_KIND_KUBE_SERVER + ResourceKindDBServer = prehogv1a.ResourceKind_RESOURCE_KIND_DB_SERVER + ResourceKindWindowsDesktop = prehogv1a.ResourceKind_RESOURCE_KIND_WINDOWS_DESKTOP + ResourceKindNodeOpenSSH = prehogv1a.ResourceKind_RESOURCE_KIND_NODE_OPENSSH ) func ResourceKindFromKeepAliveType(t types.KeepAlive_KeepAliveType) ResourceKind { @@ -391,14 +391,14 @@ func ResourceKindFromKeepAliveType(t types.KeepAlive_KeepAliveType) ResourceKind type ResourceHeartbeatEvent struct { Name string - Kind prehogv1.ResourceKind + Kind prehogv1a.ResourceKind Static bool } -func (u *ResourceHeartbeatEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_ResourceHeartbeat{ - ResourceHeartbeat: &prehogv1.ResourceHeartbeatEvent{ +func (u *ResourceHeartbeatEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_ResourceHeartbeat{ + ResourceHeartbeat: &prehogv1a.ResourceHeartbeatEvent{ ResourceName: a.AnonymizeNonEmpty(u.Name), ResourceKind: u.Kind, Static: u.Static, diff --git a/lib/usagereporter/teleport/types_discover.go b/lib/usagereporter/teleport/types_discover.go index 42f31ffe11919..4d6f3a78e7241 100644 --- a/lib/usagereporter/teleport/types_discover.go +++ b/lib/usagereporter/teleport/types_discover.go @@ -20,19 +20,19 @@ import ( "github.com/gravitational/trace" usageeventsv1 "github.com/gravitational/teleport/api/gen/proto/go/usageevents/v1" - prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" + prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" "github.com/gravitational/teleport/lib/utils" ) -func discoverMetadataToPrehog(u *usageeventsv1.DiscoverMetadata, userMD UserMetadata) *prehogv1.DiscoverMetadata { - return &prehogv1.DiscoverMetadata{ +func discoverMetadataToPrehog(u *usageeventsv1.DiscoverMetadata, userMD UserMetadata) *prehogv1a.DiscoverMetadata { + return &prehogv1a.DiscoverMetadata{ Id: u.Id, UserName: userMD.Username, Sso: userMD.IsSSO, } } -func validateDiscoverMetadata(u *prehogv1.DiscoverMetadata) error { +func validateDiscoverMetadata(u *prehogv1a.DiscoverMetadata) error { if u == nil { return trace.BadParameter("metadata is required") } @@ -44,48 +44,48 @@ func validateDiscoverMetadata(u *prehogv1.DiscoverMetadata) error { return nil } -func discoverResourceToPrehog(u *usageeventsv1.DiscoverResourceMetadata) *prehogv1.DiscoverResourceMetadata { - return &prehogv1.DiscoverResourceMetadata{ - Resource: prehogv1.DiscoverResource(u.Resource), +func discoverResourceToPrehog(u *usageeventsv1.DiscoverResourceMetadata) *prehogv1a.DiscoverResourceMetadata { + return &prehogv1a.DiscoverResourceMetadata{ + Resource: prehogv1a.DiscoverResource(u.Resource), } } -func validateDiscoverResourceMetadata(u *prehogv1.DiscoverResourceMetadata) error { +func validateDiscoverResourceMetadata(u *prehogv1a.DiscoverResourceMetadata) error { if u == nil { return trace.BadParameter("resource is required") } - if u.Resource == prehogv1.DiscoverResource_DISCOVER_RESOURCE_UNSPECIFIED { + if u.Resource == prehogv1a.DiscoverResource_DISCOVER_RESOURCE_UNSPECIFIED { return trace.BadParameter("invalid resource") } return nil } -func discoverStatusToPrehog(u *usageeventsv1.DiscoverStepStatus) *prehogv1.DiscoverStepStatus { - return &prehogv1.DiscoverStepStatus{ - Status: prehogv1.DiscoverStatus(u.Status), +func discoverStatusToPrehog(u *usageeventsv1.DiscoverStepStatus) *prehogv1a.DiscoverStepStatus { + return &prehogv1a.DiscoverStepStatus{ + Status: prehogv1a.DiscoverStatus(u.Status), Error: u.Error, } } -func validateDiscoverStatus(u *prehogv1.DiscoverStepStatus) error { +func validateDiscoverStatus(u *prehogv1a.DiscoverStepStatus) error { if u == nil { return trace.BadParameter("status is required") } - if u.Status == prehogv1.DiscoverStatus_DISCOVER_STATUS_UNSPECIFIED { + if u.Status == prehogv1a.DiscoverStatus_DISCOVER_STATUS_UNSPECIFIED { return trace.BadParameter("invalid status.status") } - if u.Status == prehogv1.DiscoverStatus_DISCOVER_STATUS_ERROR && len(u.Error) == 0 { + if u.Status == prehogv1a.DiscoverStatus_DISCOVER_STATUS_ERROR && len(u.Error) == 0 { return trace.BadParameter("status.error is required when status.status is ERROR") } return nil } -func validateDiscoverBaseEventFields(md *prehogv1.DiscoverMetadata, res *prehogv1.DiscoverResourceMetadata, st *prehogv1.DiscoverStepStatus) error { +func validateDiscoverBaseEventFields(md *prehogv1a.DiscoverMetadata, res *prehogv1a.DiscoverResourceMetadata, st *prehogv1a.DiscoverStepStatus) error { if err := validateDiscoverMetadata(md); err != nil { return trace.Wrap(err) } @@ -102,7 +102,7 @@ func validateDiscoverBaseEventFields(md *prehogv1.DiscoverMetadata, res *prehogv } // UIDiscoverStartedEvent is a UI event sent when a user starts the Discover Wizard. -type UIDiscoverStartedEvent prehogv1.UIDiscoverStartedEvent +type UIDiscoverStartedEvent prehogv1a.UIDiscoverStartedEvent func (u *UIDiscoverStartedEvent) CheckAndSetDefaults() error { if err := validateDiscoverMetadata(u.Metadata); err != nil { @@ -115,11 +115,11 @@ func (u *UIDiscoverStartedEvent) CheckAndSetDefaults() error { return nil } -func (u *UIDiscoverStartedEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverStartedEvent{ - UiDiscoverStartedEvent: &prehogv1.UIDiscoverStartedEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverStartedEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverStartedEvent{ + UiDiscoverStartedEvent: &prehogv1a.UIDiscoverStartedEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), Sso: u.Metadata.Sso, @@ -131,17 +131,17 @@ func (u *UIDiscoverStartedEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEv } // UIDiscoverResourceSelectionEvent is a UI event sent when a user starts the Discover Wizard. -type UIDiscoverResourceSelectionEvent prehogv1.UIDiscoverResourceSelectionEvent +type UIDiscoverResourceSelectionEvent prehogv1a.UIDiscoverResourceSelectionEvent func (u *UIDiscoverResourceSelectionEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverResourceSelectionEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverResourceSelectionEvent{ - UiDiscoverResourceSelectionEvent: &prehogv1.UIDiscoverResourceSelectionEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverResourceSelectionEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverResourceSelectionEvent{ + UiDiscoverResourceSelectionEvent: &prehogv1a.UIDiscoverResourceSelectionEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -159,17 +159,17 @@ func (u *UIDiscoverResourceSelectionEvent) Anonymize(a utils.Anonymizer) prehogv // // For Database Access this step is the installation of the teleport 'install-db' script. // It can be skipped if the cluster already has a Database Service capable of proxying the database. -type UIDiscoverDeployServiceEvent prehogv1.UIDiscoverDeployServiceEvent +type UIDiscoverDeployServiceEvent prehogv1a.UIDiscoverDeployServiceEvent func (u *UIDiscoverDeployServiceEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverDeployServiceEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverDeployServiceEvent{ - UiDiscoverDeployServiceEvent: &prehogv1.UIDiscoverDeployServiceEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverDeployServiceEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverDeployServiceEvent{ + UiDiscoverDeployServiceEvent: &prehogv1a.UIDiscoverDeployServiceEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -182,17 +182,17 @@ func (u *UIDiscoverDeployServiceEvent) Anonymize(a utils.Anonymizer) prehogv1.Su // UIDiscoverDatabaseRegisterEvent is emitted when a user registers a database resource // and goes to the next step. -type UIDiscoverDatabaseRegisterEvent prehogv1.UIDiscoverDatabaseRegisterEvent +type UIDiscoverDatabaseRegisterEvent prehogv1a.UIDiscoverDatabaseRegisterEvent func (u *UIDiscoverDatabaseRegisterEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverDatabaseRegisterEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverDatabaseRegisterEvent{ - UiDiscoverDatabaseRegisterEvent: &prehogv1.UIDiscoverDatabaseRegisterEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverDatabaseRegisterEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverDatabaseRegisterEvent{ + UiDiscoverDatabaseRegisterEvent: &prehogv1a.UIDiscoverDatabaseRegisterEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -205,17 +205,17 @@ func (u *UIDiscoverDatabaseRegisterEvent) Anonymize(a utils.Anonymizer) prehogv1 // UIDiscoverDatabaseConfigureMTLSEvent is emitted when a user configures mutual TLS for self-hosted database // and goes to the next step. -type UIDiscoverDatabaseConfigureMTLSEvent prehogv1.UIDiscoverDatabaseConfigureMTLSEvent +type UIDiscoverDatabaseConfigureMTLSEvent prehogv1a.UIDiscoverDatabaseConfigureMTLSEvent func (u *UIDiscoverDatabaseConfigureMTLSEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverDatabaseConfigureMTLSEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverDatabaseConfigureMtlsEvent{ - UiDiscoverDatabaseConfigureMtlsEvent: &prehogv1.UIDiscoverDatabaseConfigureMTLSEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverDatabaseConfigureMTLSEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverDatabaseConfigureMtlsEvent{ + UiDiscoverDatabaseConfigureMtlsEvent: &prehogv1a.UIDiscoverDatabaseConfigureMTLSEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -228,17 +228,17 @@ func (u *UIDiscoverDatabaseConfigureMTLSEvent) Anonymize(a utils.Anonymizer) pre // UIDiscoverDesktopActiveDirectoryToolsInstallEvent is emitted when the user is asked to run the install Active Directory tools script. // This happens on the Desktop flow. -type UIDiscoverDesktopActiveDirectoryToolsInstallEvent prehogv1.UIDiscoverDesktopActiveDirectoryToolsInstallEvent +type UIDiscoverDesktopActiveDirectoryToolsInstallEvent prehogv1a.UIDiscoverDesktopActiveDirectoryToolsInstallEvent func (u *UIDiscoverDesktopActiveDirectoryToolsInstallEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverDesktopActiveDirectoryToolsInstallEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverDesktopActiveDirectoryToolsInstallEvent{ - UiDiscoverDesktopActiveDirectoryToolsInstallEvent: &prehogv1.UIDiscoverDesktopActiveDirectoryToolsInstallEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverDesktopActiveDirectoryToolsInstallEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverDesktopActiveDirectoryToolsInstallEvent{ + UiDiscoverDesktopActiveDirectoryToolsInstallEvent: &prehogv1a.UIDiscoverDesktopActiveDirectoryToolsInstallEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -251,17 +251,17 @@ func (u *UIDiscoverDesktopActiveDirectoryToolsInstallEvent) Anonymize(a utils.An // UIDiscoverDesktopActiveDirectoryConfigureEvent is emitted when the user is asked to run the Configure Active Directory script. // This happens on the Desktop flow. -type UIDiscoverDesktopActiveDirectoryConfigureEvent prehogv1.UIDiscoverDesktopActiveDirectoryConfigureEvent +type UIDiscoverDesktopActiveDirectoryConfigureEvent prehogv1a.UIDiscoverDesktopActiveDirectoryConfigureEvent func (u *UIDiscoverDesktopActiveDirectoryConfigureEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverDesktopActiveDirectoryConfigureEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverDesktopActiveDirectoryConfigureEvent{ - UiDiscoverDesktopActiveDirectoryConfigureEvent: &prehogv1.UIDiscoverDesktopActiveDirectoryConfigureEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverDesktopActiveDirectoryConfigureEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverDesktopActiveDirectoryConfigureEvent{ + UiDiscoverDesktopActiveDirectoryConfigureEvent: &prehogv1a.UIDiscoverDesktopActiveDirectoryConfigureEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -274,7 +274,7 @@ func (u *UIDiscoverDesktopActiveDirectoryConfigureEvent) Anonymize(a utils.Anony // UIDiscoverAutoDiscoveredResourcesEvent is emitted when the user is presented with the list of auto discovered resources. // resources_count field must contain the number of discovered resources when the user leaves the screen. -type UIDiscoverAutoDiscoveredResourcesEvent prehogv1.UIDiscoverAutoDiscoveredResourcesEvent +type UIDiscoverAutoDiscoveredResourcesEvent prehogv1a.UIDiscoverAutoDiscoveredResourcesEvent func (u *UIDiscoverAutoDiscoveredResourcesEvent) CheckAndSetDefaults() error { if u.ResourcesCount < 0 { @@ -283,11 +283,11 @@ func (u *UIDiscoverAutoDiscoveredResourcesEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverAutoDiscoveredResourcesEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverAutoDiscoveredResourcesEvent{ - UiDiscoverAutoDiscoveredResourcesEvent: &prehogv1.UIDiscoverAutoDiscoveredResourcesEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverAutoDiscoveredResourcesEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverAutoDiscoveredResourcesEvent{ + UiDiscoverAutoDiscoveredResourcesEvent: &prehogv1a.UIDiscoverAutoDiscoveredResourcesEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -301,17 +301,17 @@ func (u *UIDiscoverAutoDiscoveredResourcesEvent) Anonymize(a utils.Anonymizer) p // UIDiscoverDatabaseConfigureIAMPolicyEvent is emitted when a user configured IAM for RDS database // and proceeded to the next step. -type UIDiscoverDatabaseConfigureIAMPolicyEvent prehogv1.UIDiscoverDatabaseConfigureIAMPolicyEvent +type UIDiscoverDatabaseConfigureIAMPolicyEvent prehogv1a.UIDiscoverDatabaseConfigureIAMPolicyEvent func (u *UIDiscoverDatabaseConfigureIAMPolicyEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverDatabaseConfigureIAMPolicyEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverDatabaseConfigureIamPolicyEvent{ - UiDiscoverDatabaseConfigureIamPolicyEvent: &prehogv1.UIDiscoverDatabaseConfigureIAMPolicyEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverDatabaseConfigureIAMPolicyEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverDatabaseConfigureIamPolicyEvent{ + UiDiscoverDatabaseConfigureIamPolicyEvent: &prehogv1a.UIDiscoverDatabaseConfigureIAMPolicyEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -324,17 +324,17 @@ func (u *UIDiscoverDatabaseConfigureIAMPolicyEvent) Anonymize(a utils.Anonymizer // UIDiscoverPrincipalsConfigureEvent emitted on "Setup Access" screen when user has updated their principals // and proceeded to the next step. -type UIDiscoverPrincipalsConfigureEvent prehogv1.UIDiscoverPrincipalsConfigureEvent +type UIDiscoverPrincipalsConfigureEvent prehogv1a.UIDiscoverPrincipalsConfigureEvent func (u *UIDiscoverPrincipalsConfigureEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverPrincipalsConfigureEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverPrincipalsConfigureEvent{ - UiDiscoverPrincipalsConfigureEvent: &prehogv1.UIDiscoverPrincipalsConfigureEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverPrincipalsConfigureEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverPrincipalsConfigureEvent{ + UiDiscoverPrincipalsConfigureEvent: &prehogv1a.UIDiscoverPrincipalsConfigureEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -347,17 +347,17 @@ func (u *UIDiscoverPrincipalsConfigureEvent) Anonymize(a utils.Anonymizer) preho // UIDiscoverTestConnectionEvent emitted on the "Test Connection" screen // when the user clicked tested connection to their resource. -type UIDiscoverTestConnectionEvent prehogv1.UIDiscoverTestConnectionEvent +type UIDiscoverTestConnectionEvent prehogv1a.UIDiscoverTestConnectionEvent func (u *UIDiscoverTestConnectionEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverTestConnectionEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverTestConnectionEvent{ - UiDiscoverTestConnectionEvent: &prehogv1.UIDiscoverTestConnectionEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverTestConnectionEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverTestConnectionEvent{ + UiDiscoverTestConnectionEvent: &prehogv1a.UIDiscoverTestConnectionEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, @@ -369,17 +369,17 @@ func (u *UIDiscoverTestConnectionEvent) Anonymize(a utils.Anonymizer) prehogv1.S } // UIDiscoverCompletedEvent is emitted when user completes the Discover wizard. -type UIDiscoverCompletedEvent prehogv1.UIDiscoverCompletedEvent +type UIDiscoverCompletedEvent prehogv1a.UIDiscoverCompletedEvent func (u *UIDiscoverCompletedEvent) CheckAndSetDefaults() error { return trace.Wrap(validateDiscoverBaseEventFields(u.Metadata, u.Resource, u.Status)) } -func (u *UIDiscoverCompletedEvent) Anonymize(a utils.Anonymizer) prehogv1.SubmitEventRequest { - return prehogv1.SubmitEventRequest{ - Event: &prehogv1.SubmitEventRequest_UiDiscoverCompletedEvent{ - UiDiscoverCompletedEvent: &prehogv1.UIDiscoverCompletedEvent{ - Metadata: &prehogv1.DiscoverMetadata{ +func (u *UIDiscoverCompletedEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest { + return prehogv1a.SubmitEventRequest{ + Event: &prehogv1a.SubmitEventRequest_UiDiscoverCompletedEvent{ + UiDiscoverCompletedEvent: &prehogv1a.UIDiscoverCompletedEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: u.Metadata.Id, UserName: a.AnonymizeString(u.Metadata.UserName), }, diff --git a/lib/usagereporter/teleport/usagereporter.go b/lib/usagereporter/teleport/usagereporter.go index 8a149242b1ab3..a9507d7ef0547 100644 --- a/lib/usagereporter/teleport/usagereporter.go +++ b/lib/usagereporter/teleport/usagereporter.go @@ -30,8 +30,8 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "github.com/gravitational/teleport/api/types" - prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" - prehogv1c "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha/v1alphaconnect" + prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" + prehogv1ac "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect" "github.com/gravitational/teleport/lib/defaults" "github.com/gravitational/teleport/lib/observability/metrics" "github.com/gravitational/teleport/lib/usagereporter" @@ -74,11 +74,25 @@ type UsageReporter interface { AnonymizeAndSubmit(event ...Anonymizable) } -// TeleportUsageReporter submits Teleport usage events -// anonymized with the cluster name. -type TeleportUsageReporter struct { +// GracefulStopper is a UsageReporter that needs to do some work before +// stopping; this is a separate interface because [UsageReporter] is embedded in +// auth.Server.Services, and we don't want to expose extraneous methods as part +// of auth.Server. +type GracefulStopper interface { + UsageReporter + + // GracefulStop gracefully closes and runs any finalization needed by the + // UsageReporter; operations can run as long as the context is alive, but + // must terminate quickly (even losing data) if the context is closed. + // Returns nil if operations have completed cleanly. + GracefulStop(context.Context) error +} + +// StreamingUsageReporter submits all Teleport usage events anonymized with the +// cluster name, with a very short buffer for batches and no persistency. +type StreamingUsageReporter struct { // usageReporter is an actual reporter that batches and sends events - usageReporter *usagereporter.UsageReporter[prehogv1.SubmitEventRequest] + usageReporter *usagereporter.UsageReporter[prehogv1a.SubmitEventRequest] // anonymizer is the anonymizer used for filtered audit events. anonymizer utils.Anonymizer // clusterName is the cluster's name, used for anonymization and as an event @@ -87,9 +101,9 @@ type TeleportUsageReporter struct { clock clockwork.Clock } -var _ UsageReporter = (*TeleportUsageReporter)(nil) +var _ UsageReporter = (*StreamingUsageReporter)(nil) -func (t *TeleportUsageReporter) AnonymizeAndSubmit(events ...Anonymizable) { +func (t *StreamingUsageReporter) AnonymizeAndSubmit(events ...Anonymizable) { for _, e := range events { req := e.Anonymize(t.anonymizer) req.Timestamp = timestamppb.New(t.clock.Now()) @@ -98,13 +112,18 @@ func (t *TeleportUsageReporter) AnonymizeAndSubmit(events ...Anonymizable) { } } -func (t *TeleportUsageReporter) Run(ctx context.Context) { +func (t *StreamingUsageReporter) Run(ctx context.Context) { t.usageReporter.Run(ctx) } -type SubmitFunc = usagereporter.SubmitFunc[prehogv1.SubmitEventRequest] +type SubmitFunc = usagereporter.SubmitFunc[prehogv1a.SubmitEventRequest] + +// TODO(espadolini): change the call in e/lib/prehog/prehog.go:InitPreHogUsageReporting +func NewTeleportUsageReporter(log logrus.FieldLogger, clusterName types.ClusterName, submitter SubmitFunc) (*StreamingUsageReporter, error) { + return NewStreamingUsageReporter(log, clusterName, submitter) +} -func NewTeleportUsageReporter(log logrus.FieldLogger, clusterName types.ClusterName, submitter SubmitFunc) (*TeleportUsageReporter, error) { +func NewStreamingUsageReporter(log logrus.FieldLogger, clusterName types.ClusterName, submitter SubmitFunc) (*StreamingUsageReporter, error) { if log == nil { log = logrus.StandardLogger() } @@ -121,7 +140,7 @@ func NewTeleportUsageReporter(log logrus.FieldLogger, clusterName types.ClusterN clock := clockwork.NewRealClock() - reporter := usagereporter.NewUsageReporter(&usagereporter.Options[prehogv1.SubmitEventRequest]{ + reporter := usagereporter.NewUsageReporter(&usagereporter.Options[prehogv1a.SubmitEventRequest]{ Log: log, Submit: submitter, MinBatchSize: usageReporterMinBatchSize, @@ -133,7 +152,7 @@ func NewTeleportUsageReporter(log logrus.FieldLogger, clusterName types.ClusterN Clock: clock, }) - return &TeleportUsageReporter{ + return &StreamingUsageReporter{ usageReporter: reporter, anonymizer: anonymizer, clusterName: clusterName, @@ -177,15 +196,15 @@ func NewPrehogSubmitter(ctx context.Context, prehogEndpoint string, clientCert * } httpClient.Timeout = 5 * time.Second - client := prehogv1c.NewTeleportReportingServiceClient(httpClient, prehogEndpoint) + client := prehogv1ac.NewTeleportReportingServiceClient(httpClient, prehogEndpoint) - return func(reporter *usagereporter.UsageReporter[prehogv1.SubmitEventRequest], events []*usagereporter.SubmittedEvent[prehogv1.SubmitEventRequest]) ([]*usagereporter.SubmittedEvent[prehogv1.SubmitEventRequest], error) { - evs := make([]*prehogv1.SubmitEventRequest, 0, len(events)) + return func(reporter *usagereporter.UsageReporter[prehogv1a.SubmitEventRequest], events []*usagereporter.SubmittedEvent[prehogv1a.SubmitEventRequest]) ([]*usagereporter.SubmittedEvent[prehogv1a.SubmitEventRequest], error) { + evs := make([]*prehogv1a.SubmitEventRequest, 0, len(events)) for _, e := range events { evs = append(evs, e.Event) } - req := connect.NewRequest(&prehogv1.SubmitEventsRequest{ + req := connect.NewRequest(&prehogv1a.SubmitEventsRequest{ Events: evs, }) if _, err := client.SubmitEvents(ctx, req); err != nil { @@ -201,6 +220,7 @@ type DiscardUsageReporter struct{} var _ UsageReporter = DiscardUsageReporter{} +// AnonymizeAndSubmit implements [UsageReporter] func (DiscardUsageReporter) AnonymizeAndSubmit(...Anonymizable) { // do nothing } diff --git a/lib/usagereporter/teleport/usagereporter_test.go b/lib/usagereporter/teleport/usagereporter_test.go index b2d42aa828174..837fb984b6b43 100644 --- a/lib/usagereporter/teleport/usagereporter_test.go +++ b/lib/usagereporter/teleport/usagereporter_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/require" usageeventsv1 "github.com/gravitational/teleport/api/gen/proto/go/usageevents/v1" - prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" + prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" "github.com/gravitational/teleport/lib/utils" ) @@ -37,7 +37,7 @@ func TestConvertUsageEvent(t *testing.T) { identityUsername string isSSOUser bool errCheck require.ErrorAssertionFunc - expected *prehogv1.SubmitEventRequest + expected *prehogv1a.SubmitEventRequest }{ { name: "discover started event", @@ -49,14 +49,14 @@ func TestConvertUsageEvent(t *testing.T) { }}, identityUsername: "myuser", errCheck: require.NoError, - expected: &prehogv1.SubmitEventRequest{Event: &prehogv1.SubmitEventRequest_UiDiscoverStartedEvent{ - UiDiscoverStartedEvent: &prehogv1.UIDiscoverStartedEvent{ - Metadata: &prehogv1.DiscoverMetadata{ + expected: &prehogv1a.SubmitEventRequest{Event: &prehogv1a.SubmitEventRequest_UiDiscoverStartedEvent{ + UiDiscoverStartedEvent: &prehogv1a.UIDiscoverStartedEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: "someid", UserName: expectedAnonymizedUserString, Sso: false, }, - Status: &prehogv1.DiscoverStepStatus{Status: prehogv1.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, + Status: &prehogv1a.DiscoverStepStatus{Status: prehogv1a.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, }, }}, }, @@ -71,15 +71,15 @@ func TestConvertUsageEvent(t *testing.T) { }}, identityUsername: "myuser", errCheck: require.NoError, - expected: &prehogv1.SubmitEventRequest{Event: &prehogv1.SubmitEventRequest_UiDiscoverResourceSelectionEvent{ - UiDiscoverResourceSelectionEvent: &prehogv1.UIDiscoverResourceSelectionEvent{ - Metadata: &prehogv1.DiscoverMetadata{ + expected: &prehogv1a.SubmitEventRequest{Event: &prehogv1a.SubmitEventRequest_UiDiscoverResourceSelectionEvent{ + UiDiscoverResourceSelectionEvent: &prehogv1a.UIDiscoverResourceSelectionEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: "someid", UserName: expectedAnonymizedUserString, Sso: false, }, - Resource: &prehogv1.DiscoverResourceMetadata{Resource: prehogv1.DiscoverResource_DISCOVER_RESOURCE_SERVER}, - Status: &prehogv1.DiscoverStepStatus{Status: prehogv1.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, + Resource: &prehogv1a.DiscoverResourceMetadata{Resource: prehogv1a.DiscoverResource_DISCOVER_RESOURCE_SERVER}, + Status: &prehogv1a.DiscoverStepStatus{Status: prehogv1a.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, }, }}, }, @@ -137,15 +137,15 @@ func TestConvertUsageEvent(t *testing.T) { }}, identityUsername: "myuser", errCheck: require.NoError, - expected: &prehogv1.SubmitEventRequest{Event: &prehogv1.SubmitEventRequest_UiDiscoverAutoDiscoveredResourcesEvent{ - UiDiscoverAutoDiscoveredResourcesEvent: &prehogv1.UIDiscoverAutoDiscoveredResourcesEvent{ - Metadata: &prehogv1.DiscoverMetadata{ + expected: &prehogv1a.SubmitEventRequest{Event: &prehogv1a.SubmitEventRequest_UiDiscoverAutoDiscoveredResourcesEvent{ + UiDiscoverAutoDiscoveredResourcesEvent: &prehogv1a.UIDiscoverAutoDiscoveredResourcesEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: "someid", UserName: expectedAnonymizedUserString, Sso: false, }, - Resource: &prehogv1.DiscoverResourceMetadata{Resource: prehogv1.DiscoverResource_DISCOVER_RESOURCE_SERVER}, - Status: &prehogv1.DiscoverStepStatus{Status: prehogv1.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, + Resource: &prehogv1a.DiscoverResourceMetadata{Resource: prehogv1a.DiscoverResource_DISCOVER_RESOURCE_SERVER}, + Status: &prehogv1a.DiscoverStepStatus{Status: prehogv1a.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, ResourcesCount: 0, }, }}, @@ -162,15 +162,15 @@ func TestConvertUsageEvent(t *testing.T) { }}, identityUsername: "myuser", errCheck: require.NoError, - expected: &prehogv1.SubmitEventRequest{Event: &prehogv1.SubmitEventRequest_UiDiscoverAutoDiscoveredResourcesEvent{ - UiDiscoverAutoDiscoveredResourcesEvent: &prehogv1.UIDiscoverAutoDiscoveredResourcesEvent{ - Metadata: &prehogv1.DiscoverMetadata{ + expected: &prehogv1a.SubmitEventRequest{Event: &prehogv1a.SubmitEventRequest_UiDiscoverAutoDiscoveredResourcesEvent{ + UiDiscoverAutoDiscoveredResourcesEvent: &prehogv1a.UIDiscoverAutoDiscoveredResourcesEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: "someid", UserName: expectedAnonymizedUserString, Sso: false, }, - Resource: &prehogv1.DiscoverResourceMetadata{Resource: prehogv1.DiscoverResource_DISCOVER_RESOURCE_SERVER}, - Status: &prehogv1.DiscoverStepStatus{Status: prehogv1.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, + Resource: &prehogv1a.DiscoverResourceMetadata{Resource: prehogv1a.DiscoverResource_DISCOVER_RESOURCE_SERVER}, + Status: &prehogv1a.DiscoverStepStatus{Status: prehogv1a.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, ResourcesCount: 2, }, }}, @@ -189,7 +189,8 @@ func TestConvertUsageEvent(t *testing.T) { errCheck: func(tt require.TestingT, err error, i ...interface{}) { require.True(tt, trace.IsBadParameter(err), "exepcted trace.IsBadParameter error, got: %v", err) }, - }, { + }, + { name: "discover started event with sso user", event: &usageeventsv1.UsageEventOneOf{Event: &usageeventsv1.UsageEventOneOf_UiDiscoverStartedEvent{ UiDiscoverStartedEvent: &usageeventsv1.UIDiscoverStartedEvent{ @@ -200,14 +201,14 @@ func TestConvertUsageEvent(t *testing.T) { identityUsername: "myuser", isSSOUser: true, errCheck: require.NoError, - expected: &prehogv1.SubmitEventRequest{Event: &prehogv1.SubmitEventRequest_UiDiscoverStartedEvent{ - UiDiscoverStartedEvent: &prehogv1.UIDiscoverStartedEvent{ - Metadata: &prehogv1.DiscoverMetadata{ + expected: &prehogv1a.SubmitEventRequest{Event: &prehogv1a.SubmitEventRequest_UiDiscoverStartedEvent{ + UiDiscoverStartedEvent: &prehogv1a.UIDiscoverStartedEvent{ + Metadata: &prehogv1a.DiscoverMetadata{ Id: "someid", UserName: expectedAnonymizedUserString, Sso: true, }, - Status: &prehogv1.DiscoverStepStatus{Status: prehogv1.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, + Status: &prehogv1a.DiscoverStepStatus{Status: prehogv1a.DiscoverStatus_DISCOVER_STATUS_SUCCESS}, }, }}, }, diff --git a/proto/prehog/v1/teleport.proto b/proto/prehog/v1/teleport.proto new file mode 100644 index 0000000000000..b868f4cb693cd --- /dev/null +++ b/proto/prehog/v1/teleport.proto @@ -0,0 +1,76 @@ +// Copyright 2023 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package prehog.v1; + +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1;prehogv1"; + +message UserActivityReport { + // randomly generated UUID for this specific report, 16 bytes (in string order) + bytes report_uuid = 1; + // anonymized, 32 bytes (HMAC-SHA-256) + bytes cluster_name = 2; + // anonymized, 32 bytes (HMAC-SHA-256) + bytes reporter_hostid = 3; + // beginning of the time window for this data; ending is not specified but is + // intended to be at most 15 minutes + google.protobuf.Timestamp start_time = 4; + + repeated UserActivityRecord records = 5; +} + +message UserActivityRecord { + // anonymized, 32 bytes (HMAC-SHA-256) + bytes user_name = 1; + + // counter of user.login events + uint64 logins = 2; + + // counter of session.start events (non-Kube) + uint64 ssh_sessions = 3; + // counter of app.session.start events (non-TCP) + uint64 app_sessions = 4; + // counter of session.start events (only Kube) + uint64 kube_sessions = 5; + // counter of db.session.start events + uint64 db_sessions = 6; + // counter of windows.desktop.session.start events + uint64 desktop_sessions = 7; + // counter of app.session.start events (only TCP) + uint64 app_tcp_sessions = 8; + // counter of port events + uint64 ssh_port_sessions = 9; + + // counter of kube.request events + uint64 kube_requests = 10; + // counter of sftp events + uint64 sftp_events = 11; +} + +message SubmitUsageReportsRequest { + // at most 10 in a single RPC, each shouldn't exceed 128KiB or so + repeated UserActivityReport user_activity = 1; +} +message SubmitUsageReportsResponse { + // randomly generated UUID for this specific batch, 16 bytes (in string order) + bytes batch_uuid = 1; +} + +service TeleportReportingService { + rpc SubmitUsageReports(SubmitUsageReportsRequest) returns (SubmitUsageReportsResponse) {} +} diff --git a/proto/prehog/v1alpha/connect.proto b/proto/prehog/v1alpha/connect.proto index 36237c4b67f2d..835432afafa1e 100644 --- a/proto/prehog/v1alpha/connect.proto +++ b/proto/prehog/v1alpha/connect.proto @@ -18,7 +18,7 @@ package prehog.v1alpha; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha"; +option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha"; message ConnectClusterLoginEvent { // anonymized diff --git a/proto/prehog/v1alpha/tbot.proto b/proto/prehog/v1alpha/tbot.proto index 4bf533f97f37a..1eaeeec1bce1c 100644 --- a/proto/prehog/v1alpha/tbot.proto +++ b/proto/prehog/v1alpha/tbot.proto @@ -18,7 +18,7 @@ package prehog.v1alpha; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha"; +option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha"; // TbotStartEvent is triggered whenever tbot starts, regardless of whether tbot // was able to successfully connect to or authenticate with a Teleport cluster. diff --git a/proto/prehog/v1alpha/teleport.proto b/proto/prehog/v1alpha/teleport.proto index 67d60af77fd81..de191b3a425e0 100644 --- a/proto/prehog/v1alpha/teleport.proto +++ b/proto/prehog/v1alpha/teleport.proto @@ -19,7 +19,7 @@ package prehog.v1alpha; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha"; +option go_package = "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha;prehogv1alpha"; message UserLoginEvent { // anonymized diff --git a/tool/tbot/anonymous_telemetry.go b/tool/tbot/anonymous_telemetry.go index ba184b53ea636..6a00317a883cf 100644 --- a/tool/tbot/anonymous_telemetry.go +++ b/tool/tbot/anonymous_telemetry.go @@ -28,8 +28,8 @@ import ( "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/types" - prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" - prehogv1c "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha/v1alphaconnect" + prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" + prehogv1ac "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha/prehogv1alphaconnect" "github.com/gravitational/teleport/lib/tbot/config" ) @@ -54,7 +54,7 @@ func telemetryEnabled(envGetter envGetter) bool { return false } -func telemetryClient(envGetter envGetter) prehogv1c.TbotReportingServiceClient { +func telemetryClient(envGetter envGetter) prehogv1ac.TbotReportingServiceClient { // Override the default value using TELEPORT_ANONYMOUS_TELEMETRY_ADDRESS // environment variable. // staging: https://reporting-tbot-staging.teleportinfra.dev @@ -63,7 +63,7 @@ func telemetryClient(envGetter envGetter) prehogv1c.TbotReportingServiceClient { endpoint = env } - return prehogv1c.NewTbotReportingServiceClient( + return prehogv1ac.NewTbotReportingServiceClient( http.DefaultClient, endpoint, ) } @@ -73,7 +73,7 @@ func telemetryClient(envGetter envGetter) prehogv1c.TbotReportingServiceClient { // identifiable information. func sendTelemetry( ctx context.Context, - client prehogv1c.TbotReportingServiceClient, + client prehogv1ac.TbotReportingServiceClient, envGetter envGetter, log logrus.FieldLogger, cfg *config.BotConfig, @@ -85,8 +85,8 @@ func sendTelemetry( } log.Infof("Anonymous telemetry is enabled. Find out more about Machine ID's anonymous telemetry at %s", telemetryDocs) - data := &prehogv1.TbotStartEvent{ - RunMode: prehogv1.TbotStartEvent_RUN_MODE_DAEMON, + data := &prehogv1a.TbotStartEvent{ + RunMode: prehogv1a.TbotStartEvent_RUN_MODE_DAEMON, // Default to reporting the "token" join method to account for // scenarios where initial join has onboarding configured but future // starts renew using credentials. @@ -94,7 +94,7 @@ func sendTelemetry( Version: teleport.Version, } if cfg.Oneshot { - data.RunMode = prehogv1.TbotStartEvent_RUN_MODE_ONE_SHOT + data.RunMode = prehogv1a.TbotStartEvent_RUN_MODE_ONE_SHOT } if helper := envGetter(helperEnv); helper != "" { data.Helper = helper @@ -117,10 +117,10 @@ func sendTelemetry( } distinctID := uuid.New().String() - _, err := client.SubmitTbotEvent(ctx, connect.NewRequest(&prehogv1.SubmitTbotEventRequest{ + _, err := client.SubmitTbotEvent(ctx, connect.NewRequest(&prehogv1a.SubmitTbotEventRequest{ DistinctId: distinctID, Timestamp: timestamppb.New(start), - Event: &prehogv1.SubmitTbotEventRequest_Start{Start: data}, + Event: &prehogv1a.SubmitTbotEventRequest_Start{Start: data}, })) if err != nil { return trace.Wrap(err) diff --git a/tool/tbot/anonymous_telemetry_test.go b/tool/tbot/anonymous_telemetry_test.go index d7cc8d040556a..81d3fc1731c55 100644 --- a/tool/tbot/anonymous_telemetry_test.go +++ b/tool/tbot/anonymous_telemetry_test.go @@ -23,21 +23,21 @@ import ( "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/types" - prehogv1 "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" + prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha" "github.com/gravitational/teleport/lib/tbot/config" "github.com/gravitational/teleport/lib/utils" ) type mockReportingServiceClient struct { - eventRequest *prehogv1.SubmitTbotEventRequest + eventRequest *prehogv1a.SubmitTbotEventRequest } func (mrsc *mockReportingServiceClient) SubmitTbotEvent( ctx context.Context, - req *connect.Request[prehogv1.SubmitTbotEventRequest], -) (*connect.Response[prehogv1.SubmitTbotEventResponse], error) { + req *connect.Request[prehogv1a.SubmitTbotEventRequest], +) (*connect.Response[prehogv1a.SubmitTbotEventResponse], error) { mrsc.eventRequest = req.Msg - return connect.NewResponse(&prehogv1.SubmitTbotEventResponse{}), nil + return connect.NewResponse(&prehogv1a.SubmitTbotEventResponse{}), nil } func mockEnvGetter(data map[string]string) envGetter { @@ -105,9 +105,9 @@ func TestSendTelemetry(t *testing.T) { require.NotNil(t, mockClient.eventRequest) require.NotZero(t, mockClient.eventRequest.Timestamp) require.NotZero(t, mockClient.eventRequest.DistinctId) - require.Equal(t, &prehogv1.SubmitTbotEventRequest_Start{ - Start: &prehogv1.TbotStartEvent{ - RunMode: prehogv1.TbotStartEvent_RUN_MODE_ONE_SHOT, + require.Equal(t, &prehogv1a.SubmitTbotEventRequest_Start{ + Start: &prehogv1a.TbotStartEvent{ + RunMode: prehogv1a.TbotStartEvent_RUN_MODE_ONE_SHOT, JoinType: string(types.JoinMethodGitHub), Version: teleport.Version,