From 053ed58c080913384b09d84cdaa334acaf95f2f0 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Mon, 16 Nov 2026 13:45:12 +1100 Subject: [PATCH] feat(connectors): an extension declares the settings it reads, and each accepted package is listed (#2026) --- .../contracts/connector/v1/connector.pb.go | 487 +++++++++++++----- internal/contracts/guard/v1/guard.pb.go | 361 ++++++++++--- .../secretengine/v1/secretengine.pb.go | 340 ++++++++++-- .../secretengine/v1/secretengine_grpc.pb.go | 42 ++ modules/connectors/connector.go | 15 +- modules/connectors/credentials.go | 69 ++- modules/connectors/credentials_test.go | 71 +++ modules/connectors/engines.go | 29 +- modules/connectors/guards.go | 24 +- modules/connectors/list.go | 142 +++++ modules/connectors/mcp.go | 11 + modules/connectors/mcpaccept.go | 9 + modules/connectors/module.go | 17 + modules/connectors/remove_test.go | 7 +- modules/connectors/settings.go | 251 +++++++++ modules/judgement/extensions_test.go | 2 +- proto/connector/v1/connector.proto | 31 ++ proto/guard/v1/guard.proto | 29 ++ proto/secretengine/v1/secretengine.proto | 37 ++ 19 files changed, 1702 insertions(+), 272 deletions(-) create mode 100644 modules/connectors/credentials_test.go create mode 100644 modules/connectors/list.go create mode 100644 modules/connectors/settings.go diff --git a/internal/contracts/connector/v1/connector.pb.go b/internal/contracts/connector/v1/connector.pb.go index e39ffb46f..21711ada4 100644 --- a/internal/contracts/connector/v1/connector.pb.go +++ b/internal/contracts/connector/v1/connector.pb.go @@ -22,6 +22,70 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type SettingType int32 + +const ( + SettingType_SETTING_TYPE_UNSPECIFIED SettingType = 0 + SettingType_SETTING_TYPE_STRING SettingType = 1 + SettingType_SETTING_TYPE_NUMBER SettingType = 2 + SettingType_SETTING_TYPE_BOOLEAN SettingType = 3 + SettingType_SETTING_TYPE_DURATION SettingType = 4 + SettingType_SETTING_TYPE_LIST SettingType = 5 + SettingType_SETTING_TYPE_SELECT SettingType = 6 + SettingType_SETTING_TYPE_TEXT SettingType = 7 +) + +// Enum value maps for SettingType. +var ( + SettingType_name = map[int32]string{ + 0: "SETTING_TYPE_UNSPECIFIED", + 1: "SETTING_TYPE_STRING", + 2: "SETTING_TYPE_NUMBER", + 3: "SETTING_TYPE_BOOLEAN", + 4: "SETTING_TYPE_DURATION", + 5: "SETTING_TYPE_LIST", + 6: "SETTING_TYPE_SELECT", + 7: "SETTING_TYPE_TEXT", + } + SettingType_value = map[string]int32{ + "SETTING_TYPE_UNSPECIFIED": 0, + "SETTING_TYPE_STRING": 1, + "SETTING_TYPE_NUMBER": 2, + "SETTING_TYPE_BOOLEAN": 3, + "SETTING_TYPE_DURATION": 4, + "SETTING_TYPE_LIST": 5, + "SETTING_TYPE_SELECT": 6, + "SETTING_TYPE_TEXT": 7, + } +) + +func (x SettingType) Enum() *SettingType { + p := new(SettingType) + *p = x + return p +} + +func (x SettingType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SettingType) Descriptor() protoreflect.EnumDescriptor { + return file_connector_v1_connector_proto_enumTypes[0].Descriptor() +} + +func (SettingType) Type() protoreflect.EnumType { + return &file_connector_v1_connector_proto_enumTypes[0] +} + +func (x SettingType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SettingType.Descriptor instead. +func (SettingType) EnumDescriptor() ([]byte, []int) { + return file_connector_v1_connector_proto_rawDescGZIP(), []int{0} +} + type Reversibility int32 const ( @@ -61,11 +125,11 @@ func (x Reversibility) String() string { } func (Reversibility) Descriptor() protoreflect.EnumDescriptor { - return file_connector_v1_connector_proto_enumTypes[0].Descriptor() + return file_connector_v1_connector_proto_enumTypes[1].Descriptor() } func (Reversibility) Type() protoreflect.EnumType { - return &file_connector_v1_connector_proto_enumTypes[0] + return &file_connector_v1_connector_proto_enumTypes[1] } func (x Reversibility) Number() protoreflect.EnumNumber { @@ -74,7 +138,7 @@ func (x Reversibility) Number() protoreflect.EnumNumber { // Deprecated: Use Reversibility.Descriptor instead. func (Reversibility) EnumDescriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{0} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{1} } type ConfigureRequest struct { @@ -212,7 +276,12 @@ type DescribeResponse struct { // listens says the connector serves Listen. Listens bool `protobuf:"varint,6,opt,name=listens,proto3" json:"listens,omitempty"` // target_facts says the connector serves TargetFacts. - TargetFacts bool `protobuf:"varint,7,opt,name=target_facts,json=targetFacts,proto3" json:"target_facts,omitempty"` + TargetFacts bool `protobuf:"varint,7,opt,name=target_facts,json=targetFacts,proto3" json:"target_facts,omitempty"` + // settings are the values an operator enters for the connector to run, + // which the dashboard renders as a form. + Settings []*Setting `protobuf:"bytes,8,rep,name=settings,proto3" json:"settings,omitempty"` + // version is the connector's own release. + Version string `protobuf:"bytes,9,opt,name=version,proto3" json:"version,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -296,6 +365,117 @@ func (x *DescribeResponse) GetTargetFacts() bool { return false } +func (x *DescribeResponse) GetSettings() []*Setting { + if x != nil { + return x.Settings + } + return nil +} + +func (x *DescribeResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +// Setting is one value an operator enters for an extension to run. +type Setting struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // secret says the value is a secret reference, never the secret. + Secret bool `protobuf:"varint,4,opt,name=secret,proto3" json:"secret,omitempty"` + Required bool `protobuf:"varint,5,opt,name=required,proto3" json:"required,omitempty"` + // type decides how the value is entered and checked; unspecified is a + // string. + Type SettingType `protobuf:"varint,6,opt,name=type,proto3,enum=connector.v1.SettingType" json:"type,omitempty"` + // options are the allowed values of a select setting. + Options []string `protobuf:"bytes,7,rep,name=options,proto3" json:"options,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Setting) Reset() { + *x = Setting{} + mi := &file_connector_v1_connector_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Setting) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Setting) ProtoMessage() {} + +func (x *Setting) ProtoReflect() protoreflect.Message { + mi := &file_connector_v1_connector_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Setting.ProtoReflect.Descriptor instead. +func (*Setting) Descriptor() ([]byte, []int) { + return file_connector_v1_connector_proto_rawDescGZIP(), []int{4} +} + +func (x *Setting) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Setting) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *Setting) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Setting) GetSecret() bool { + if x != nil { + return x.Secret + } + return false +} + +func (x *Setting) GetRequired() bool { + if x != nil { + return x.Required + } + return false +} + +func (x *Setting) GetType() SettingType { + if x != nil { + return x.Type + } + return SettingType_SETTING_TYPE_UNSPECIFIED +} + +func (x *Setting) GetOptions() []string { + if x != nil { + return x.Options + } + return nil +} + type EventType struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -308,7 +488,7 @@ type EventType struct { func (x *EventType) Reset() { *x = EventType{} - mi := &file_connector_v1_connector_proto_msgTypes[4] + mi := &file_connector_v1_connector_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -320,7 +500,7 @@ func (x *EventType) String() string { func (*EventType) ProtoMessage() {} func (x *EventType) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[4] + mi := &file_connector_v1_connector_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -333,7 +513,7 @@ func (x *EventType) ProtoReflect() protoreflect.Message { // Deprecated: Use EventType.ProtoReflect.Descriptor instead. func (*EventType) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{4} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{5} } func (x *EventType) GetName() string { @@ -375,7 +555,7 @@ type ActionType struct { func (x *ActionType) Reset() { *x = ActionType{} - mi := &file_connector_v1_connector_proto_msgTypes[5] + mi := &file_connector_v1_connector_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -387,7 +567,7 @@ func (x *ActionType) String() string { func (*ActionType) ProtoMessage() {} func (x *ActionType) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[5] + mi := &file_connector_v1_connector_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -400,7 +580,7 @@ func (x *ActionType) ProtoReflect() protoreflect.Message { // Deprecated: Use ActionType.ProtoReflect.Descriptor instead. func (*ActionType) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{5} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{6} } func (x *ActionType) GetName() string { @@ -449,7 +629,7 @@ type DeliveryType struct { func (x *DeliveryType) Reset() { *x = DeliveryType{} - mi := &file_connector_v1_connector_proto_msgTypes[6] + mi := &file_connector_v1_connector_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -461,7 +641,7 @@ func (x *DeliveryType) String() string { func (*DeliveryType) ProtoMessage() {} func (x *DeliveryType) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[6] + mi := &file_connector_v1_connector_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -474,7 +654,7 @@ func (x *DeliveryType) ProtoReflect() protoreflect.Message { // Deprecated: Use DeliveryType.ProtoReflect.Descriptor instead. func (*DeliveryType) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{6} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{7} } func (x *DeliveryType) GetName() string { @@ -509,7 +689,7 @@ type LookupType struct { func (x *LookupType) Reset() { *x = LookupType{} - mi := &file_connector_v1_connector_proto_msgTypes[7] + mi := &file_connector_v1_connector_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -521,7 +701,7 @@ func (x *LookupType) String() string { func (*LookupType) ProtoMessage() {} func (x *LookupType) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[7] + mi := &file_connector_v1_connector_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -534,7 +714,7 @@ func (x *LookupType) ProtoReflect() protoreflect.Message { // Deprecated: Use LookupType.ProtoReflect.Descriptor instead. func (*LookupType) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{7} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{8} } func (x *LookupType) GetName() string { @@ -571,7 +751,7 @@ type Effect struct { func (x *Effect) Reset() { *x = Effect{} - mi := &file_connector_v1_connector_proto_msgTypes[8] + mi := &file_connector_v1_connector_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -583,7 +763,7 @@ func (x *Effect) String() string { func (*Effect) ProtoMessage() {} func (x *Effect) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[8] + mi := &file_connector_v1_connector_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -596,7 +776,7 @@ func (x *Effect) ProtoReflect() protoreflect.Message { // Deprecated: Use Effect.ProtoReflect.Descriptor instead. func (*Effect) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{8} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{9} } func (x *Effect) GetReadOnly() bool { @@ -634,7 +814,7 @@ type Target struct { func (x *Target) Reset() { *x = Target{} - mi := &file_connector_v1_connector_proto_msgTypes[9] + mi := &file_connector_v1_connector_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -646,7 +826,7 @@ func (x *Target) String() string { func (*Target) ProtoMessage() {} func (x *Target) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[9] + mi := &file_connector_v1_connector_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -659,7 +839,7 @@ func (x *Target) ProtoReflect() protoreflect.Message { // Deprecated: Use Target.ProtoReflect.Descriptor instead. func (*Target) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{9} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{10} } func (x *Target) GetKind() string { @@ -700,7 +880,7 @@ type ParseRequest struct { func (x *ParseRequest) Reset() { *x = ParseRequest{} - mi := &file_connector_v1_connector_proto_msgTypes[10] + mi := &file_connector_v1_connector_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -712,7 +892,7 @@ func (x *ParseRequest) String() string { func (*ParseRequest) ProtoMessage() {} func (x *ParseRequest) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[10] + mi := &file_connector_v1_connector_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -725,7 +905,7 @@ func (x *ParseRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ParseRequest.ProtoReflect.Descriptor instead. func (*ParseRequest) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{10} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{11} } func (x *ParseRequest) GetBody() []byte { @@ -751,7 +931,7 @@ type ParseResponse struct { func (x *ParseResponse) Reset() { *x = ParseResponse{} - mi := &file_connector_v1_connector_proto_msgTypes[11] + mi := &file_connector_v1_connector_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -763,7 +943,7 @@ func (x *ParseResponse) String() string { func (*ParseResponse) ProtoMessage() {} func (x *ParseResponse) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[11] + mi := &file_connector_v1_connector_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -776,7 +956,7 @@ func (x *ParseResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ParseResponse.ProtoReflect.Descriptor instead. func (*ParseResponse) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{11} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{12} } func (x *ParseResponse) GetEvents() []*Event { @@ -803,7 +983,7 @@ type Event struct { func (x *Event) Reset() { *x = Event{} - mi := &file_connector_v1_connector_proto_msgTypes[12] + mi := &file_connector_v1_connector_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -815,7 +995,7 @@ func (x *Event) String() string { func (*Event) ProtoMessage() {} func (x *Event) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[12] + mi := &file_connector_v1_connector_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -828,7 +1008,7 @@ func (x *Event) ProtoReflect() protoreflect.Message { // Deprecated: Use Event.ProtoReflect.Descriptor instead. func (*Event) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{12} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{13} } func (x *Event) GetType() string { @@ -876,7 +1056,7 @@ type ResolveRequest struct { func (x *ResolveRequest) Reset() { *x = ResolveRequest{} - mi := &file_connector_v1_connector_proto_msgTypes[13] + mi := &file_connector_v1_connector_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -888,7 +1068,7 @@ func (x *ResolveRequest) String() string { func (*ResolveRequest) ProtoMessage() {} func (x *ResolveRequest) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[13] + mi := &file_connector_v1_connector_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -901,7 +1081,7 @@ func (x *ResolveRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveRequest.ProtoReflect.Descriptor instead. func (*ResolveRequest) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{13} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{14} } func (x *ResolveRequest) GetAction() string { @@ -928,7 +1108,7 @@ type ResolveResponse struct { func (x *ResolveResponse) Reset() { *x = ResolveResponse{} - mi := &file_connector_v1_connector_proto_msgTypes[14] + mi := &file_connector_v1_connector_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -940,7 +1120,7 @@ func (x *ResolveResponse) String() string { func (*ResolveResponse) ProtoMessage() {} func (x *ResolveResponse) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[14] + mi := &file_connector_v1_connector_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -953,7 +1133,7 @@ func (x *ResolveResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveResponse.ProtoReflect.Descriptor instead. func (*ResolveResponse) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{14} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{15} } func (x *ResolveResponse) GetTarget() *Target { @@ -983,7 +1163,7 @@ type InvokeRequest struct { func (x *InvokeRequest) Reset() { *x = InvokeRequest{} - mi := &file_connector_v1_connector_proto_msgTypes[15] + mi := &file_connector_v1_connector_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -995,7 +1175,7 @@ func (x *InvokeRequest) String() string { func (*InvokeRequest) ProtoMessage() {} func (x *InvokeRequest) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[15] + mi := &file_connector_v1_connector_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1008,7 +1188,7 @@ func (x *InvokeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use InvokeRequest.ProtoReflect.Descriptor instead. func (*InvokeRequest) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{15} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{16} } func (x *InvokeRequest) GetAction() string { @@ -1053,7 +1233,7 @@ type InvokeResponse struct { func (x *InvokeResponse) Reset() { *x = InvokeResponse{} - mi := &file_connector_v1_connector_proto_msgTypes[16] + mi := &file_connector_v1_connector_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1065,7 +1245,7 @@ func (x *InvokeResponse) String() string { func (*InvokeResponse) ProtoMessage() {} func (x *InvokeResponse) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[16] + mi := &file_connector_v1_connector_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1078,7 +1258,7 @@ func (x *InvokeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use InvokeResponse.ProtoReflect.Descriptor instead. func (*InvokeResponse) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{16} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{17} } func (x *InvokeResponse) GetOutput() []byte { @@ -1112,7 +1292,7 @@ type LookupRequest struct { func (x *LookupRequest) Reset() { *x = LookupRequest{} - mi := &file_connector_v1_connector_proto_msgTypes[17] + mi := &file_connector_v1_connector_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1124,7 +1304,7 @@ func (x *LookupRequest) String() string { func (*LookupRequest) ProtoMessage() {} func (x *LookupRequest) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[17] + mi := &file_connector_v1_connector_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1137,7 +1317,7 @@ func (x *LookupRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LookupRequest.ProtoReflect.Descriptor instead. func (*LookupRequest) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{17} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{18} } func (x *LookupRequest) GetLookup() string { @@ -1164,7 +1344,7 @@ type LookupResponse struct { func (x *LookupResponse) Reset() { *x = LookupResponse{} - mi := &file_connector_v1_connector_proto_msgTypes[18] + mi := &file_connector_v1_connector_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1176,7 +1356,7 @@ func (x *LookupResponse) String() string { func (*LookupResponse) ProtoMessage() {} func (x *LookupResponse) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[18] + mi := &file_connector_v1_connector_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1189,7 +1369,7 @@ func (x *LookupResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LookupResponse.ProtoReflect.Descriptor instead. func (*LookupResponse) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{18} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{19} } func (x *LookupResponse) GetOutput() []byte { @@ -1217,7 +1397,7 @@ type DeliverRequest struct { func (x *DeliverRequest) Reset() { *x = DeliverRequest{} - mi := &file_connector_v1_connector_proto_msgTypes[19] + mi := &file_connector_v1_connector_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1229,7 +1409,7 @@ func (x *DeliverRequest) String() string { func (*DeliverRequest) ProtoMessage() {} func (x *DeliverRequest) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[19] + mi := &file_connector_v1_connector_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1242,7 +1422,7 @@ func (x *DeliverRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeliverRequest.ProtoReflect.Descriptor instead. func (*DeliverRequest) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{19} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{20} } func (x *DeliverRequest) GetDelivery() string { @@ -1276,7 +1456,7 @@ type DeliverResponse struct { func (x *DeliverResponse) Reset() { *x = DeliverResponse{} - mi := &file_connector_v1_connector_proto_msgTypes[20] + mi := &file_connector_v1_connector_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1288,7 +1468,7 @@ func (x *DeliverResponse) String() string { func (*DeliverResponse) ProtoMessage() {} func (x *DeliverResponse) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[20] + mi := &file_connector_v1_connector_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1301,7 +1481,7 @@ func (x *DeliverResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeliverResponse.ProtoReflect.Descriptor instead. func (*DeliverResponse) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{20} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{21} } func (x *DeliverResponse) GetExternalId() string { @@ -1320,7 +1500,7 @@ type TargetFactsRequest struct { func (x *TargetFactsRequest) Reset() { *x = TargetFactsRequest{} - mi := &file_connector_v1_connector_proto_msgTypes[21] + mi := &file_connector_v1_connector_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1332,7 +1512,7 @@ func (x *TargetFactsRequest) String() string { func (*TargetFactsRequest) ProtoMessage() {} func (x *TargetFactsRequest) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[21] + mi := &file_connector_v1_connector_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1345,7 +1525,7 @@ func (x *TargetFactsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TargetFactsRequest.ProtoReflect.Descriptor instead. func (*TargetFactsRequest) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{21} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{22} } func (x *TargetFactsRequest) GetTarget() *Target { @@ -1372,7 +1552,7 @@ type TargetFactsResponse struct { func (x *TargetFactsResponse) Reset() { *x = TargetFactsResponse{} - mi := &file_connector_v1_connector_proto_msgTypes[22] + mi := &file_connector_v1_connector_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1384,7 +1564,7 @@ func (x *TargetFactsResponse) String() string { func (*TargetFactsResponse) ProtoMessage() {} func (x *TargetFactsResponse) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[22] + mi := &file_connector_v1_connector_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1397,7 +1577,7 @@ func (x *TargetFactsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use TargetFactsResponse.ProtoReflect.Descriptor instead. func (*TargetFactsResponse) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{22} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{23} } func (x *TargetFactsResponse) GetFound() bool { @@ -1438,7 +1618,7 @@ type ListenRequest struct { func (x *ListenRequest) Reset() { *x = ListenRequest{} - mi := &file_connector_v1_connector_proto_msgTypes[23] + mi := &file_connector_v1_connector_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1450,7 +1630,7 @@ func (x *ListenRequest) String() string { func (*ListenRequest) ProtoMessage() {} func (x *ListenRequest) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[23] + mi := &file_connector_v1_connector_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1463,7 +1643,7 @@ func (x *ListenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListenRequest.ProtoReflect.Descriptor instead. func (*ListenRequest) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{23} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{24} } func (x *ListenRequest) GetCursor() string { @@ -1483,7 +1663,7 @@ type ListenResponse struct { func (x *ListenResponse) Reset() { *x = ListenResponse{} - mi := &file_connector_v1_connector_proto_msgTypes[24] + mi := &file_connector_v1_connector_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1495,7 +1675,7 @@ func (x *ListenResponse) String() string { func (*ListenResponse) ProtoMessage() {} func (x *ListenResponse) ProtoReflect() protoreflect.Message { - mi := &file_connector_v1_connector_proto_msgTypes[24] + mi := &file_connector_v1_connector_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1508,7 +1688,7 @@ func (x *ListenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListenResponse.ProtoReflect.Descriptor instead. func (*ListenResponse) Descriptor() ([]byte, []int) { - return file_connector_v1_connector_proto_rawDescGZIP(), []int{24} + return file_connector_v1_connector_proto_rawDescGZIP(), []int{25} } func (x *ListenResponse) GetEvents() []*Event { @@ -1540,7 +1720,7 @@ const file_connector_v1_connector_proto_rawDesc = "" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x13\n" + "\x11ConfigureResponse\"\x11\n" + - "\x0fDescribeRequest\"\xc0\x02\n" + + "\x0fDescribeRequest\"\x8d\x03\n" + "\x10DescribeResponse\x12\x1a\n" + "\bcontract\x18\x01 \x01(\tR\bcontract\x12/\n" + "\x06events\x18\x02 \x03(\v2\x17.connector.v1.EventTypeR\x06events\x122\n" + @@ -1550,7 +1730,17 @@ const file_connector_v1_connector_proto_rawDesc = "" + "deliveries\x18\x05 \x03(\v2\x1a.connector.v1.DeliveryTypeR\n" + "deliveries\x12\x18\n" + "\alistens\x18\x06 \x01(\bR\alistens\x12!\n" + - "\ftarget_facts\x18\a \x01(\bR\vtargetFacts\"Y\n" + + "\ftarget_facts\x18\a \x01(\bR\vtargetFacts\x121\n" + + "\bsettings\x18\b \x03(\v2\x15.connector.v1.SettingR\bsettings\x12\x18\n" + + "\aversion\x18\t \x01(\tR\aversion\"\xd0\x01\n" + + "\aSetting\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05label\x18\x02 \x01(\tR\x05label\x12 \n" + + "\vdescription\x18\x03 \x01(\tR\vdescription\x12\x16\n" + + "\x06secret\x18\x04 \x01(\bR\x06secret\x12\x1a\n" + + "\brequired\x18\x05 \x01(\bR\brequired\x12-\n" + + "\x04type\x18\x06 \x01(\x0e2\x19.connector.v1.SettingTypeR\x04type\x12\x18\n" + + "\aoptions\x18\a \x03(\tR\aoptions\"Y\n" + "\tEventType\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12 \n" + "\vdescription\x18\x02 \x01(\tR\vdescription\x12\x16\n" + @@ -1639,7 +1829,16 @@ const file_connector_v1_connector_proto_rawDesc = "" + "\x06cursor\x18\x01 \x01(\tR\x06cursor\"U\n" + "\x0eListenResponse\x12+\n" + "\x06events\x18\x01 \x03(\v2\x13.connector.v1.EventR\x06events\x12\x16\n" + - "\x06cursor\x18\x02 \x01(\tR\x06cursor*\x95\x01\n" + + "\x06cursor\x18\x02 \x01(\tR\x06cursor*\xd9\x01\n" + + "\vSettingType\x12\x1c\n" + + "\x18SETTING_TYPE_UNSPECIFIED\x10\x00\x12\x17\n" + + "\x13SETTING_TYPE_STRING\x10\x01\x12\x17\n" + + "\x13SETTING_TYPE_NUMBER\x10\x02\x12\x18\n" + + "\x14SETTING_TYPE_BOOLEAN\x10\x03\x12\x19\n" + + "\x15SETTING_TYPE_DURATION\x10\x04\x12\x15\n" + + "\x11SETTING_TYPE_LIST\x10\x05\x12\x17\n" + + "\x13SETTING_TYPE_SELECT\x10\x06\x12\x15\n" + + "\x11SETTING_TYPE_TEXT\x10\a*\x95\x01\n" + "\rReversibility\x12\x1d\n" + "\x19REVERSIBILITY_UNSPECIFIED\x10\x00\x12&\n" + "\"REVERSIBILITY_UNDONE_AUTOMATICALLY\x10\x01\x12\x1d\n" + @@ -1669,79 +1868,83 @@ func file_connector_v1_connector_proto_rawDescGZIP() []byte { return file_connector_v1_connector_proto_rawDescData } -var file_connector_v1_connector_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_connector_v1_connector_proto_msgTypes = make([]protoimpl.MessageInfo, 28) +var file_connector_v1_connector_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_connector_v1_connector_proto_msgTypes = make([]protoimpl.MessageInfo, 29) var file_connector_v1_connector_proto_goTypes = []any{ - (Reversibility)(0), // 0: connector.v1.Reversibility - (*ConfigureRequest)(nil), // 1: connector.v1.ConfigureRequest - (*ConfigureResponse)(nil), // 2: connector.v1.ConfigureResponse - (*DescribeRequest)(nil), // 3: connector.v1.DescribeRequest - (*DescribeResponse)(nil), // 4: connector.v1.DescribeResponse - (*EventType)(nil), // 5: connector.v1.EventType - (*ActionType)(nil), // 6: connector.v1.ActionType - (*DeliveryType)(nil), // 7: connector.v1.DeliveryType - (*LookupType)(nil), // 8: connector.v1.LookupType - (*Effect)(nil), // 9: connector.v1.Effect - (*Target)(nil), // 10: connector.v1.Target - (*ParseRequest)(nil), // 11: connector.v1.ParseRequest - (*ParseResponse)(nil), // 12: connector.v1.ParseResponse - (*Event)(nil), // 13: connector.v1.Event - (*ResolveRequest)(nil), // 14: connector.v1.ResolveRequest - (*ResolveResponse)(nil), // 15: connector.v1.ResolveResponse - (*InvokeRequest)(nil), // 16: connector.v1.InvokeRequest - (*InvokeResponse)(nil), // 17: connector.v1.InvokeResponse - (*LookupRequest)(nil), // 18: connector.v1.LookupRequest - (*LookupResponse)(nil), // 19: connector.v1.LookupResponse - (*DeliverRequest)(nil), // 20: connector.v1.DeliverRequest - (*DeliverResponse)(nil), // 21: connector.v1.DeliverResponse - (*TargetFactsRequest)(nil), // 22: connector.v1.TargetFactsRequest - (*TargetFactsResponse)(nil), // 23: connector.v1.TargetFactsResponse - (*ListenRequest)(nil), // 24: connector.v1.ListenRequest - (*ListenResponse)(nil), // 25: connector.v1.ListenResponse - nil, // 26: connector.v1.ConfigureRequest.SettingsEntry - nil, // 27: connector.v1.ConfigureRequest.SecretsEntry - nil, // 28: connector.v1.ParseRequest.HeadersEntry - (*timestamppb.Timestamp)(nil), // 29: google.protobuf.Timestamp + (SettingType)(0), // 0: connector.v1.SettingType + (Reversibility)(0), // 1: connector.v1.Reversibility + (*ConfigureRequest)(nil), // 2: connector.v1.ConfigureRequest + (*ConfigureResponse)(nil), // 3: connector.v1.ConfigureResponse + (*DescribeRequest)(nil), // 4: connector.v1.DescribeRequest + (*DescribeResponse)(nil), // 5: connector.v1.DescribeResponse + (*Setting)(nil), // 6: connector.v1.Setting + (*EventType)(nil), // 7: connector.v1.EventType + (*ActionType)(nil), // 8: connector.v1.ActionType + (*DeliveryType)(nil), // 9: connector.v1.DeliveryType + (*LookupType)(nil), // 10: connector.v1.LookupType + (*Effect)(nil), // 11: connector.v1.Effect + (*Target)(nil), // 12: connector.v1.Target + (*ParseRequest)(nil), // 13: connector.v1.ParseRequest + (*ParseResponse)(nil), // 14: connector.v1.ParseResponse + (*Event)(nil), // 15: connector.v1.Event + (*ResolveRequest)(nil), // 16: connector.v1.ResolveRequest + (*ResolveResponse)(nil), // 17: connector.v1.ResolveResponse + (*InvokeRequest)(nil), // 18: connector.v1.InvokeRequest + (*InvokeResponse)(nil), // 19: connector.v1.InvokeResponse + (*LookupRequest)(nil), // 20: connector.v1.LookupRequest + (*LookupResponse)(nil), // 21: connector.v1.LookupResponse + (*DeliverRequest)(nil), // 22: connector.v1.DeliverRequest + (*DeliverResponse)(nil), // 23: connector.v1.DeliverResponse + (*TargetFactsRequest)(nil), // 24: connector.v1.TargetFactsRequest + (*TargetFactsResponse)(nil), // 25: connector.v1.TargetFactsResponse + (*ListenRequest)(nil), // 26: connector.v1.ListenRequest + (*ListenResponse)(nil), // 27: connector.v1.ListenResponse + nil, // 28: connector.v1.ConfigureRequest.SettingsEntry + nil, // 29: connector.v1.ConfigureRequest.SecretsEntry + nil, // 30: connector.v1.ParseRequest.HeadersEntry + (*timestamppb.Timestamp)(nil), // 31: google.protobuf.Timestamp } var file_connector_v1_connector_proto_depIdxs = []int32{ - 26, // 0: connector.v1.ConfigureRequest.settings:type_name -> connector.v1.ConfigureRequest.SettingsEntry - 27, // 1: connector.v1.ConfigureRequest.secrets:type_name -> connector.v1.ConfigureRequest.SecretsEntry - 5, // 2: connector.v1.DescribeResponse.events:type_name -> connector.v1.EventType - 6, // 3: connector.v1.DescribeResponse.actions:type_name -> connector.v1.ActionType - 8, // 4: connector.v1.DescribeResponse.lookups:type_name -> connector.v1.LookupType - 7, // 5: connector.v1.DescribeResponse.deliveries:type_name -> connector.v1.DeliveryType - 9, // 6: connector.v1.ActionType.effect:type_name -> connector.v1.Effect - 0, // 7: connector.v1.Effect.reversibility:type_name -> connector.v1.Reversibility - 28, // 8: connector.v1.ParseRequest.headers:type_name -> connector.v1.ParseRequest.HeadersEntry - 13, // 9: connector.v1.ParseResponse.events:type_name -> connector.v1.Event - 29, // 10: connector.v1.Event.occurred_at:type_name -> google.protobuf.Timestamp - 10, // 11: connector.v1.ResolveResponse.target:type_name -> connector.v1.Target - 9, // 12: connector.v1.ResolveResponse.effect:type_name -> connector.v1.Effect - 10, // 13: connector.v1.TargetFactsRequest.target:type_name -> connector.v1.Target - 13, // 14: connector.v1.ListenResponse.events:type_name -> connector.v1.Event - 1, // 15: connector.v1.ConnectorService.Configure:input_type -> connector.v1.ConfigureRequest - 3, // 16: connector.v1.ConnectorService.Describe:input_type -> connector.v1.DescribeRequest - 11, // 17: connector.v1.ConnectorService.Parse:input_type -> connector.v1.ParseRequest - 14, // 18: connector.v1.ConnectorService.Resolve:input_type -> connector.v1.ResolveRequest - 16, // 19: connector.v1.ConnectorService.Invoke:input_type -> connector.v1.InvokeRequest - 18, // 20: connector.v1.ConnectorService.Lookup:input_type -> connector.v1.LookupRequest - 20, // 21: connector.v1.ConnectorService.Deliver:input_type -> connector.v1.DeliverRequest - 24, // 22: connector.v1.ConnectorService.Listen:input_type -> connector.v1.ListenRequest - 22, // 23: connector.v1.ConnectorService.TargetFacts:input_type -> connector.v1.TargetFactsRequest - 2, // 24: connector.v1.ConnectorService.Configure:output_type -> connector.v1.ConfigureResponse - 4, // 25: connector.v1.ConnectorService.Describe:output_type -> connector.v1.DescribeResponse - 12, // 26: connector.v1.ConnectorService.Parse:output_type -> connector.v1.ParseResponse - 15, // 27: connector.v1.ConnectorService.Resolve:output_type -> connector.v1.ResolveResponse - 17, // 28: connector.v1.ConnectorService.Invoke:output_type -> connector.v1.InvokeResponse - 19, // 29: connector.v1.ConnectorService.Lookup:output_type -> connector.v1.LookupResponse - 21, // 30: connector.v1.ConnectorService.Deliver:output_type -> connector.v1.DeliverResponse - 25, // 31: connector.v1.ConnectorService.Listen:output_type -> connector.v1.ListenResponse - 23, // 32: connector.v1.ConnectorService.TargetFacts:output_type -> connector.v1.TargetFactsResponse - 24, // [24:33] is the sub-list for method output_type - 15, // [15:24] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 28, // 0: connector.v1.ConfigureRequest.settings:type_name -> connector.v1.ConfigureRequest.SettingsEntry + 29, // 1: connector.v1.ConfigureRequest.secrets:type_name -> connector.v1.ConfigureRequest.SecretsEntry + 7, // 2: connector.v1.DescribeResponse.events:type_name -> connector.v1.EventType + 8, // 3: connector.v1.DescribeResponse.actions:type_name -> connector.v1.ActionType + 10, // 4: connector.v1.DescribeResponse.lookups:type_name -> connector.v1.LookupType + 9, // 5: connector.v1.DescribeResponse.deliveries:type_name -> connector.v1.DeliveryType + 6, // 6: connector.v1.DescribeResponse.settings:type_name -> connector.v1.Setting + 0, // 7: connector.v1.Setting.type:type_name -> connector.v1.SettingType + 11, // 8: connector.v1.ActionType.effect:type_name -> connector.v1.Effect + 1, // 9: connector.v1.Effect.reversibility:type_name -> connector.v1.Reversibility + 30, // 10: connector.v1.ParseRequest.headers:type_name -> connector.v1.ParseRequest.HeadersEntry + 15, // 11: connector.v1.ParseResponse.events:type_name -> connector.v1.Event + 31, // 12: connector.v1.Event.occurred_at:type_name -> google.protobuf.Timestamp + 12, // 13: connector.v1.ResolveResponse.target:type_name -> connector.v1.Target + 11, // 14: connector.v1.ResolveResponse.effect:type_name -> connector.v1.Effect + 12, // 15: connector.v1.TargetFactsRequest.target:type_name -> connector.v1.Target + 15, // 16: connector.v1.ListenResponse.events:type_name -> connector.v1.Event + 2, // 17: connector.v1.ConnectorService.Configure:input_type -> connector.v1.ConfigureRequest + 4, // 18: connector.v1.ConnectorService.Describe:input_type -> connector.v1.DescribeRequest + 13, // 19: connector.v1.ConnectorService.Parse:input_type -> connector.v1.ParseRequest + 16, // 20: connector.v1.ConnectorService.Resolve:input_type -> connector.v1.ResolveRequest + 18, // 21: connector.v1.ConnectorService.Invoke:input_type -> connector.v1.InvokeRequest + 20, // 22: connector.v1.ConnectorService.Lookup:input_type -> connector.v1.LookupRequest + 22, // 23: connector.v1.ConnectorService.Deliver:input_type -> connector.v1.DeliverRequest + 26, // 24: connector.v1.ConnectorService.Listen:input_type -> connector.v1.ListenRequest + 24, // 25: connector.v1.ConnectorService.TargetFacts:input_type -> connector.v1.TargetFactsRequest + 3, // 26: connector.v1.ConnectorService.Configure:output_type -> connector.v1.ConfigureResponse + 5, // 27: connector.v1.ConnectorService.Describe:output_type -> connector.v1.DescribeResponse + 14, // 28: connector.v1.ConnectorService.Parse:output_type -> connector.v1.ParseResponse + 17, // 29: connector.v1.ConnectorService.Resolve:output_type -> connector.v1.ResolveResponse + 19, // 30: connector.v1.ConnectorService.Invoke:output_type -> connector.v1.InvokeResponse + 21, // 31: connector.v1.ConnectorService.Lookup:output_type -> connector.v1.LookupResponse + 23, // 32: connector.v1.ConnectorService.Deliver:output_type -> connector.v1.DeliverResponse + 27, // 33: connector.v1.ConnectorService.Listen:output_type -> connector.v1.ListenResponse + 25, // 34: connector.v1.ConnectorService.TargetFacts:output_type -> connector.v1.TargetFactsResponse + 26, // [26:35] is the sub-list for method output_type + 17, // [17:26] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_connector_v1_connector_proto_init() } @@ -1754,8 +1957,8 @@ func file_connector_v1_connector_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_connector_v1_connector_proto_rawDesc), len(file_connector_v1_connector_proto_rawDesc)), - NumEnums: 1, - NumMessages: 28, + NumEnums: 2, + NumMessages: 29, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/contracts/guard/v1/guard.pb.go b/internal/contracts/guard/v1/guard.pb.go index cd88142f3..ab3eb80fc 100644 --- a/internal/contracts/guard/v1/guard.pb.go +++ b/internal/contracts/guard/v1/guard.pb.go @@ -23,6 +23,70 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type SettingType int32 + +const ( + SettingType_SETTING_TYPE_UNSPECIFIED SettingType = 0 + SettingType_SETTING_TYPE_STRING SettingType = 1 + SettingType_SETTING_TYPE_NUMBER SettingType = 2 + SettingType_SETTING_TYPE_BOOLEAN SettingType = 3 + SettingType_SETTING_TYPE_DURATION SettingType = 4 + SettingType_SETTING_TYPE_LIST SettingType = 5 + SettingType_SETTING_TYPE_SELECT SettingType = 6 + SettingType_SETTING_TYPE_TEXT SettingType = 7 +) + +// Enum value maps for SettingType. +var ( + SettingType_name = map[int32]string{ + 0: "SETTING_TYPE_UNSPECIFIED", + 1: "SETTING_TYPE_STRING", + 2: "SETTING_TYPE_NUMBER", + 3: "SETTING_TYPE_BOOLEAN", + 4: "SETTING_TYPE_DURATION", + 5: "SETTING_TYPE_LIST", + 6: "SETTING_TYPE_SELECT", + 7: "SETTING_TYPE_TEXT", + } + SettingType_value = map[string]int32{ + "SETTING_TYPE_UNSPECIFIED": 0, + "SETTING_TYPE_STRING": 1, + "SETTING_TYPE_NUMBER": 2, + "SETTING_TYPE_BOOLEAN": 3, + "SETTING_TYPE_DURATION": 4, + "SETTING_TYPE_LIST": 5, + "SETTING_TYPE_SELECT": 6, + "SETTING_TYPE_TEXT": 7, + } +) + +func (x SettingType) Enum() *SettingType { + p := new(SettingType) + *p = x + return p +} + +func (x SettingType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SettingType) Descriptor() protoreflect.EnumDescriptor { + return file_guard_v1_guard_proto_enumTypes[0].Descriptor() +} + +func (SettingType) Type() protoreflect.EnumType { + return &file_guard_v1_guard_proto_enumTypes[0] +} + +func (x SettingType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SettingType.Descriptor instead. +func (SettingType) EnumDescriptor() ([]byte, []int) { + return file_guard_v1_guard_proto_rawDescGZIP(), []int{0} +} + type Reversibility int32 const ( @@ -59,11 +123,11 @@ func (x Reversibility) String() string { } func (Reversibility) Descriptor() protoreflect.EnumDescriptor { - return file_guard_v1_guard_proto_enumTypes[0].Descriptor() + return file_guard_v1_guard_proto_enumTypes[1].Descriptor() } func (Reversibility) Type() protoreflect.EnumType { - return &file_guard_v1_guard_proto_enumTypes[0] + return &file_guard_v1_guard_proto_enumTypes[1] } func (x Reversibility) Number() protoreflect.EnumNumber { @@ -72,7 +136,7 @@ func (x Reversibility) Number() protoreflect.EnumNumber { // Deprecated: Use Reversibility.Descriptor instead. func (Reversibility) EnumDescriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{0} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{1} } // Ceiling is the five-level scale, from the most autonomy to the least. @@ -118,11 +182,11 @@ func (x Ceiling) String() string { } func (Ceiling) Descriptor() protoreflect.EnumDescriptor { - return file_guard_v1_guard_proto_enumTypes[1].Descriptor() + return file_guard_v1_guard_proto_enumTypes[2].Descriptor() } func (Ceiling) Type() protoreflect.EnumType { - return &file_guard_v1_guard_proto_enumTypes[1] + return &file_guard_v1_guard_proto_enumTypes[2] } func (x Ceiling) Number() protoreflect.EnumNumber { @@ -131,7 +195,7 @@ func (x Ceiling) Number() protoreflect.EnumNumber { // Deprecated: Use Ceiling.Descriptor instead. func (Ceiling) EnumDescriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{1} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{2} } // Strength is how much a finding's evidence supports it. @@ -171,11 +235,11 @@ func (x Strength) String() string { } func (Strength) Descriptor() protoreflect.EnumDescriptor { - return file_guard_v1_guard_proto_enumTypes[2].Descriptor() + return file_guard_v1_guard_proto_enumTypes[3].Descriptor() } func (Strength) Type() protoreflect.EnumType { - return &file_guard_v1_guard_proto_enumTypes[2] + return &file_guard_v1_guard_proto_enumTypes[3] } func (x Strength) Number() protoreflect.EnumNumber { @@ -184,7 +248,7 @@ func (x Strength) Number() protoreflect.EnumNumber { // Deprecated: Use Strength.Descriptor instead. func (Strength) EnumDescriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{2} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{3} } type ConfigureRequest struct { @@ -319,7 +383,10 @@ type DescribeResponse struct { // version is the guard's own release, recorded with each verdict. Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` // advisory says the guard's verdicts are recorded and set no ceiling. - Advisory bool `protobuf:"varint,4,opt,name=advisory,proto3" json:"advisory,omitempty"` + Advisory bool `protobuf:"varint,4,opt,name=advisory,proto3" json:"advisory,omitempty"` + // settings are the values an operator enters for the guard to run, + // including the judge it asks. The dashboard renders them as a form. + Settings []*Setting `protobuf:"bytes,5,rep,name=settings,proto3" json:"settings,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -382,6 +449,110 @@ func (x *DescribeResponse) GetAdvisory() bool { return false } +func (x *DescribeResponse) GetSettings() []*Setting { + if x != nil { + return x.Settings + } + return nil +} + +// Setting is one value an operator enters for an extension to run. +type Setting struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // secret says the value is a secret reference, never the secret. + Secret bool `protobuf:"varint,4,opt,name=secret,proto3" json:"secret,omitempty"` + Required bool `protobuf:"varint,5,opt,name=required,proto3" json:"required,omitempty"` + // type decides how the value is entered and checked; unspecified is a + // string. + Type SettingType `protobuf:"varint,6,opt,name=type,proto3,enum=guard.v1.SettingType" json:"type,omitempty"` + // options are the allowed values of a select setting. + Options []string `protobuf:"bytes,7,rep,name=options,proto3" json:"options,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Setting) Reset() { + *x = Setting{} + mi := &file_guard_v1_guard_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Setting) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Setting) ProtoMessage() {} + +func (x *Setting) ProtoReflect() protoreflect.Message { + mi := &file_guard_v1_guard_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Setting.ProtoReflect.Descriptor instead. +func (*Setting) Descriptor() ([]byte, []int) { + return file_guard_v1_guard_proto_rawDescGZIP(), []int{4} +} + +func (x *Setting) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Setting) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *Setting) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Setting) GetSecret() bool { + if x != nil { + return x.Secret + } + return false +} + +func (x *Setting) GetRequired() bool { + if x != nil { + return x.Required + } + return false +} + +func (x *Setting) GetType() SettingType { + if x != nil { + return x.Type + } + return SettingType_SETTING_TYPE_UNSPECIFIED +} + +func (x *Setting) GetOptions() []string { + if x != nil { + return x.Options + } + return nil +} + type Effect struct { state protoimpl.MessageState `protogen:"open.v1"` ReadOnly bool `protobuf:"varint,1,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` @@ -393,7 +564,7 @@ type Effect struct { func (x *Effect) Reset() { *x = Effect{} - mi := &file_guard_v1_guard_proto_msgTypes[4] + mi := &file_guard_v1_guard_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -405,7 +576,7 @@ func (x *Effect) String() string { func (*Effect) ProtoMessage() {} func (x *Effect) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[4] + mi := &file_guard_v1_guard_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -418,7 +589,7 @@ func (x *Effect) ProtoReflect() protoreflect.Message { // Deprecated: Use Effect.ProtoReflect.Descriptor instead. func (*Effect) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{4} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{5} } func (x *Effect) GetReadOnly() bool { @@ -454,7 +625,7 @@ type Target struct { func (x *Target) Reset() { *x = Target{} - mi := &file_guard_v1_guard_proto_msgTypes[5] + mi := &file_guard_v1_guard_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -466,7 +637,7 @@ func (x *Target) String() string { func (*Target) ProtoMessage() {} func (x *Target) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[5] + mi := &file_guard_v1_guard_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -479,7 +650,7 @@ func (x *Target) ProtoReflect() protoreflect.Message { // Deprecated: Use Target.ProtoReflect.Descriptor instead. func (*Target) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{5} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{6} } func (x *Target) GetKind() string { @@ -521,7 +692,7 @@ type RunContext struct { func (x *RunContext) Reset() { *x = RunContext{} - mi := &file_guard_v1_guard_proto_msgTypes[6] + mi := &file_guard_v1_guard_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -533,7 +704,7 @@ func (x *RunContext) String() string { func (*RunContext) ProtoMessage() {} func (x *RunContext) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[6] + mi := &file_guard_v1_guard_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -546,7 +717,7 @@ func (x *RunContext) ProtoReflect() protoreflect.Message { // Deprecated: Use RunContext.ProtoReflect.Descriptor instead. func (*RunContext) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{6} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{7} } func (x *RunContext) GetRunId() string { @@ -588,7 +759,7 @@ type JudgeRequest struct { func (x *JudgeRequest) Reset() { *x = JudgeRequest{} - mi := &file_guard_v1_guard_proto_msgTypes[7] + mi := &file_guard_v1_guard_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -600,7 +771,7 @@ func (x *JudgeRequest) String() string { func (*JudgeRequest) ProtoMessage() {} func (x *JudgeRequest) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[7] + mi := &file_guard_v1_guard_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -613,7 +784,7 @@ func (x *JudgeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use JudgeRequest.ProtoReflect.Descriptor instead. func (*JudgeRequest) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{7} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{8} } func (x *JudgeRequest) GetConnector() string { @@ -705,7 +876,7 @@ type Evidence struct { func (x *Evidence) Reset() { *x = Evidence{} - mi := &file_guard_v1_guard_proto_msgTypes[8] + mi := &file_guard_v1_guard_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -717,7 +888,7 @@ func (x *Evidence) String() string { func (*Evidence) ProtoMessage() {} func (x *Evidence) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[8] + mi := &file_guard_v1_guard_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -730,7 +901,7 @@ func (x *Evidence) ProtoReflect() protoreflect.Message { // Deprecated: Use Evidence.ProtoReflect.Descriptor instead. func (*Evidence) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{8} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{9} } func (x *Evidence) GetSource() string { @@ -759,7 +930,7 @@ type Finding struct { func (x *Finding) Reset() { *x = Finding{} - mi := &file_guard_v1_guard_proto_msgTypes[9] + mi := &file_guard_v1_guard_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -771,7 +942,7 @@ func (x *Finding) String() string { func (*Finding) ProtoMessage() {} func (x *Finding) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[9] + mi := &file_guard_v1_guard_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -784,7 +955,7 @@ func (x *Finding) ProtoReflect() protoreflect.Message { // Deprecated: Use Finding.ProtoReflect.Descriptor instead. func (*Finding) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{9} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{10} } func (x *Finding) GetText() string { @@ -825,7 +996,7 @@ type JudgeResponse struct { func (x *JudgeResponse) Reset() { *x = JudgeResponse{} - mi := &file_guard_v1_guard_proto_msgTypes[10] + mi := &file_guard_v1_guard_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -837,7 +1008,7 @@ func (x *JudgeResponse) String() string { func (*JudgeResponse) ProtoMessage() {} func (x *JudgeResponse) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[10] + mi := &file_guard_v1_guard_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -850,7 +1021,7 @@ func (x *JudgeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use JudgeResponse.ProtoReflect.Descriptor instead. func (*JudgeResponse) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{10} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{11} } func (x *JudgeResponse) GetCeiling() Ceiling { @@ -923,7 +1094,7 @@ type JudgeRecord struct { func (x *JudgeRecord) Reset() { *x = JudgeRecord{} - mi := &file_guard_v1_guard_proto_msgTypes[11] + mi := &file_guard_v1_guard_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -935,7 +1106,7 @@ func (x *JudgeRecord) String() string { func (*JudgeRecord) ProtoMessage() {} func (x *JudgeRecord) ProtoReflect() protoreflect.Message { - mi := &file_guard_v1_guard_proto_msgTypes[11] + mi := &file_guard_v1_guard_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -948,7 +1119,7 @@ func (x *JudgeRecord) ProtoReflect() protoreflect.Message { // Deprecated: Use JudgeRecord.ProtoReflect.Descriptor instead. func (*JudgeRecord) Descriptor() ([]byte, []int) { - return file_guard_v1_guard_proto_rawDescGZIP(), []int{11} + return file_guard_v1_guard_proto_rawDescGZIP(), []int{12} } func (x *JudgeRecord) GetModel() string { @@ -1078,12 +1249,21 @@ const file_guard_v1_guard_proto_rawDesc = "" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x13\n" + "\x11ConfigureResponse\"\x11\n" + - "\x0fDescribeRequest\"x\n" + + "\x0fDescribeRequest\"\xa7\x01\n" + "\x10DescribeResponse\x12\x1a\n" + "\bcontract\x18\x01 \x01(\tR\bcontract\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x03 \x01(\tR\aversion\x12\x1a\n" + - "\badvisory\x18\x04 \x01(\bR\badvisory\"~\n" + + "\badvisory\x18\x04 \x01(\bR\badvisory\x12-\n" + + "\bsettings\x18\x05 \x03(\v2\x11.guard.v1.SettingR\bsettings\"\xcc\x01\n" + + "\aSetting\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05label\x18\x02 \x01(\tR\x05label\x12 \n" + + "\vdescription\x18\x03 \x01(\tR\vdescription\x12\x16\n" + + "\x06secret\x18\x04 \x01(\bR\x06secret\x12\x1a\n" + + "\brequired\x18\x05 \x01(\bR\brequired\x12)\n" + + "\x04type\x18\x06 \x01(\x0e2\x15.guard.v1.SettingTypeR\x04type\x12\x18\n" + + "\aoptions\x18\a \x03(\tR\aoptions\"~\n" + "\x06Effect\x12\x1b\n" + "\tread_only\x18\x01 \x01(\bR\breadOnly\x12=\n" + "\rreversibility\x18\x02 \x01(\x0e2\x17.guard.v1.ReversibilityR\rreversibility\x12\x18\n" + @@ -1146,7 +1326,16 @@ const file_guard_v1_guard_proto_rawDesc = "" + "\vhttp_status\x18\x0f \x01(\x05R\n" + "httpStatus\x12\x1d\n" + "\n" + - "latency_ms\x18\x10 \x01(\x03R\tlatencyMs*\x95\x01\n" + + "latency_ms\x18\x10 \x01(\x03R\tlatencyMs*\xd9\x01\n" + + "\vSettingType\x12\x1c\n" + + "\x18SETTING_TYPE_UNSPECIFIED\x10\x00\x12\x17\n" + + "\x13SETTING_TYPE_STRING\x10\x01\x12\x17\n" + + "\x13SETTING_TYPE_NUMBER\x10\x02\x12\x18\n" + + "\x14SETTING_TYPE_BOOLEAN\x10\x03\x12\x19\n" + + "\x15SETTING_TYPE_DURATION\x10\x04\x12\x15\n" + + "\x11SETTING_TYPE_LIST\x10\x05\x12\x17\n" + + "\x13SETTING_TYPE_SELECT\x10\x06\x12\x15\n" + + "\x11SETTING_TYPE_TEXT\x10\a*\x95\x01\n" + "\rReversibility\x12\x1d\n" + "\x19REVERSIBILITY_UNSPECIFIED\x10\x00\x12&\n" + "\"REVERSIBILITY_UNDONE_AUTOMATICALLY\x10\x01\x12\x1d\n" + @@ -1183,54 +1372,58 @@ func file_guard_v1_guard_proto_rawDescGZIP() []byte { return file_guard_v1_guard_proto_rawDescData } -var file_guard_v1_guard_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_guard_v1_guard_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_guard_v1_guard_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_guard_v1_guard_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_guard_v1_guard_proto_goTypes = []any{ - (Reversibility)(0), // 0: guard.v1.Reversibility - (Ceiling)(0), // 1: guard.v1.Ceiling - (Strength)(0), // 2: guard.v1.Strength - (*ConfigureRequest)(nil), // 3: guard.v1.ConfigureRequest - (*ConfigureResponse)(nil), // 4: guard.v1.ConfigureResponse - (*DescribeRequest)(nil), // 5: guard.v1.DescribeRequest - (*DescribeResponse)(nil), // 6: guard.v1.DescribeResponse - (*Effect)(nil), // 7: guard.v1.Effect - (*Target)(nil), // 8: guard.v1.Target - (*RunContext)(nil), // 9: guard.v1.RunContext - (*JudgeRequest)(nil), // 10: guard.v1.JudgeRequest - (*Evidence)(nil), // 11: guard.v1.Evidence - (*Finding)(nil), // 12: guard.v1.Finding - (*JudgeResponse)(nil), // 13: guard.v1.JudgeResponse - (*JudgeRecord)(nil), // 14: guard.v1.JudgeRecord - nil, // 15: guard.v1.ConfigureRequest.SettingsEntry - nil, // 16: guard.v1.ConfigureRequest.SecretsEntry - (*durationpb.Duration)(nil), // 17: google.protobuf.Duration - (*timestamppb.Timestamp)(nil), // 18: google.protobuf.Timestamp + (SettingType)(0), // 0: guard.v1.SettingType + (Reversibility)(0), // 1: guard.v1.Reversibility + (Ceiling)(0), // 2: guard.v1.Ceiling + (Strength)(0), // 3: guard.v1.Strength + (*ConfigureRequest)(nil), // 4: guard.v1.ConfigureRequest + (*ConfigureResponse)(nil), // 5: guard.v1.ConfigureResponse + (*DescribeRequest)(nil), // 6: guard.v1.DescribeRequest + (*DescribeResponse)(nil), // 7: guard.v1.DescribeResponse + (*Setting)(nil), // 8: guard.v1.Setting + (*Effect)(nil), // 9: guard.v1.Effect + (*Target)(nil), // 10: guard.v1.Target + (*RunContext)(nil), // 11: guard.v1.RunContext + (*JudgeRequest)(nil), // 12: guard.v1.JudgeRequest + (*Evidence)(nil), // 13: guard.v1.Evidence + (*Finding)(nil), // 14: guard.v1.Finding + (*JudgeResponse)(nil), // 15: guard.v1.JudgeResponse + (*JudgeRecord)(nil), // 16: guard.v1.JudgeRecord + nil, // 17: guard.v1.ConfigureRequest.SettingsEntry + nil, // 18: guard.v1.ConfigureRequest.SecretsEntry + (*durationpb.Duration)(nil), // 19: google.protobuf.Duration + (*timestamppb.Timestamp)(nil), // 20: google.protobuf.Timestamp } var file_guard_v1_guard_proto_depIdxs = []int32{ - 15, // 0: guard.v1.ConfigureRequest.settings:type_name -> guard.v1.ConfigureRequest.SettingsEntry - 16, // 1: guard.v1.ConfigureRequest.secrets:type_name -> guard.v1.ConfigureRequest.SecretsEntry - 0, // 2: guard.v1.Effect.reversibility:type_name -> guard.v1.Reversibility - 8, // 3: guard.v1.JudgeRequest.target:type_name -> guard.v1.Target - 7, // 4: guard.v1.JudgeRequest.effect:type_name -> guard.v1.Effect - 9, // 5: guard.v1.JudgeRequest.run:type_name -> guard.v1.RunContext - 17, // 6: guard.v1.JudgeRequest.deadline:type_name -> google.protobuf.Duration - 18, // 7: guard.v1.JudgeRequest.at:type_name -> google.protobuf.Timestamp - 11, // 8: guard.v1.JudgeRequest.evidence:type_name -> guard.v1.Evidence - 2, // 9: guard.v1.Finding.strength:type_name -> guard.v1.Strength - 1, // 10: guard.v1.JudgeResponse.ceiling:type_name -> guard.v1.Ceiling - 12, // 11: guard.v1.JudgeResponse.findings:type_name -> guard.v1.Finding - 14, // 12: guard.v1.JudgeResponse.judges:type_name -> guard.v1.JudgeRecord - 3, // 13: guard.v1.GuardService.Configure:input_type -> guard.v1.ConfigureRequest - 5, // 14: guard.v1.GuardService.Describe:input_type -> guard.v1.DescribeRequest - 10, // 15: guard.v1.GuardService.Judge:input_type -> guard.v1.JudgeRequest - 4, // 16: guard.v1.GuardService.Configure:output_type -> guard.v1.ConfigureResponse - 6, // 17: guard.v1.GuardService.Describe:output_type -> guard.v1.DescribeResponse - 13, // 18: guard.v1.GuardService.Judge:output_type -> guard.v1.JudgeResponse - 16, // [16:19] is the sub-list for method output_type - 13, // [13:16] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 17, // 0: guard.v1.ConfigureRequest.settings:type_name -> guard.v1.ConfigureRequest.SettingsEntry + 18, // 1: guard.v1.ConfigureRequest.secrets:type_name -> guard.v1.ConfigureRequest.SecretsEntry + 8, // 2: guard.v1.DescribeResponse.settings:type_name -> guard.v1.Setting + 0, // 3: guard.v1.Setting.type:type_name -> guard.v1.SettingType + 1, // 4: guard.v1.Effect.reversibility:type_name -> guard.v1.Reversibility + 10, // 5: guard.v1.JudgeRequest.target:type_name -> guard.v1.Target + 9, // 6: guard.v1.JudgeRequest.effect:type_name -> guard.v1.Effect + 11, // 7: guard.v1.JudgeRequest.run:type_name -> guard.v1.RunContext + 19, // 8: guard.v1.JudgeRequest.deadline:type_name -> google.protobuf.Duration + 20, // 9: guard.v1.JudgeRequest.at:type_name -> google.protobuf.Timestamp + 13, // 10: guard.v1.JudgeRequest.evidence:type_name -> guard.v1.Evidence + 3, // 11: guard.v1.Finding.strength:type_name -> guard.v1.Strength + 2, // 12: guard.v1.JudgeResponse.ceiling:type_name -> guard.v1.Ceiling + 14, // 13: guard.v1.JudgeResponse.findings:type_name -> guard.v1.Finding + 16, // 14: guard.v1.JudgeResponse.judges:type_name -> guard.v1.JudgeRecord + 4, // 15: guard.v1.GuardService.Configure:input_type -> guard.v1.ConfigureRequest + 6, // 16: guard.v1.GuardService.Describe:input_type -> guard.v1.DescribeRequest + 12, // 17: guard.v1.GuardService.Judge:input_type -> guard.v1.JudgeRequest + 5, // 18: guard.v1.GuardService.Configure:output_type -> guard.v1.ConfigureResponse + 7, // 19: guard.v1.GuardService.Describe:output_type -> guard.v1.DescribeResponse + 15, // 20: guard.v1.GuardService.Judge:output_type -> guard.v1.JudgeResponse + 18, // [18:21] is the sub-list for method output_type + 15, // [15:18] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_guard_v1_guard_proto_init() } @@ -1243,8 +1436,8 @@ func file_guard_v1_guard_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_guard_v1_guard_proto_rawDesc), len(file_guard_v1_guard_proto_rawDesc)), - NumEnums: 3, - NumMessages: 14, + NumEnums: 4, + NumMessages: 15, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/contracts/secretengine/v1/secretengine.pb.go b/internal/contracts/secretengine/v1/secretengine.pb.go index c99bd3533..9d38b4f4d 100644 --- a/internal/contracts/secretengine/v1/secretengine.pb.go +++ b/internal/contracts/secretengine/v1/secretengine.pb.go @@ -21,6 +21,70 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type SettingType int32 + +const ( + SettingType_SETTING_TYPE_UNSPECIFIED SettingType = 0 + SettingType_SETTING_TYPE_STRING SettingType = 1 + SettingType_SETTING_TYPE_NUMBER SettingType = 2 + SettingType_SETTING_TYPE_BOOLEAN SettingType = 3 + SettingType_SETTING_TYPE_DURATION SettingType = 4 + SettingType_SETTING_TYPE_LIST SettingType = 5 + SettingType_SETTING_TYPE_SELECT SettingType = 6 + SettingType_SETTING_TYPE_TEXT SettingType = 7 +) + +// Enum value maps for SettingType. +var ( + SettingType_name = map[int32]string{ + 0: "SETTING_TYPE_UNSPECIFIED", + 1: "SETTING_TYPE_STRING", + 2: "SETTING_TYPE_NUMBER", + 3: "SETTING_TYPE_BOOLEAN", + 4: "SETTING_TYPE_DURATION", + 5: "SETTING_TYPE_LIST", + 6: "SETTING_TYPE_SELECT", + 7: "SETTING_TYPE_TEXT", + } + SettingType_value = map[string]int32{ + "SETTING_TYPE_UNSPECIFIED": 0, + "SETTING_TYPE_STRING": 1, + "SETTING_TYPE_NUMBER": 2, + "SETTING_TYPE_BOOLEAN": 3, + "SETTING_TYPE_DURATION": 4, + "SETTING_TYPE_LIST": 5, + "SETTING_TYPE_SELECT": 6, + "SETTING_TYPE_TEXT": 7, + } +) + +func (x SettingType) Enum() *SettingType { + p := new(SettingType) + *p = x + return p +} + +func (x SettingType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SettingType) Descriptor() protoreflect.EnumDescriptor { + return file_secretengine_v1_secretengine_proto_enumTypes[0].Descriptor() +} + +func (SettingType) Type() protoreflect.EnumType { + return &file_secretengine_v1_secretengine_proto_enumTypes[0] +} + +func (x SettingType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SettingType.Descriptor instead. +func (SettingType) EnumDescriptor() ([]byte, []int) { + return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{0} +} + type ConfigureRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Settings map[string]string `protobuf:"bytes,1,rep,name=settings,proto3" json:"settings,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` @@ -111,6 +175,192 @@ func (*ConfigureResponse) Descriptor() ([]byte, []int) { return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{1} } +type DescribeRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DescribeRequest) Reset() { + *x = DescribeRequest{} + mi := &file_secretengine_v1_secretengine_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DescribeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DescribeRequest) ProtoMessage() {} + +func (x *DescribeRequest) ProtoReflect() protoreflect.Message { + mi := &file_secretengine_v1_secretengine_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DescribeRequest.ProtoReflect.Descriptor instead. +func (*DescribeRequest) Descriptor() ([]byte, []int) { + return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{2} +} + +type DescribeResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // version is the engine's own release. + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Settings []*Setting `protobuf:"bytes,2,rep,name=settings,proto3" json:"settings,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DescribeResponse) Reset() { + *x = DescribeResponse{} + mi := &file_secretengine_v1_secretengine_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DescribeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DescribeResponse) ProtoMessage() {} + +func (x *DescribeResponse) ProtoReflect() protoreflect.Message { + mi := &file_secretengine_v1_secretengine_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DescribeResponse.ProtoReflect.Descriptor instead. +func (*DescribeResponse) Descriptor() ([]byte, []int) { + return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{3} +} + +func (x *DescribeResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *DescribeResponse) GetSettings() []*Setting { + if x != nil { + return x.Settings + } + return nil +} + +// Setting is one value an operator enters for an extension to run. +type Setting struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // secret says the value is a secret reference, never the secret. + Secret bool `protobuf:"varint,4,opt,name=secret,proto3" json:"secret,omitempty"` + Required bool `protobuf:"varint,5,opt,name=required,proto3" json:"required,omitempty"` + // type decides how the value is entered and checked; unspecified is a + // string. + Type SettingType `protobuf:"varint,6,opt,name=type,proto3,enum=secretengine.v1.SettingType" json:"type,omitempty"` + // options are the allowed values of a select setting. + Options []string `protobuf:"bytes,7,rep,name=options,proto3" json:"options,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Setting) Reset() { + *x = Setting{} + mi := &file_secretengine_v1_secretengine_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Setting) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Setting) ProtoMessage() {} + +func (x *Setting) ProtoReflect() protoreflect.Message { + mi := &file_secretengine_v1_secretengine_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Setting.ProtoReflect.Descriptor instead. +func (*Setting) Descriptor() ([]byte, []int) { + return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{4} +} + +func (x *Setting) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Setting) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *Setting) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Setting) GetSecret() bool { + if x != nil { + return x.Secret + } + return false +} + +func (x *Setting) GetRequired() bool { + if x != nil { + return x.Required + } + return false +} + +func (x *Setting) GetType() SettingType { + if x != nil { + return x.Type + } + return SettingType_SETTING_TYPE_UNSPECIFIED +} + +func (x *Setting) GetOptions() []string { + if x != nil { + return x.Options + } + return nil +} + type ResolveRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` @@ -120,7 +370,7 @@ type ResolveRequest struct { func (x *ResolveRequest) Reset() { *x = ResolveRequest{} - mi := &file_secretengine_v1_secretengine_proto_msgTypes[2] + mi := &file_secretengine_v1_secretengine_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -132,7 +382,7 @@ func (x *ResolveRequest) String() string { func (*ResolveRequest) ProtoMessage() {} func (x *ResolveRequest) ProtoReflect() protoreflect.Message { - mi := &file_secretengine_v1_secretengine_proto_msgTypes[2] + mi := &file_secretengine_v1_secretengine_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -145,7 +395,7 @@ func (x *ResolveRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveRequest.ProtoReflect.Descriptor instead. func (*ResolveRequest) Descriptor() ([]byte, []int) { - return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{2} + return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{5} } func (x *ResolveRequest) GetKey() string { @@ -164,7 +414,7 @@ type ResolveResponse struct { func (x *ResolveResponse) Reset() { *x = ResolveResponse{} - mi := &file_secretengine_v1_secretengine_proto_msgTypes[3] + mi := &file_secretengine_v1_secretengine_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -176,7 +426,7 @@ func (x *ResolveResponse) String() string { func (*ResolveResponse) ProtoMessage() {} func (x *ResolveResponse) ProtoReflect() protoreflect.Message { - mi := &file_secretengine_v1_secretengine_proto_msgTypes[3] + mi := &file_secretengine_v1_secretengine_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -189,7 +439,7 @@ func (x *ResolveResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveResponse.ProtoReflect.Descriptor instead. func (*ResolveResponse) Descriptor() ([]byte, []int) { - return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{3} + return file_secretengine_v1_secretengine_proto_rawDescGZIP(), []int{6} } func (x *ResolveResponse) GetValue() string { @@ -213,13 +463,35 @@ const file_secretengine_v1_secretengine_proto_rawDesc = "" + "\fSecretsEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x13\n" + - "\x11ConfigureResponse\"\"\n" + + "\x11ConfigureResponse\"\x11\n" + + "\x0fDescribeRequest\"b\n" + + "\x10DescribeResponse\x12\x18\n" + + "\aversion\x18\x01 \x01(\tR\aversion\x124\n" + + "\bsettings\x18\x02 \x03(\v2\x18.secretengine.v1.SettingR\bsettings\"\xd3\x01\n" + + "\aSetting\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05label\x18\x02 \x01(\tR\x05label\x12 \n" + + "\vdescription\x18\x03 \x01(\tR\vdescription\x12\x16\n" + + "\x06secret\x18\x04 \x01(\bR\x06secret\x12\x1a\n" + + "\brequired\x18\x05 \x01(\bR\brequired\x120\n" + + "\x04type\x18\x06 \x01(\x0e2\x1c.secretengine.v1.SettingTypeR\x04type\x12\x18\n" + + "\aoptions\x18\a \x03(\tR\aoptions\"\"\n" + "\x0eResolveRequest\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\"'\n" + "\x0fResolveResponse\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value2\xb7\x01\n" + + "\x05value\x18\x01 \x01(\tR\x05value*\xd9\x01\n" + + "\vSettingType\x12\x1c\n" + + "\x18SETTING_TYPE_UNSPECIFIED\x10\x00\x12\x17\n" + + "\x13SETTING_TYPE_STRING\x10\x01\x12\x17\n" + + "\x13SETTING_TYPE_NUMBER\x10\x02\x12\x18\n" + + "\x14SETTING_TYPE_BOOLEAN\x10\x03\x12\x19\n" + + "\x15SETTING_TYPE_DURATION\x10\x04\x12\x15\n" + + "\x11SETTING_TYPE_LIST\x10\x05\x12\x17\n" + + "\x13SETTING_TYPE_SELECT\x10\x06\x12\x15\n" + + "\x11SETTING_TYPE_TEXT\x10\a2\x88\x02\n" + "\x13SecretEngineService\x12R\n" + - "\tConfigure\x12!.secretengine.v1.ConfigureRequest\x1a\".secretengine.v1.ConfigureResponse\x12L\n" + + "\tConfigure\x12!.secretengine.v1.ConfigureRequest\x1a\".secretengine.v1.ConfigureResponse\x12O\n" + + "\bDescribe\x12 .secretengine.v1.DescribeRequest\x1a!.secretengine.v1.DescribeResponse\x12L\n" + "\aResolve\x12\x1f.secretengine.v1.ResolveRequest\x1a .secretengine.v1.ResolveResponseB\xdc\x01\n" + "\x13com.secretengine.v1B\x11SecretengineProtoP\x01ZUgithub.com/samcharles93/archie-core/internal/contracts/secretengine/v1;secretenginev1\xa2\x02\x03SXX\xaa\x02\x0fSecretengine.V1\xca\x02\x0fSecretengine\\V1\xe2\x02\x1bSecretengine\\V1\\GPBMetadata\xea\x02\x10Secretengine::V1b\x06proto3" @@ -235,27 +507,36 @@ func file_secretengine_v1_secretengine_proto_rawDescGZIP() []byte { return file_secretengine_v1_secretengine_proto_rawDescData } -var file_secretengine_v1_secretengine_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_secretengine_v1_secretengine_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_secretengine_v1_secretengine_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_secretengine_v1_secretengine_proto_goTypes = []any{ - (*ConfigureRequest)(nil), // 0: secretengine.v1.ConfigureRequest - (*ConfigureResponse)(nil), // 1: secretengine.v1.ConfigureResponse - (*ResolveRequest)(nil), // 2: secretengine.v1.ResolveRequest - (*ResolveResponse)(nil), // 3: secretengine.v1.ResolveResponse - nil, // 4: secretengine.v1.ConfigureRequest.SettingsEntry - nil, // 5: secretengine.v1.ConfigureRequest.SecretsEntry + (SettingType)(0), // 0: secretengine.v1.SettingType + (*ConfigureRequest)(nil), // 1: secretengine.v1.ConfigureRequest + (*ConfigureResponse)(nil), // 2: secretengine.v1.ConfigureResponse + (*DescribeRequest)(nil), // 3: secretengine.v1.DescribeRequest + (*DescribeResponse)(nil), // 4: secretengine.v1.DescribeResponse + (*Setting)(nil), // 5: secretengine.v1.Setting + (*ResolveRequest)(nil), // 6: secretengine.v1.ResolveRequest + (*ResolveResponse)(nil), // 7: secretengine.v1.ResolveResponse + nil, // 8: secretengine.v1.ConfigureRequest.SettingsEntry + nil, // 9: secretengine.v1.ConfigureRequest.SecretsEntry } var file_secretengine_v1_secretengine_proto_depIdxs = []int32{ - 4, // 0: secretengine.v1.ConfigureRequest.settings:type_name -> secretengine.v1.ConfigureRequest.SettingsEntry - 5, // 1: secretengine.v1.ConfigureRequest.secrets:type_name -> secretengine.v1.ConfigureRequest.SecretsEntry - 0, // 2: secretengine.v1.SecretEngineService.Configure:input_type -> secretengine.v1.ConfigureRequest - 2, // 3: secretengine.v1.SecretEngineService.Resolve:input_type -> secretengine.v1.ResolveRequest - 1, // 4: secretengine.v1.SecretEngineService.Configure:output_type -> secretengine.v1.ConfigureResponse - 3, // 5: secretengine.v1.SecretEngineService.Resolve:output_type -> secretengine.v1.ResolveResponse - 4, // [4:6] is the sub-list for method output_type - 2, // [2:4] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 8, // 0: secretengine.v1.ConfigureRequest.settings:type_name -> secretengine.v1.ConfigureRequest.SettingsEntry + 9, // 1: secretengine.v1.ConfigureRequest.secrets:type_name -> secretengine.v1.ConfigureRequest.SecretsEntry + 5, // 2: secretengine.v1.DescribeResponse.settings:type_name -> secretengine.v1.Setting + 0, // 3: secretengine.v1.Setting.type:type_name -> secretengine.v1.SettingType + 1, // 4: secretengine.v1.SecretEngineService.Configure:input_type -> secretengine.v1.ConfigureRequest + 3, // 5: secretengine.v1.SecretEngineService.Describe:input_type -> secretengine.v1.DescribeRequest + 6, // 6: secretengine.v1.SecretEngineService.Resolve:input_type -> secretengine.v1.ResolveRequest + 2, // 7: secretengine.v1.SecretEngineService.Configure:output_type -> secretengine.v1.ConfigureResponse + 4, // 8: secretengine.v1.SecretEngineService.Describe:output_type -> secretengine.v1.DescribeResponse + 7, // 9: secretengine.v1.SecretEngineService.Resolve:output_type -> secretengine.v1.ResolveResponse + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_secretengine_v1_secretengine_proto_init() } @@ -268,13 +549,14 @@ func file_secretengine_v1_secretengine_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_secretengine_v1_secretengine_proto_rawDesc), len(file_secretengine_v1_secretengine_proto_rawDesc)), - NumEnums: 0, - NumMessages: 6, + NumEnums: 1, + NumMessages: 9, NumExtensions: 0, NumServices: 1, }, GoTypes: file_secretengine_v1_secretengine_proto_goTypes, DependencyIndexes: file_secretengine_v1_secretengine_proto_depIdxs, + EnumInfos: file_secretengine_v1_secretengine_proto_enumTypes, MessageInfos: file_secretengine_v1_secretengine_proto_msgTypes, }.Build() File_secretengine_v1_secretengine_proto = out.File diff --git a/internal/contracts/secretengine/v1/secretengine_grpc.pb.go b/internal/contracts/secretengine/v1/secretengine_grpc.pb.go index 18961e554..b7101d210 100644 --- a/internal/contracts/secretengine/v1/secretengine_grpc.pb.go +++ b/internal/contracts/secretengine/v1/secretengine_grpc.pb.go @@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion9 const ( SecretEngineService_Configure_FullMethodName = "/secretengine.v1.SecretEngineService/Configure" + SecretEngineService_Describe_FullMethodName = "/secretengine.v1.SecretEngineService/Describe" SecretEngineService_Resolve_FullMethodName = "/secretengine.v1.SecretEngineService/Resolve" ) @@ -35,6 +36,9 @@ type SecretEngineServiceClient interface { // before any Resolve. It is the only channel for configuration: the plugin // process does not inherit the host environment. Configure(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureResponse, error) + // Describe names the engine's release and the settings it reads, which the + // dashboard renders as a form. + Describe(ctx context.Context, in *DescribeRequest, opts ...grpc.CallOption) (*DescribeResponse, error) // Resolve returns the value for key. An unknown key is NOT_FOUND. Resolve(ctx context.Context, in *ResolveRequest, opts ...grpc.CallOption) (*ResolveResponse, error) } @@ -57,6 +61,16 @@ func (c *secretEngineServiceClient) Configure(ctx context.Context, in *Configure return out, nil } +func (c *secretEngineServiceClient) Describe(ctx context.Context, in *DescribeRequest, opts ...grpc.CallOption) (*DescribeResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DescribeResponse) + err := c.cc.Invoke(ctx, SecretEngineService_Describe_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *secretEngineServiceClient) Resolve(ctx context.Context, in *ResolveRequest, opts ...grpc.CallOption) (*ResolveResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ResolveResponse) @@ -79,6 +93,9 @@ type SecretEngineServiceServer interface { // before any Resolve. It is the only channel for configuration: the plugin // process does not inherit the host environment. Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error) + // Describe names the engine's release and the settings it reads, which the + // dashboard renders as a form. + Describe(context.Context, *DescribeRequest) (*DescribeResponse, error) // Resolve returns the value for key. An unknown key is NOT_FOUND. Resolve(context.Context, *ResolveRequest) (*ResolveResponse, error) mustEmbedUnimplementedSecretEngineServiceServer() @@ -94,6 +111,9 @@ type UnimplementedSecretEngineServiceServer struct{} func (UnimplementedSecretEngineServiceServer) Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error) { return nil, status.Error(codes.Unimplemented, "method Configure not implemented") } +func (UnimplementedSecretEngineServiceServer) Describe(context.Context, *DescribeRequest) (*DescribeResponse, error) { + return nil, status.Error(codes.Unimplemented, "method Describe not implemented") +} func (UnimplementedSecretEngineServiceServer) Resolve(context.Context, *ResolveRequest) (*ResolveResponse, error) { return nil, status.Error(codes.Unimplemented, "method Resolve not implemented") } @@ -136,6 +156,24 @@ func _SecretEngineService_Configure_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _SecretEngineService_Describe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DescribeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SecretEngineServiceServer).Describe(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SecretEngineService_Describe_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SecretEngineServiceServer).Describe(ctx, req.(*DescribeRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _SecretEngineService_Resolve_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ResolveRequest) if err := dec(in); err != nil { @@ -165,6 +203,10 @@ var SecretEngineService_ServiceDesc = grpc.ServiceDesc{ MethodName: "Configure", Handler: _SecretEngineService_Configure_Handler, }, + { + MethodName: "Describe", + Handler: _SecretEngineService_Describe_Handler, + }, { MethodName: "Resolve", Handler: _SecretEngineService_Resolve_Handler, diff --git a/modules/connectors/connector.go b/modules/connectors/connector.go index 1c375b10a..f40f5c9c7 100644 --- a/modules/connectors/connector.go +++ b/modules/connectors/connector.go @@ -128,6 +128,7 @@ type Tool interface { // Connector is a running connector and what it declared. type Connector struct { name string + version string client pb.ConnectorServiceClient eventTypes map[string]*jsonschema.Resolved actions map[string]action @@ -138,6 +139,8 @@ type Connector struct { listens bool // facts says it answers TargetFacts. facts bool + // settings is the schema it declared for its operator settings. + settings []Setting } // open configures a connector and reads its declaration. @@ -153,13 +156,17 @@ func open(ctx context.Context, name string, client pb.ConnectorServiceClient, se return nil, fmt.Errorf("connector %q speaks contract %q, the host speaks %q", name, desc.GetContract(), contractVersion) } c := &Connector{ - name: name, client: client, + name: name, version: desc.GetVersion(), client: client, eventTypes: map[string]*jsonschema.Resolved{}, actions: map[string]action{}, lookups: map[string]lookup{}, deliveries: map[string]*jsonschema.Resolved{}, listens: desc.GetListens(), facts: desc.GetTargetFacts(), + settings: connectorSettings(desc.GetSettings()), + } + if err := validateSettingsSchema(c.settings); err != nil { + return nil, fmt.Errorf("connector %q: %w", name, err) } return c, c.load(desc) } @@ -303,6 +310,12 @@ func (c *Connector) Declarations() []Declaration { // Name is the connector's accepted name. func (c *Connector) Name() string { return c.name } +// Version is the connector's own release, as it described itself. +func (c *Connector) Version() string { return c.version } + +// SettingsSchema is what the connector declared an operator enters. +func (c *Connector) SettingsSchema() []Setting { return c.settings } + // Parse turns a payload the caller has already verified into typed events, // each checked against its declared schema. func (c *Connector) Parse(ctx context.Context, body []byte, headers map[string]string) ([]Event, error) { diff --git a/modules/connectors/credentials.go b/modules/connectors/credentials.go index 62d4bcc14..fb2c762ae 100644 --- a/modules/connectors/credentials.go +++ b/modules/connectors/credentials.go @@ -100,24 +100,77 @@ func (m *Module) listCredentials(w http.ResponseWriter, r *http.Request) { } views := make([]credentialView, 0, len(creds)) for _, c := range creds { - fields, err := m.openCredential(c) + view, err := m.credentialViewOf(c) if err != nil { m.log.ErrorContext(r.Context(), "open credential", "credential", c.Name, "error", err) httpjson.Error(w, http.StatusInternalServerError, "couldn't open credential "+c.Name) return } - view := credentialView{Name: c.Name, Kind: c.Kind, Fields: map[string]string{}} - for name, f := range fields { - view.Fields[name] = "stored" - if f.Engine != "" { - view.Fields[name] = f.Engine + ":" + f.Key - } - } views = append(views, view) } httpjson.Write(w, http.StatusOK, views) } +func (m *Module) getCredential(w http.ResponseWriter, r *http.Request) { + name := r.PathValue("name") + c, ok, err := m.store.Credential(r.Context(), m.orgID, name) + if err != nil { + m.log.ErrorContext(r.Context(), "read credential", "credential", name, "error", err) + httpjson.Error(w, http.StatusInternalServerError, "couldn't read the credential") + return + } + if !ok { + httpjson.Error(w, http.StatusNotFound, "no such credential") + return + } + view, err := m.credentialViewOf(c) + if err != nil { + m.log.ErrorContext(r.Context(), "open credential", "credential", name, "error", err) + httpjson.Error(w, http.StatusInternalServerError, "couldn't open the credential") + return + } + httpjson.Write(w, http.StatusOK, view) +} + +// credentialViewOf says where each field comes from: stored, or the secret +// engine and key that resolves it. The value is never returned. +func (m *Module) credentialViewOf(c store.Credential) (credentialView, error) { + fields, err := m.openCredential(c) + if err != nil { + return credentialView{}, err + } + view := credentialView{Name: c.Name, Kind: c.Kind, Fields: map[string]string{}} + for name, f := range fields { + view.Fields[name] = "stored" + if f.Engine != "" { + view.Fields[name] = f.Engine + ":" + f.Key + } + } + return view, nil +} + +// BearerToken returns the token a bearer credential holds, resolved through an +// engine when it names one. It is how a setting references a credential by +// name without the dashboard ever reading the value. +func (m *Module) BearerToken(ctx context.Context, name string) (string, error) { + c, ok, err := m.store.Credential(ctx, m.orgID, name) + if err != nil { + return "", err + } + if !ok { + return "", fmt.Errorf("credential %q doesn't exist", name) + } + fields, err := m.openCredential(c) + if err != nil { + return "", err + } + f, ok := fields["token"] + if !ok { + return "", fmt.Errorf("credential %q has no token field", name) + } + return m.resolveField(ctx, store.Accepted{}, f) +} + func checkCredential(req credentialRequest) error { required, optional, ok := kindFields(req.Kind) if !ok { diff --git a/modules/connectors/credentials_test.go b/modules/connectors/credentials_test.go new file mode 100644 index 000000000..00daa2e8b --- /dev/null +++ b/modules/connectors/credentials_test.go @@ -0,0 +1,71 @@ +package connectors + +import ( + "context" + json "encoding/json/v2" + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "filippo.io/age" + + "github.com/samcharles93/archie-core/modules/connectors/internal/seal" + "github.com/samcharles93/archie-core/modules/connectors/internal/store" +) + +// TestCredentialRoutesNeverReturnASecret guards the credential boundary: a +// list or a read says where each field comes from and never what it holds. +func TestCredentialRoutesNeverReturnASecret(t *testing.T) { + id, err := age.GenerateX25519Identity() + if err != nil { + t.Fatal(err) + } + sealer, err := seal.New(id.String(), nil) + if err != nil { + t.Fatal(err) + } + const secret = "plainly-fake-value-the-route-must-not-return" + plain, err := json.Marshal(map[string]Field{"token": {Value: secret}}) + if err != nil { + t.Fatal(err) + } + sealed, err := sealer.Seal("default/ops/bearer", plain) + if err != nil { + t.Fatal(err) + } + module := &Module{ + orgID: "default", + log: slog.New(slog.DiscardHandler), + store: &fakeRegistry{creds: []store.Credential{ + {OrgID: "default", Name: "ops", Kind: "bearer", Sealed: sealed}, + }}, + sealer: sealer, + } + + for _, tt := range []struct { + name string + call func(http.ResponseWriter, *http.Request) + }{ + {name: "list", call: module.listCredentials}, + {name: "read", call: module.getCredential}, + } { + t.Run(tt.name, func(t *testing.T) { + rec := httptest.NewRecorder() + req := httptest.NewRequestWithContext(context.Background(), http.MethodGet, "/api/credentials", nil) + req.SetPathValue("name", "ops") + tt.call(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status %d: %s", rec.Code, rec.Body.String()) + } + body := rec.Body.String() + if strings.Contains(body, secret) { + t.Fatalf("the route returned the secret: %s", body) + } + if !strings.Contains(body, "stored") { + t.Fatalf("the route didn't say the field is stored: %s", body) + } + }) + } +} diff --git a/modules/connectors/engines.go b/modules/connectors/engines.go index 85ff19e85..6ea945ec6 100644 --- a/modules/connectors/engines.go +++ b/modules/connectors/engines.go @@ -28,10 +28,18 @@ var ErrSecretNotFound = errors.New("secret engine holds no such key") // Engine is a running secret engine: an extension that resolves the keys // credentials name, such as entries in a sops file. type Engine struct { - name string - client sepb.SecretEngineServiceClient + name string + version string + settings []Setting + client sepb.SecretEngineServiceClient } +// Version is the engine's own release, as it described itself. +func (e *Engine) Version() string { return e.version } + +// SettingsSchema is what the engine declared an operator enters. +func (e *Engine) SettingsSchema() []Setting { return e.settings } + // Resolve returns the secret the engine holds under key. func (e *Engine) Resolve(ctx context.Context, key string) (string, error) { ctx, cancel := context.WithTimeout(ctx, resolveTimeout) @@ -64,7 +72,22 @@ func (h *Host) StartEngine(ctx context.Context, spec Spec) (*Engine, error) { h.procs.Stop(spec.Name) return nil, fmt.Errorf("secret engine %q: configure: %w", spec.Name, err) } - return &Engine{name: spec.Name, client: client}, nil + e := &Engine{name: spec.Name, client: client} + desc, err := client.Describe(ctx, &sepb.DescribeRequest{}) + if status.Code(err) == codes.Unimplemented { + // An engine built before settings were declarable still runs. + return e, nil + } + if err != nil { + h.procs.Stop(spec.Name) + return nil, fmt.Errorf("secret engine %q: describe: %w", spec.Name, err) + } + e.version, e.settings = desc.GetVersion(), engineSettings(desc.GetSettings()) + if err := validateSettingsSchema(e.settings); err != nil { + h.procs.Stop(spec.Name) + return nil, fmt.Errorf("secret engine %q: %w", spec.Name, err) + } + return e, nil } // enginePlugin is the host side of the go-plugin handshake for secret engines. diff --git a/modules/connectors/guards.go b/modules/connectors/guards.go index d5db3f42e..56ad4a309 100644 --- a/modules/connectors/guards.go +++ b/modules/connectors/guards.go @@ -90,13 +90,18 @@ type Guard struct { version string digest string advisory bool + values map[string]string + settings []Setting client gpb.GuardServiceClient } // NewGuard wraps a client of a guard extension. digest is the package digest // recorded with every verdict. -func NewGuard(name, version, digest string, advisory bool, client gpb.GuardServiceClient) *Guard { - return &Guard{name: name, version: version, digest: digest, advisory: advisory, client: client} +func NewGuard(name, version, digest string, advisory bool, values map[string]string, settings []Setting, client gpb.GuardServiceClient) *Guard { + return &Guard{ + name: name, version: version, digest: digest, advisory: advisory, + values: values, settings: settings, client: client, + } } // Name is the guard's name in verdicts. @@ -111,6 +116,14 @@ func (g *Guard) Digest() string { return g.digest } // Advisory says the guard's verdicts set no ceiling. func (g *Guard) Advisory() bool { return g.advisory } +// SettingsSchema is what the guard declared an operator enters, including the +// judge it asks. +func (g *Guard) SettingsSchema() []Setting { return g.settings } + +// Settings is what the guard was configured with. A secret is the reference +// the guard resolves, never its value. +func (g *Guard) Settings() map[string]string { return g.values } + // Judge asks the guard about one action. ctx bounds the wait. func (g *Guard) Judge(ctx context.Context, r GuardRequest) (GuardAnswer, error) { evidence := make([]*gpb.Evidence, 0, len(r.Evidence)) @@ -197,7 +210,12 @@ func (h *Host) StartGuard(ctx context.Context, spec Spec) (*Guard, error) { h.procs.Stop(spec.Name) return nil, fmt.Errorf("guard %q: describe: %w", spec.Name, err) } - return NewGuard(spec.Name, desc.GetVersion(), spec.SHA256, desc.GetAdvisory(), client), nil + settings := guardSettings(desc.GetSettings()) + if err := validateSettingsSchema(settings); err != nil { + h.procs.Stop(spec.Name) + return nil, fmt.Errorf("guard %q: %w", spec.Name, err) + } + return NewGuard(spec.Name, desc.GetVersion(), spec.SHA256, desc.GetAdvisory(), spec.Settings, settings, client), nil } // guardPlugin is the host side of the go-plugin handshake for guards. diff --git a/modules/connectors/list.go b/modules/connectors/list.go new file mode 100644 index 000000000..0b8e0bd8b --- /dev/null +++ b/modules/connectors/list.go @@ -0,0 +1,142 @@ +package connectors + +import ( + "encoding/json/jsontext" + json "encoding/json/v2" + "fmt" + "net/http" + + "github.com/samcharles93/archie-core/internal/platform/httpjson" + "github.com/samcharles93/archie-core/modules/connectors/internal/store" +) + +// ExtensionView is one accepted package as the dashboard shows it: what it is, +// whether it is running, and the settings and credential slots it was given. +// It never carries a secret: a credential is named, and a secret setting is +// the reference the extension resolves. +type ExtensionView struct { + Name string `json:"name"` + Contract string `json:"contract"` + State string `json:"state"` + Error string `json:"error,omitempty"` + Version string `json:"version,omitempty"` + Digest string `json:"digest"` + Path string `json:"path,omitempty"` + URL string `json:"url,omitempty"` + Args []string `json:"args,omitempty"` + Egress []string `json:"egress"` + Env []string `json:"env"` + Settings map[string]string `json:"settings"` + SettingsSchema []Setting `json:"settings_schema"` + Credentials map[string]string `json:"credentials"` + Tools jsontext.Value `json:"tools,omitempty"` +} + +// list returns the accepted packages of one contract, in name order. +func (m *Module) list(contract string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + accepted, err := m.store.List(r.Context(), m.orgID) + if err != nil { + m.log.ErrorContext(r.Context(), "list accepted packages", "contract", contract, "error", err) + httpjson.Error(w, http.StatusInternalServerError, "couldn't read the accepted packages") + return + } + views := make([]ExtensionView, 0, len(accepted)) + for _, a := range accepted { + if a.Contract != contract { + continue + } + view, err := m.viewOf(a) + if err != nil { + m.log.ErrorContext(r.Context(), "read accepted package", "package", a.Name, "error", err) + httpjson.Error(w, http.StatusInternalServerError, "couldn't read "+a.Name) + return + } + views = append(views, view) + } + httpjson.Write(w, http.StatusOK, views) + } +} + +func (m *Module) viewOf(a store.Accepted) (ExtensionView, error) { + view := ExtensionView{ + Name: a.Name, Contract: a.Contract, Digest: a.SHA256, Path: a.Path, URL: a.URL, + Args: a.Args, Egress: a.Egress, Env: a.Env, Tools: a.Tools, + Settings: map[string]string{}, Credentials: map[string]string{}, SettingsSchema: []Setting{}, + } + if len(a.Settings) > 0 { + if err := json.Unmarshal(a.Settings, &view.Settings); err != nil { + return ExtensionView{}, fmt.Errorf("settings: %w", err) + } + } + if len(a.Credentials) > 0 { + if err := json.Unmarshal(a.Credentials, &view.Credentials); err != nil { + return ExtensionView{}, fmt.Errorf("credentials: %w", err) + } + } + state, reason, version, schema := m.stateOf(a) + view.State, view.Error, view.Version, view.SettingsSchema = state, reason, version, schema + return view, nil +} + +// stateOf reports whether a package is running, and what it declared. +func (m *Module) stateOf(a store.Accepted) (state, reason, version string, schema []Setting) { + m.mu.RLock() + reason = m.failed[a.Name] + connector, running := m.running[a.Name] + engine, isEngine := m.engines[a.Name] + guard, isGuard := m.guards[a.Name] + server, isServer := m.servers[a.Name] + m.mu.RUnlock() + + switch { + case reason != "": + return "failed", reason, "", nil + case running: + return "running", "", connector.Version(), connector.SettingsSchema() + case isEngine: + return "running", "", engine.Version(), engine.SettingsSchema() + case isGuard: + return "running", "", guard.Version(), guard.SettingsSchema() + case isServer: + if err := server.Ready(); err != nil { + return "failed", err.Error(), "", server.SettingsSchema() + } + return "running", "", "", server.SettingsSchema() + } + return "stopped", "", "", nil +} + +// schemaOf returns the settings schema of a package that is running now. +func (m *Module) schemaOf(name string) ([]Setting, bool) { + m.mu.RLock() + defer m.mu.RUnlock() + switch { + case m.running[name] != nil: + return m.running[name].SettingsSchema(), true + case m.engines[name] != nil: + return m.engines[name].SettingsSchema(), true + case m.guards[name] != nil: + return m.guards[name].SettingsSchema(), true + case m.servers[name] != nil: + return m.servers[name].SettingsSchema(), true + } + return nil, false +} + +// checkAccepted checks an acceptance's settings against the schema the package +// declared, once it is known. +func (m *Module) checkAccepted(a store.Accepted) error { + schema, ok := m.schemaOf(a.Name) + if !ok || len(schema) == 0 { + return nil + } + var values map[string]string + if len(a.Settings) > 0 { + if err := json.Unmarshal(a.Settings, &values); err != nil { + return fmt.Errorf("settings: %w", err) + } + } + _, err := checkSettings(schema, values) + return err +} diff --git a/modules/connectors/mcp.go b/modules/connectors/mcp.go index 8626991e0..b0bb130f7 100644 --- a/modules/connectors/mcp.go +++ b/modules/connectors/mcp.go @@ -125,6 +125,17 @@ func (h *Host) NewServer(spec ServerSpec) *Server { return s } +// SettingsSchema names the environment settings the acceptance gave a stdio +// server. MCP has no configuration channel, so the keys are the declaration. +func (s *Server) SettingsSchema() []Setting { + out := make([]Setting, 0, len(s.spec.Settings)) + for _, kv := range s.spec.Settings { + key, _, _ := strings.Cut(kv, "=") + out = append(out, Setting{Key: key, Label: key}) + } + return out +} + // Declarations lists the tools the acceptance permits, in name order. func (s *Server) Declarations() []Declaration { s.mu.Lock() diff --git a/modules/connectors/mcpaccept.go b/modules/connectors/mcpaccept.go index f300d18c1..d9e46b66d 100644 --- a/modules/connectors/mcpaccept.go +++ b/modules/connectors/mcpaccept.go @@ -158,6 +158,15 @@ func (m *Module) acceptServer(w http.ResponseWriter, r *http.Request) { httpjson.Error(w, http.StatusUnprocessableEntity, err.Error()) return } + if err := m.checkAccepted(a); err != nil { + _, _ = m.store.Delete(context.WithoutCancel(r.Context()), m.orgID, name) + m.release(name) + m.mu.Lock() + delete(m.failed, name) + m.mu.Unlock() + httpjson.Error(w, http.StatusUnprocessableEntity, err.Error()) + return + } httpjson.Write(w, http.StatusOK, map[string]string{"name": name, "state": "running"}) } diff --git a/modules/connectors/module.go b/modules/connectors/module.go index 6fd994fc9..78267d36c 100644 --- a/modules/connectors/module.go +++ b/modules/connectors/module.go @@ -261,6 +261,11 @@ func (m *Module) Routes(mux *http.ServeMux, guard func(http.Handler) http.Handle mux.Handle("DELETE /api/mcp-servers/{name}", guard(m.remove(store.ContractMCP))) mux.Handle("PUT /api/credentials/{name}", guard(http.HandlerFunc(m.putCredential))) mux.Handle("GET /api/credentials", guard(http.HandlerFunc(m.listCredentials))) + mux.Handle("GET /api/credentials/{name}", guard(http.HandlerFunc(m.getCredential))) + mux.Handle("GET /api/connectors", guard(m.list(store.ContractConnector))) + mux.Handle("GET /api/secret-engines", guard(m.list(store.ContractSecretEngine))) + mux.Handle("GET /api/guards", guard(m.list(store.ContractGuard))) + mux.Handle("GET /api/mcp-servers", guard(m.list(store.ContractMCP))) } type acceptRequest struct { @@ -314,6 +319,18 @@ func (m *Module) acceptAs(w http.ResponseWriter, r *http.Request, contract strin httpjson.Error(w, http.StatusUnprocessableEntity, err.Error()) return } + // The extension declares its settings when it starts. A value it doesn't + // declare, or a required one that is missing, is refused now rather than + // left for the extension to misread. + if err := m.checkAccepted(a); err != nil { + _, _ = m.store.Delete(context.WithoutCancel(r.Context()), m.orgID, name) + m.release(name) + m.mu.Lock() + delete(m.failed, name) + m.mu.Unlock() + httpjson.Error(w, http.StatusUnprocessableEntity, err.Error()) + return + } httpjson.Write(w, http.StatusOK, map[string]string{"name": name, "state": "running"}) } diff --git a/modules/connectors/remove_test.go b/modules/connectors/remove_test.go index 16c42c768..8dcf6496b 100644 --- a/modules/connectors/remove_test.go +++ b/modules/connectors/remove_test.go @@ -37,7 +37,12 @@ func (f *fakeRegistry) Delete(_ context.Context, _, name string) (bool, error) { return ok, nil } -func (f *fakeRegistry) Credential(context.Context, string, string) (store.Credential, bool, error) { +func (f *fakeRegistry) Credential(_ context.Context, _, name string) (store.Credential, bool, error) { + for _, c := range f.creds { + if c.Name == name { + return c, true, nil + } + } return store.Credential{}, false, nil } diff --git a/modules/connectors/settings.go b/modules/connectors/settings.go new file mode 100644 index 000000000..c4aa65e07 --- /dev/null +++ b/modules/connectors/settings.go @@ -0,0 +1,251 @@ +package connectors + +import ( + "fmt" + "regexp" + "slices" + "strconv" + "strings" + "time" + + cpb "github.com/samcharles93/archie-core/internal/contracts/connector/v1" + gpb "github.com/samcharles93/archie-core/internal/contracts/guard/v1" + sepb "github.com/samcharles93/archie-core/internal/contracts/secretengine/v1" +) + +// Setting is one value an operator enters for an extension to run. The +// extension declares it, and the dashboard renders it. +type Setting struct { + Key string `json:"key"` + Label string `json:"label"` + Description string `json:"description,omitempty"` + Secret bool `json:"secret,omitempty"` + Required bool `json:"required,omitempty"` + Type string `json:"type,omitempty"` + Options []string `json:"options,omitempty"` +} + +// Setting types. The empty type is a string. +const ( + SettingString = "string" + SettingNumber = "number" + SettingBoolean = "boolean" + SettingDuration = "duration" + SettingList = "list" + SettingSelect = "select" + SettingText = "text" +) + +// kind returns the setting's type with the default applied. +func (s Setting) kind() string { + if s.Type == "" { + return SettingString + } + return s.Type +} + +var settingKey = regexp.MustCompile(`^[a-z][a-z0-9_]*$`) + +// validateSettingsSchema checks what an extension declared, so a broken schema +// is reported when it starts rather than when a value is edited. +func validateSettingsSchema(settings []Setting) error { + seen := make(map[string]bool, len(settings)) + for _, s := range settings { + switch { + case !settingKey.MatchString(s.Key): + return fmt.Errorf("setting %q must be lower-case letters, digits and underscores", s.Key) + case seen[s.Key]: + return fmt.Errorf("setting %q is declared twice", s.Key) + case strings.TrimSpace(s.Label) == "": + return fmt.Errorf("setting %q needs a label", s.Key) + case s.Secret != strings.HasSuffix(s.Key, "_ref"): + return fmt.Errorf("setting %q: a secret setting's key ends in _ref, and only a secret's does", s.Key) + } + if err := s.validateType(); err != nil { + return err + } + seen[s.Key] = true + } + return nil +} + +func (s Setting) validateType() error { + switch s.kind() { + case SettingString, SettingNumber, SettingBoolean, SettingDuration, SettingList, SettingSelect, SettingText: + default: + return fmt.Errorf("setting %q: unknown type %q", s.Key, s.Type) + } + if s.Secret && s.kind() != SettingString { + return fmt.Errorf("setting %q: a secret setting is a string", s.Key) + } + if s.Required && s.kind() == SettingBoolean { + return fmt.Errorf("setting %q: a boolean cannot be required, false counts as filled", s.Key) + } + if s.kind() != SettingSelect { + if len(s.Options) > 0 { + return fmt.Errorf("setting %q: options belong to a select setting", s.Key) + } + return nil + } + if len(s.Options) == 0 { + return fmt.Errorf("setting %q: a select setting needs options", s.Key) + } + return nil +} + +// checkSettings checks values against the schema the extension declared and +// returns them trimmed, with empty values dropped. +func checkSettings(schema []Setting, values map[string]string) (map[string]string, error) { + declared := make(map[string]Setting, len(schema)) + for _, s := range schema { + declared[s.Key] = s + } + out := make(map[string]string, len(values)) + for key, value := range values { + s, ok := declared[key] + if !ok { + return nil, fmt.Errorf("setting %q is not declared by the extension", key) + } + value = strings.TrimSpace(value) + if value == "" { + continue + } + checked, err := typedValue(s, value) + if err != nil { + return nil, err + } + out[key] = checked + } + for _, s := range schema { + if s.Required && out[s.Key] == "" { + return nil, fmt.Errorf("%s is required", s.Label) + } + } + return out, nil +} + +// typedValue checks a non-empty value against the setting's type and returns +// its normalised form. +func typedValue(s Setting, value string) (string, error) { + if s.Secret { + if err := checkSecretRef(s.Label, value); err != nil { + return "", err + } + } + switch s.kind() { + case SettingNumber: + return checkNumber(s.Label, value) + case SettingBoolean: + return checkBoolean(s.Label, value) + case SettingDuration: + return checkDuration(s.Label, value) + case SettingList: + return checkList(s.Label, value) + case SettingSelect: + return checkSelect(s, value) + } + return value, nil +} + +func checkSecretRef(label, value string) error { + engine, ref, found := strings.Cut(value, ":") + if !found || engine == "" || ref == "" { + return fmt.Errorf("%s must be a secret reference (engine:key)", label) + } + return nil +} + +func checkNumber(label, value string) (string, error) { + if _, err := strconv.ParseFloat(value, 64); err != nil { + return "", fmt.Errorf("%s must be a number", label) + } + return value, nil +} + +func checkBoolean(label, value string) (string, error) { + if value != "true" && value != "false" { + return "", fmt.Errorf("%s must be true or false", label) + } + return value, nil +} + +func checkDuration(label, value string) (string, error) { + if d, err := time.ParseDuration(value); err != nil || d <= 0 { + return "", fmt.Errorf("%s must be a duration such as 30s", label) + } + return value, nil +} + +func checkList(label, value string) (string, error) { + items := strings.Split(value, ",") + for i, item := range items { + items[i] = strings.TrimSpace(item) + if items[i] == "" { + return "", fmt.Errorf("%s must be a comma-separated list without empty items", label) + } + } + return strings.Join(items, ","), nil +} + +func checkSelect(s Setting, value string) (string, error) { + if !slices.Contains(s.Options, value) { + return "", fmt.Errorf("%s must be one of %s", s.Label, strings.Join(s.Options, ", ")) + } + return value, nil +} + +// settingTypeName maps a declared type, wire-compatible across the extension +// contracts, to its API name. +func settingTypeName(t int32) string { + switch cpb.SettingType(t) { + case cpb.SettingType_SETTING_TYPE_NUMBER: + return SettingNumber + case cpb.SettingType_SETTING_TYPE_BOOLEAN: + return SettingBoolean + case cpb.SettingType_SETTING_TYPE_DURATION: + return SettingDuration + case cpb.SettingType_SETTING_TYPE_LIST: + return SettingList + case cpb.SettingType_SETTING_TYPE_SELECT: + return SettingSelect + case cpb.SettingType_SETTING_TYPE_TEXT: + return SettingText + } + return SettingString +} + +func connectorSettings(in []*cpb.Setting) []Setting { + out := make([]Setting, 0, len(in)) + for _, s := range in { + out = append(out, Setting{ + Key: s.GetKey(), Label: s.GetLabel(), Description: s.GetDescription(), + Secret: s.GetSecret(), Required: s.GetRequired(), Type: settingTypeName(int32(s.GetType())), + Options: s.GetOptions(), + }) + } + return out +} + +func guardSettings(in []*gpb.Setting) []Setting { + out := make([]Setting, 0, len(in)) + for _, s := range in { + out = append(out, Setting{ + Key: s.GetKey(), Label: s.GetLabel(), Description: s.GetDescription(), + Secret: s.GetSecret(), Required: s.GetRequired(), Type: settingTypeName(int32(s.GetType())), + Options: s.GetOptions(), + }) + } + return out +} + +func engineSettings(in []*sepb.Setting) []Setting { + out := make([]Setting, 0, len(in)) + for _, s := range in { + out = append(out, Setting{ + Key: s.GetKey(), Label: s.GetLabel(), Description: s.GetDescription(), + Secret: s.GetSecret(), Required: s.GetRequired(), Type: settingTypeName(int32(s.GetType())), + Options: s.GetOptions(), + }) + } + return out +} diff --git a/modules/judgement/extensions_test.go b/modules/judgement/extensions_test.go index 309033ad8..5783da1ee 100644 --- a/modules/judgement/extensions_test.go +++ b/modules/judgement/extensions_test.go @@ -50,7 +50,7 @@ func TestGuardExtensionsDecideAtTheLowestCeiling(t *testing.T) { return &gpb.JudgeResponse{Ceiling: c, Findings: []*gpb.Finding{{Text: "seen", Evidence: "log", Strength: gpb.Strength_STRENGTH_STRONG}}} } guard := func(name string, advisory bool, c *fakeGuardClient) *connectors.Guard { - return connectors.NewGuard(name, "1.0.0", "digest-"+name, advisory, c) + return connectors.NewGuard(name, "1.0.0", "digest-"+name, advisory, nil, nil, c) } tests := []struct { name string diff --git a/proto/connector/v1/connector.proto b/proto/connector/v1/connector.proto index 0c4feec28..0f2437edb 100644 --- a/proto/connector/v1/connector.proto +++ b/proto/connector/v1/connector.proto @@ -61,6 +61,37 @@ message DescribeResponse { bool listens = 6; // target_facts says the connector serves TargetFacts. bool target_facts = 7; + // settings are the values an operator enters for the connector to run, + // which the dashboard renders as a form. + repeated Setting settings = 8; + // version is the connector's own release. + string version = 9; +} + +// Setting is one value an operator enters for an extension to run. +message Setting { + string key = 1; + string label = 2; + string description = 3; + // secret says the value is a secret reference, never the secret. + bool secret = 4; + bool required = 5; + // type decides how the value is entered and checked; unspecified is a + // string. + SettingType type = 6; + // options are the allowed values of a select setting. + repeated string options = 7; +} + +enum SettingType { + SETTING_TYPE_UNSPECIFIED = 0; + SETTING_TYPE_STRING = 1; + SETTING_TYPE_NUMBER = 2; + SETTING_TYPE_BOOLEAN = 3; + SETTING_TYPE_DURATION = 4; + SETTING_TYPE_LIST = 5; + SETTING_TYPE_SELECT = 6; + SETTING_TYPE_TEXT = 7; } message EventType { diff --git a/proto/guard/v1/guard.proto b/proto/guard/v1/guard.proto index fda480db4..546eb06aa 100644 --- a/proto/guard/v1/guard.proto +++ b/proto/guard/v1/guard.proto @@ -36,6 +36,35 @@ message DescribeResponse { string version = 3; // advisory says the guard's verdicts are recorded and set no ceiling. bool advisory = 4; + // settings are the values an operator enters for the guard to run, + // including the judge it asks. The dashboard renders them as a form. + repeated Setting settings = 5; +} + +// Setting is one value an operator enters for an extension to run. +message Setting { + string key = 1; + string label = 2; + string description = 3; + // secret says the value is a secret reference, never the secret. + bool secret = 4; + bool required = 5; + // type decides how the value is entered and checked; unspecified is a + // string. + SettingType type = 6; + // options are the allowed values of a select setting. + repeated string options = 7; +} + +enum SettingType { + SETTING_TYPE_UNSPECIFIED = 0; + SETTING_TYPE_STRING = 1; + SETTING_TYPE_NUMBER = 2; + SETTING_TYPE_BOOLEAN = 3; + SETTING_TYPE_DURATION = 4; + SETTING_TYPE_LIST = 5; + SETTING_TYPE_SELECT = 6; + SETTING_TYPE_TEXT = 7; } enum Reversibility { diff --git a/proto/secretengine/v1/secretengine.proto b/proto/secretengine/v1/secretengine.proto index ddc69943e..5e7060d18 100644 --- a/proto/secretengine/v1/secretengine.proto +++ b/proto/secretengine/v1/secretengine.proto @@ -10,6 +10,9 @@ service SecretEngineService { // before any Resolve. It is the only channel for configuration: the plugin // process does not inherit the host environment. rpc Configure(ConfigureRequest) returns (ConfigureResponse); + // Describe names the engine's release and the settings it reads, which the + // dashboard renders as a form. + rpc Describe(DescribeRequest) returns (DescribeResponse); // Resolve returns the value for key. An unknown key is NOT_FOUND. rpc Resolve(ResolveRequest) returns (ResolveResponse); } @@ -21,5 +24,39 @@ message ConfigureRequest { map secrets = 2; } message ConfigureResponse {} + +message DescribeRequest {} +message DescribeResponse { + // version is the engine's own release. + string version = 1; + repeated Setting settings = 2; +} + +// Setting is one value an operator enters for an extension to run. +message Setting { + string key = 1; + string label = 2; + string description = 3; + // secret says the value is a secret reference, never the secret. + bool secret = 4; + bool required = 5; + // type decides how the value is entered and checked; unspecified is a + // string. + SettingType type = 6; + // options are the allowed values of a select setting. + repeated string options = 7; +} + +enum SettingType { + SETTING_TYPE_UNSPECIFIED = 0; + SETTING_TYPE_STRING = 1; + SETTING_TYPE_NUMBER = 2; + SETTING_TYPE_BOOLEAN = 3; + SETTING_TYPE_DURATION = 4; + SETTING_TYPE_LIST = 5; + SETTING_TYPE_SELECT = 6; + SETTING_TYPE_TEXT = 7; +} + message ResolveRequest { string key = 1; } message ResolveResponse { string value = 1; }