From 6968ddb5c9b7ed329a00a3c422f146dd03eb2c2d Mon Sep 17 00:00:00 2001 From: Christian Schaible Date: Tue, 16 Jul 2024 16:09:47 +0200 Subject: [PATCH] Add sequence number --- audit/api/api_common_test.go | 88 +++++++++ audit/api/test_data.go | 5 + gen/go/audit/v1/audit_event.pb.go | 214 +++++++++++---------- gen/go/audit/v1/audit_event.pb.validate.go | 29 +++ proto/audit/v1/audit_event.proto | 26 +-- 5 files changed, 254 insertions(+), 108 deletions(-) diff --git a/audit/api/api_common_test.go b/audit/api/api_common_test.go index 83bc648..84ff020 100644 --- a/audit/api/api_common_test.go +++ b/audit/api/api_common_test.go @@ -4,7 +4,10 @@ import ( "context" "errors" "fmt" + "google.golang.org/protobuf/types/known/timestamppb" + "google.golang.org/protobuf/types/known/wrapperspb" "testing" + "time" "dev.azure.com/schwarzit/schwarzit.stackit-core-platform/common-audit.git/audit/messaging" auditV1 "dev.azure.com/schwarzit/schwarzit.stackit-core-platform/common-audit.git/gen/go/audit/v1" @@ -60,6 +63,91 @@ func Test_ValidateAndSerializePartially_EventNil(t *testing.T) { assert.ErrorIs(t, err, ErrEventNil) } +func Test_ValidateAndSerializePartially_AuditEventSequenceNumber(t *testing.T) { + validator := NewValidator(t) + + t.Run("Sequence number too low", func(t *testing.T) { + event, routingIdentifier, objectIdentifier := NewOrganizationAuditEvent(nil) + event.SequenceNumber = wrapperspb.Int64(-2) + + _, err := validateAndSerializePartially( + &validator, event, auditV1.Visibility_VISIBILITY_PUBLIC, routingIdentifier, objectIdentifier) + + assert.EqualError(t, err, "validation error:\n - sequence_number: value must be greater than or equal to -1 [int64.gte]") + }) + + t.Run("Sequence number is minimum", func(t *testing.T) { + event, routingIdentifier, objectIdentifier := NewOrganizationAuditEvent(nil) + event.SequenceNumber = wrapperspb.Int64(-1) + + e, err := validateAndSerializePartially( + &validator, event, auditV1.Visibility_VISIBILITY_PUBLIC, routingIdentifier, objectIdentifier) + + assert.NoError(t, err) + validateSequenceNumber(t, e, -1) + }) + + t.Run("Sequence number is default", func(t *testing.T) { + event, routingIdentifier, objectIdentifier := NewOrganizationAuditEvent(nil) + event.SequenceNumber = wrapperspb.Int64(0) + + e, err := validateAndSerializePartially( + &validator, event, auditV1.Visibility_VISIBILITY_PUBLIC, routingIdentifier, objectIdentifier) + + assert.NoError(t, err) + validateSequenceNumber(t, e, 0) + }) + + t.Run("Sequence number is greater than default", func(t *testing.T) { + event, routingIdentifier, objectIdentifier := NewOrganizationAuditEvent(nil) + event.SequenceNumber = wrapperspb.Int64(1) + + e, err := validateAndSerializePartially( + &validator, event, auditV1.Visibility_VISIBILITY_PUBLIC, routingIdentifier, objectIdentifier) + + assert.NoError(t, err) + validateSequenceNumber(t, e, 1) + }) + + t.Run("Sequence number not set", func(t *testing.T) { + event := &auditV1.AuditEvent{ + EventName: "ORGANIZATION_CREATED", + EventTimeStamp: timestamppb.New(time.Now()), + EventTrigger: auditV1.EventTrigger_EVENT_TRIGGER_EVENT, + Initiator: &auditV1.Principal{ + Id: uuid.NewString(), + }, + } + + identifier := uuid.New() + routingIdentifier := &RoutingIdentifier{ + Identifier: identifier, + Type: RoutingIdentifierTypeOrganization, + } + + objectIdentifier := &auditV1.ObjectIdentifier{ + Identifier: identifier.String(), + Type: auditV1.ObjectType_OBJECT_TYPE_ORGANIZATION, + } + + _, err := validateAndSerializePartially( + &validator, event, auditV1.Visibility_VISIBILITY_PUBLIC, routingIdentifier, objectIdentifier) + + assert.EqualError(t, err, "validation error:\n - sequence_number: value is required [required]") + }) + +} +func validateSequenceNumber(t *testing.T, event *auditV1.RoutableAuditEvent, expectedNumber int64) { + switch data := event.GetData().(type) { + case *auditV1.RoutableAuditEvent_UnencryptedData: + var auditEvent auditV1.AuditEvent + assert.NoError(t, proto.Unmarshal(data.UnencryptedData.Data, &auditEvent)) + assert.Equal(t, expectedNumber, auditEvent.SequenceNumber.Value) + default: + assert.Fail(t, "expected unencrypted data") + } +} + func Test_ValidateAndSerializePartially_AuditEventValidationFailed(t *testing.T) { validator := NewValidator(t) diff --git a/audit/api/test_data.go b/audit/api/test_data.go index 0000e31..8758450 100644 --- a/audit/api/test_data.go +++ b/audit/api/test_data.go @@ -1,6 +1,7 @@ package api import ( + "google.golang.org/protobuf/types/known/wrapperspb" "time" auditV1 "dev.azure.com/schwarzit/schwarzit.stackit-core-platform/common-audit.git/gen/go/audit/v1" @@ -22,6 +23,7 @@ func NewOrganizationAuditEvent( ) { auditEvent := &auditV1.AuditEvent{ + SequenceNumber: wrapperspb.Int64(0), EventName: "ORGANIZATION_CREATED", EventTimeStamp: timestamppb.New(time.Now()), EventTrigger: auditV1.EventTrigger_EVENT_TRIGGER_EVENT, @@ -105,6 +107,7 @@ func NewFolderAuditEvent( ) { auditEvent := &auditV1.AuditEvent{ + SequenceNumber: wrapperspb.Int64(0), EventName: "FOLDER_CREATED", EventTimeStamp: timestamppb.New(time.Now()), EventTrigger: auditV1.EventTrigger_EVENT_TRIGGER_EVENT, @@ -142,6 +145,7 @@ func NewProjectAuditEvent( ) { auditEvent := &auditV1.AuditEvent{ + SequenceNumber: wrapperspb.Int64(0), EventName: "PROJECT_CREATED", EventTimeStamp: timestamppb.New(time.Now()), EventTrigger: auditV1.EventTrigger_EVENT_TRIGGER_EVENT, @@ -172,6 +176,7 @@ func NewSystemAuditEvent( customization *func(*auditV1.AuditEvent)) *auditV1.AuditEvent { auditEvent := &auditV1.AuditEvent{ + SequenceNumber: wrapperspb.Int64(0), EventName: "SYSTEM_CHANGED", EventTimeStamp: timestamppb.New(time.Now()), EventTrigger: auditV1.EventTrigger_EVENT_TRIGGER_EVENT, diff --git a/gen/go/audit/v1/audit_event.pb.go b/gen/go/audit/v1/audit_event.pb.go index ec93dd0..bd9a71e 100644 --- a/gen/go/audit/v1/audit_event.pb.go +++ b/gen/go/audit/v1/audit_event.pb.go @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" structpb "google.golang.org/protobuf/types/known/structpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) @@ -283,26 +284,28 @@ type AuditEvent struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // Sequence number of event sent by the service to identify missing events. + SequenceNumber *wrapperspb.Int64Value `protobuf:"bytes,1,opt,name=sequence_number,json=sequenceNumber,proto3" json:"sequence_number,omitempty"` // Functional event name with pattern _, e.g. ORGANIZATION_CREATED // Important for filtering and translation / verbalization of event types // in the UI or data sinks. - EventName string `protobuf:"bytes,1,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` + EventName string `protobuf:"bytes,2,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` // The time when the event happened. Must not be a value in the future. - EventTimeStamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=event_time_stamp,json=eventTimeStamp,proto3" json:"event_time_stamp,omitempty"` - EventTrigger EventTrigger `protobuf:"varint,3,opt,name=event_trigger,json=eventTrigger,proto3,enum=audit.v1.EventTrigger" json:"event_trigger,omitempty"` + EventTimeStamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=event_time_stamp,json=eventTimeStamp,proto3" json:"event_time_stamp,omitempty"` + EventTrigger EventTrigger `protobuf:"varint,4,opt,name=event_trigger,json=eventTrigger,proto3,enum=audit.v1.EventTrigger" json:"event_trigger,omitempty"` // Request details - mandatory if event_trigger is set to "EVENT_REQUEST" - Request *RequestDetails `protobuf:"bytes,4,opt,name=request,proto3,oneof" json:"request,omitempty"` - Initiator *Principal `protobuf:"bytes,5,opt,name=initiator,proto3" json:"initiator,omitempty"` + Request *RequestDetails `protobuf:"bytes,5,opt,name=request,proto3,oneof" json:"request,omitempty"` + Initiator *Principal `protobuf:"bytes,6,opt,name=initiator,proto3" json:"initiator,omitempty"` // List of service account delegation principals. // -> Chain from service account to the actual user who initiated the action. - Principals []*Principal `protobuf:"bytes,6,rep,name=principals,proto3" json:"principals,omitempty"` - ResourceId *string `protobuf:"bytes,7,opt,name=resource_id,json=resourceId,proto3,oneof" json:"resource_id,omitempty"` - ResourceName *string `protobuf:"bytes,8,opt,name=resource_name,json=resourceName,proto3,oneof" json:"resource_name,omitempty"` - CorrelationId *string `protobuf:"bytes,9,opt,name=correlation_id,json=correlationId,proto3,oneof" json:"correlation_id,omitempty"` + Principals []*Principal `protobuf:"bytes,7,rep,name=principals,proto3" json:"principals,omitempty"` + ResourceId *string `protobuf:"bytes,8,opt,name=resource_id,json=resourceId,proto3,oneof" json:"resource_id,omitempty"` + ResourceName *string `protobuf:"bytes,9,opt,name=resource_name,json=resourceName,proto3,oneof" json:"resource_name,omitempty"` + CorrelationId *string `protobuf:"bytes,10,opt,name=correlation_id,json=correlationId,proto3,oneof" json:"correlation_id,omitempty"` // Result of the operation to publish with the event - Result *structpb.Struct `protobuf:"bytes,10,opt,name=result,proto3,oneof" json:"result,omitempty"` + Result *structpb.Struct `protobuf:"bytes,11,opt,name=result,proto3,oneof" json:"result,omitempty"` // Additional information to publish with the event - Details *structpb.Struct `protobuf:"bytes,11,opt,name=details,proto3,oneof" json:"details,omitempty"` + Details *structpb.Struct `protobuf:"bytes,12,opt,name=details,proto3,oneof" json:"details,omitempty"` } func (x *AuditEvent) Reset() { @@ -337,6 +340,13 @@ func (*AuditEvent) Descriptor() ([]byte, []int) { return file_audit_v1_audit_event_proto_rawDescGZIP(), []int{3} } +func (x *AuditEvent) GetSequenceNumber() *wrapperspb.Int64Value { + if x != nil { + return x.SequenceNumber + } + return nil +} + func (x *AuditEvent) GetEventName() string { if x != nil { return x.EventName @@ -425,6 +435,8 @@ var file_audit_v1_audit_event_proto_rawDesc = []byte{ 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x54, 0x0a, 0x09, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x12, 0x16, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, @@ -458,79 +470,85 @@ var file_audit_v1_audit_event_proto_rawDesc = []byte{ 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xba, 0x48, 0x07, 0xc8, 0x01, 0x01, 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xba, 0x48, 0x07, 0xc8, 0x01, - 0x01, 0x72, 0x02, 0x10, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xf0, 0x06, 0x0a, - 0x0a, 0x41, 0x75, 0x64, 0x69, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x0a, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x19, 0xba, 0x48, 0x16, 0xc8, 0x01, 0x01, 0x72, 0x11, 0x32, 0x0f, 0x5e, 0x5b, 0x41, 0x2d, 0x5a, - 0x5d, 0x2b, 0x5f, 0x5b, 0x41, 0x2d, 0x5a, 0x5d, 0x2b, 0x24, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x51, 0x0a, 0x10, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 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, 0x42, 0x0b, 0xba, 0x48, 0x08, - 0xc8, 0x01, 0x01, 0xb2, 0x01, 0x02, 0x38, 0x01, 0x52, 0x0e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, - 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x48, 0x0a, 0x0d, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x16, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x42, 0x0b, 0xba, 0x48, 0x08, 0xc8, 0x01, 0x01, 0x82, - 0x01, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, - 0x65, 0x72, 0x12, 0x37, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x48, 0x00, 0x52, - 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x88, 0x01, 0x01, 0x12, 0x39, 0x0a, 0x09, 0x69, - 0x6e, 0x69, 0x74, 0x69, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, - 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, - 0x70, 0x61, 0x6c, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x09, 0x69, 0x6e, 0x69, - 0x74, 0x69, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, - 0x70, 0x61, 0x6c, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x61, 0x75, 0x64, - 0x69, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x52, - 0x0a, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x73, 0x12, 0x30, 0x0a, 0x0b, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x0a, 0xba, 0x48, 0x07, 0x72, 0x05, 0x10, 0x01, 0x18, 0xff, 0x01, 0x48, 0x01, 0x52, 0x0a, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x34, 0x0a, - 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xba, 0x48, 0x07, 0x72, 0x05, 0x10, 0x01, 0x18, 0xff, 0x01, - 0x48, 0x02, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, - 0x88, 0x01, 0x01, 0x12, 0x36, 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xba, 0x48, 0x07, - 0x72, 0x05, 0x10, 0x01, 0x18, 0xff, 0x01, 0x48, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x34, 0x0a, 0x06, 0x72, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, - 0x72, 0x75, 0x63, 0x74, 0x48, 0x04, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x88, 0x01, - 0x01, 0x12, 0x36, 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x05, 0x52, 0x07, 0x64, - 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x88, 0x01, 0x01, 0x3a, 0x7c, 0xba, 0x48, 0x79, 0x1a, 0x77, - 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x73, 0x12, 0x1b, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x20, 0x64, 0x65, 0x74, 0x61, 0x69, - 0x6c, 0x73, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x73, 0x65, 0x74, 0x1a, 0x47, - 0x74, 0x68, 0x69, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, - 0x65, 0x72, 0x20, 0x3d, 0x3d, 0x20, 0x33, 0x20, 0x26, 0x26, 0x20, 0x68, 0x61, 0x73, 0x28, 0x74, - 0x68, 0x69, 0x73, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x29, 0x20, 0x7c, 0x7c, 0x20, - 0x74, 0x68, 0x69, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, - 0x65, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x33, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x5f, 0x69, 0x64, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x72, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2a, - 0x7e, 0x0a, 0x0c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, - 0x1d, 0x0a, 0x19, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x52, 0x49, 0x47, 0x47, 0x45, 0x52, - 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, - 0x0a, 0x13, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x52, 0x49, 0x47, 0x47, 0x45, 0x52, 0x5f, - 0x45, 0x56, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x45, 0x56, 0x45, 0x4e, 0x54, - 0x5f, 0x54, 0x52, 0x49, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x53, 0x43, 0x48, 0x45, 0x44, 0x55, 0x4c, - 0x45, 0x52, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x52, - 0x49, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0x03, 0x42, - 0x81, 0x01, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x63, 0x68, 0x77, 0x61, 0x72, 0x7a, 0x2e, - 0x73, 0x74, 0x61, 0x63, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, - 0x42, 0x0f, 0x41, 0x75, 0x64, 0x69, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x0f, 0x2e, 0x2f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x3b, 0x61, 0x75, 0x64, - 0x69, 0x74, 0x56, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x41, 0x75, 0x64, - 0x69, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x5c, 0x56, 0x31, - 0xe2, 0x02, 0x14, 0x41, 0x75, 0x64, 0x69, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x41, 0x75, 0x64, 0x69, 0x74, 0x3a, - 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x72, 0x02, 0x10, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xcb, 0x07, 0x0a, + 0x0a, 0x41, 0x75, 0x64, 0x69, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x59, 0x0a, 0x0f, 0x73, + 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x42, 0x13, 0xba, 0x48, 0x10, 0xc8, 0x01, 0x01, 0x22, 0x0b, 0x28, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x52, 0x0e, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x38, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xba, 0x48, 0x16, 0xc8, + 0x01, 0x01, 0x72, 0x11, 0x32, 0x0f, 0x5e, 0x5b, 0x41, 0x2d, 0x5a, 0x5d, 0x2b, 0x5f, 0x5b, 0x41, + 0x2d, 0x5a, 0x5d, 0x2b, 0x24, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x51, 0x0a, 0x10, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 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, 0x42, 0x0b, 0xba, 0x48, 0x08, 0xc8, 0x01, 0x01, 0xb2, 0x01, + 0x02, 0x38, 0x01, 0x52, 0x0e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x48, 0x0a, 0x0d, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x72, 0x69, + 0x67, 0x67, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x61, 0x75, 0x64, + 0x69, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, + 0x65, 0x72, 0x42, 0x0b, 0xba, 0x48, 0x08, 0xc8, 0x01, 0x01, 0x82, 0x01, 0x02, 0x10, 0x01, 0x52, + 0x0c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x37, 0x0a, + 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x48, 0x00, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x88, 0x01, 0x01, 0x12, 0x39, 0x0a, 0x09, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, + 0x74, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x61, 0x75, 0x64, 0x69, + 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x42, 0x06, + 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x09, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x74, 0x6f, + 0x72, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x73, 0x18, + 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x6e, + 0x63, 0x69, 0x70, 0x61, 0x6c, 0x73, 0x12, 0x30, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xba, 0x48, 0x07, + 0x72, 0x05, 0x10, 0x01, 0x18, 0xff, 0x01, 0x48, 0x01, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x34, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x0a, 0xba, 0x48, 0x07, 0x72, 0x05, 0x10, 0x01, 0x18, 0xff, 0x01, 0x48, 0x02, 0x52, 0x0c, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x36, + 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xba, 0x48, 0x07, 0x72, 0x05, 0x10, 0x01, 0x18, + 0xff, 0x01, 0x48, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x34, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, + 0x04, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x88, 0x01, 0x01, 0x12, 0x36, 0x0a, 0x07, + 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x05, 0x52, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x73, 0x88, 0x01, 0x01, 0x3a, 0x7c, 0xba, 0x48, 0x79, 0x1a, 0x77, 0x0a, 0x0f, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x2e, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x1b, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x20, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x20, 0x6d, 0x75, + 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x73, 0x65, 0x74, 0x1a, 0x47, 0x74, 0x68, 0x69, 0x73, 0x2e, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x20, 0x3d, 0x3d, + 0x20, 0x33, 0x20, 0x26, 0x26, 0x20, 0x68, 0x61, 0x73, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x29, 0x20, 0x7c, 0x7c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x20, 0x21, 0x3d, + 0x20, 0x33, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x0e, + 0x0a, 0x0c, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x42, 0x10, + 0x0a, 0x0e, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x42, 0x0a, + 0x0a, 0x08, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2a, 0x7e, 0x0a, 0x0c, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x19, 0x45, 0x56, + 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x52, 0x49, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x56, 0x45, + 0x4e, 0x54, 0x5f, 0x54, 0x52, 0x49, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, + 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x52, 0x49, 0x47, + 0x47, 0x45, 0x52, 0x5f, 0x53, 0x43, 0x48, 0x45, 0x44, 0x55, 0x4c, 0x45, 0x52, 0x10, 0x02, 0x12, + 0x19, 0x0a, 0x15, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x52, 0x49, 0x47, 0x47, 0x45, 0x52, + 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0x03, 0x42, 0x81, 0x01, 0x0a, 0x1c, 0x63, + 0x6f, 0x6d, 0x2e, 0x73, 0x63, 0x68, 0x77, 0x61, 0x72, 0x7a, 0x2e, 0x73, 0x74, 0x61, 0x63, 0x6b, + 0x69, 0x74, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0f, 0x41, 0x75, 0x64, + 0x69, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x0f, + 0x2e, 0x2f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x3b, 0x61, 0x75, 0x64, 0x69, 0x74, 0x56, 0x31, 0xa2, + 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x56, 0x31, + 0xca, 0x02, 0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x41, 0x75, + 0x64, 0x69, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x09, 0x41, 0x75, 0x64, 0x69, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -554,24 +572,26 @@ var file_audit_v1_audit_event_proto_goTypes = []interface{}{ (*RequestHeader)(nil), // 3: audit.v1.RequestHeader (*AuditEvent)(nil), // 4: audit.v1.AuditEvent (*structpb.Struct)(nil), // 5: google.protobuf.Struct - (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp + (*wrapperspb.Int64Value)(nil), // 6: google.protobuf.Int64Value + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_audit_v1_audit_event_proto_depIdxs = []int32{ 5, // 0: audit.v1.RequestDetails.parameters:type_name -> google.protobuf.Struct 5, // 1: audit.v1.RequestDetails.body:type_name -> google.protobuf.Struct 3, // 2: audit.v1.RequestDetails.headers:type_name -> audit.v1.RequestHeader - 6, // 3: audit.v1.AuditEvent.event_time_stamp:type_name -> google.protobuf.Timestamp - 0, // 4: audit.v1.AuditEvent.event_trigger:type_name -> audit.v1.EventTrigger - 2, // 5: audit.v1.AuditEvent.request:type_name -> audit.v1.RequestDetails - 1, // 6: audit.v1.AuditEvent.initiator:type_name -> audit.v1.Principal - 1, // 7: audit.v1.AuditEvent.principals:type_name -> audit.v1.Principal - 5, // 8: audit.v1.AuditEvent.result:type_name -> google.protobuf.Struct - 5, // 9: audit.v1.AuditEvent.details:type_name -> google.protobuf.Struct - 10, // [10:10] is the sub-list for method output_type - 10, // [10:10] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 6, // 3: audit.v1.AuditEvent.sequence_number:type_name -> google.protobuf.Int64Value + 7, // 4: audit.v1.AuditEvent.event_time_stamp:type_name -> google.protobuf.Timestamp + 0, // 5: audit.v1.AuditEvent.event_trigger:type_name -> audit.v1.EventTrigger + 2, // 6: audit.v1.AuditEvent.request:type_name -> audit.v1.RequestDetails + 1, // 7: audit.v1.AuditEvent.initiator:type_name -> audit.v1.Principal + 1, // 8: audit.v1.AuditEvent.principals:type_name -> audit.v1.Principal + 5, // 9: audit.v1.AuditEvent.result:type_name -> google.protobuf.Struct + 5, // 10: audit.v1.AuditEvent.details:type_name -> google.protobuf.Struct + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_audit_v1_audit_event_proto_init() } diff --git a/gen/go/audit/v1/audit_event.pb.validate.go b/gen/go/audit/v1/audit_event.pb.validate.go index 188f021..ebf419c 100644 --- a/gen/go/audit/v1/audit_event.pb.validate.go +++ b/gen/go/audit/v1/audit_event.pb.validate.go @@ -474,6 +474,35 @@ func (m *AuditEvent) validate(all bool) error { var errors []error + if all { + switch v := interface{}(m.GetSequenceNumber()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AuditEventValidationError{ + field: "SequenceNumber", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AuditEventValidationError{ + field: "SequenceNumber", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSequenceNumber()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AuditEventValidationError{ + field: "SequenceNumber", + reason: "embedded message failed validation", + cause: err, + } + } + } + // no validation rules for EventName if all { diff --git a/proto/audit/v1/audit_event.proto b/proto/audit/v1/audit_event.proto index e529609..9bf33ba 100644 --- a/proto/audit/v1/audit_event.proto +++ b/proto/audit/v1/audit_event.proto @@ -3,6 +3,7 @@ syntax = "proto3"; import "buf/validate/validate.proto"; import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; package audit.v1; @@ -50,34 +51,37 @@ message AuditEvent { expression: "this.event_trigger == 3 && has(this.request) || this.event_trigger != 3" }; + // Sequence number of event sent by the service to identify missing events. + google.protobuf.Int64Value sequence_number = 1 [(buf.validate.field).required = true, (buf.validate.field).int64.gte = -1]; + // Functional event name with pattern _, e.g. ORGANIZATION_CREATED // Important for filtering and translation / verbalization of event types // in the UI or data sinks. - string event_name = 1 [(buf.validate.field).required = true, (buf.validate.field).string.pattern = "^[A-Z]+_[A-Z]+$"]; + string event_name = 2 [(buf.validate.field).required = true, (buf.validate.field).string.pattern = "^[A-Z]+_[A-Z]+$"]; // The time when the event happened. Must not be a value in the future. - google.protobuf.Timestamp event_time_stamp = 2 [(buf.validate.field).required = true, (buf.validate.field).timestamp.lt_now = true]; + google.protobuf.Timestamp event_time_stamp = 3 [(buf.validate.field).required = true, (buf.validate.field).timestamp.lt_now = true]; - EventTrigger event_trigger = 3 [(buf.validate.field).required = true, (buf.validate.field).enum.defined_only = true]; + EventTrigger event_trigger = 4 [(buf.validate.field).required = true, (buf.validate.field).enum.defined_only = true]; // Request details - mandatory if event_trigger is set to "EVENT_REQUEST" - optional RequestDetails request = 4; + optional RequestDetails request = 5; - Principal initiator = 5 [(buf.validate.field).required = true]; + Principal initiator = 6 [(buf.validate.field).required = true]; // List of service account delegation principals. // -> Chain from service account to the actual user who initiated the action. - repeated Principal principals = 6; + repeated Principal principals = 7; - optional string resource_id = 7 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 255]; + optional string resource_id = 8 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 255]; - optional string resource_name = 8 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 255]; + optional string resource_name = 9 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 255]; - optional string correlation_id = 9 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 255]; + optional string correlation_id = 10 [(buf.validate.field).string.min_len = 1, (buf.validate.field).string.max_len = 255]; // Result of the operation to publish with the event - optional google.protobuf.Struct result = 10; + optional google.protobuf.Struct result = 11; // Additional information to publish with the event - optional google.protobuf.Struct details = 11; + optional google.protobuf.Struct details = 12; } \ No newline at end of file