From 261699c944b229d501180734815e7d3ef8354b2e Mon Sep 17 00:00:00 2001 From: Bin Xin Date: Fri, 3 Nov 2023 10:41:27 -0700 Subject: [PATCH] Fix redact logic when recuring into list/map fields (#367) --- auth/opa/rpcauth/redact.go | 3 +- auth/opa/rpcauth/redact_test.go | 40 +++++ proxy/testdata/testservice.pb.go | 242 ++++++++++++++++++++------ proxy/testdata/testservice.proto | 11 ++ proxy/testdata/testservice_grpc.pb.go | 2 +- 5 files changed, 241 insertions(+), 57 deletions(-) diff --git a/auth/opa/rpcauth/redact.go b/auth/opa/rpcauth/redact.go index 5aa96085..ffec8585 100644 --- a/auth/opa/rpcauth/redact.go +++ b/auth/opa/rpcauth/redact.go @@ -92,7 +92,8 @@ func redactNestedField(message protoreflect.Message, descriptor protoreflect.Fie switch { case descriptor.IsList() && isMessage(descriptor): return redactListField(value) - case descriptor.IsMap() && isMessage(descriptor): + case descriptor.IsMap() && isMessage(descriptor.MapValue()): + // Only when map value are of Message type, we recurse. return redactMapField(value) case descriptor.Message() != nil && descriptor.Message().FullName() == anypbFullName: return redactAny(message, descriptor, value) diff --git a/auth/opa/rpcauth/redact_test.go b/auth/opa/rpcauth/redact_test.go index 9eb0d183..33205afc 100644 --- a/auth/opa/rpcauth/redact_test.go +++ b/auth/opa/rpcauth/redact_test.go @@ -21,6 +21,7 @@ import ( "testing" proxypb "github.com/Snowflake-Labs/sansshell/proxy" + "github.com/Snowflake-Labs/sansshell/proxy/testdata" httppb "github.com/Snowflake-Labs/sansshell/services/httpoverrpc" "github.com/stretchr/testify/assert" "google.golang.org/protobuf/encoding/protojson" @@ -53,6 +54,25 @@ func TestGetRedactedInput(t *testing.T) { }, } proxyReqInput, _ := NewRPCAuthInput(context.TODO(), "/Proxy.Proxy/Proxy", proxyReq.ProtoReflect().Interface()) + + testReq := testdata.TestRequest{ + ListScalar: []string{"s1"}, + ListMsg: []*testdata.MyNested{ + &testdata.MyNested{ + Fine: "ok", + Sensitive: "358===", + }, + }, + MapScalar: map[string]string{"key": "value"}, + MapMsg: map[string]*testdata.MyNested{ + "key2": &testdata.MyNested{ + Fine: "also ok", + Sensitive: "456----", + }, + }, + } + testdataInput, _ := NewRPCAuthInput(context.TODO(), "/Testdata.TestService/TestUnary", + testReq.ProtoReflect().Interface()) for _, tc := range []struct { name string createInputFn func() *RPCAuthInput @@ -102,6 +122,26 @@ func TestGetRedactedInput(t *testing.T) { assert.NoError(t, err) }, }, + { + name: "redacted nested message in map or list fields", + createInputFn: func() *RPCAuthInput { + return testdataInput + }, + assertionFn: func(result RPCAuthInput) { + messageType, _ := protoregistry.GlobalTypes.FindMessageByURL(testdataInput.MessageType) + resultMessage := messageType.New().Interface() + err := protojson.Unmarshal([]byte(result.Message), resultMessage) + assert.NoError(t, err) + + req := resultMessage.(*testdata.TestRequest) + + assert.Equal(t, "--REDACTED--", req.ListMsg[0].Sensitive) + assert.Equal(t, "--REDACTED--", req.MapMsg["key2"].Sensitive) + }, + errFunc: func(t *testing.T, err error) { + assert.NoError(t, err) + }, + }, { name: "malformed input should return err", createInputFn: func() *RPCAuthInput { diff --git a/proxy/testdata/testservice.pb.go b/proxy/testdata/testservice.pb.go index dacc0dd2..dd93141f 100644 --- a/proxy/testdata/testservice.pb.go +++ b/proxy/testdata/testservice.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v4.25.0 // source: testservice.proto package testdata @@ -35,18 +35,77 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type MyNested struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Fine string `protobuf:"bytes,1,opt,name=fine,proto3" json:"fine,omitempty"` + Sensitive string `protobuf:"bytes,2,opt,name=sensitive,proto3" json:"sensitive,omitempty"` +} + +func (x *MyNested) Reset() { + *x = MyNested{} + if protoimpl.UnsafeEnabled { + mi := &file_testservice_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MyNested) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MyNested) ProtoMessage() {} + +func (x *MyNested) ProtoReflect() protoreflect.Message { + mi := &file_testservice_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MyNested.ProtoReflect.Descriptor instead. +func (*MyNested) Descriptor() ([]byte, []int) { + return file_testservice_proto_rawDescGZIP(), []int{0} +} + +func (x *MyNested) GetFine() string { + if x != nil { + return x.Fine + } + return "" +} + +func (x *MyNested) GetSensitive() string { + if x != nil { + return x.Sensitive + } + return "" +} + type TestRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Input string `protobuf:"bytes,1,opt,name=input,proto3" json:"input,omitempty"` + Input string `protobuf:"bytes,1,opt,name=input,proto3" json:"input,omitempty"` + ListScalar []string `protobuf:"bytes,2,rep,name=list_scalar,json=listScalar,proto3" json:"list_scalar,omitempty"` + ListMsg []*MyNested `protobuf:"bytes,3,rep,name=list_msg,json=listMsg,proto3" json:"list_msg,omitempty"` + MapScalar map[string]string `protobuf:"bytes,4,rep,name=map_scalar,json=mapScalar,proto3" json:"map_scalar,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + MapMsg map[string]*MyNested `protobuf:"bytes,5,rep,name=map_msg,json=mapMsg,proto3" json:"map_msg,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *TestRequest) Reset() { *x = TestRequest{} if protoimpl.UnsafeEnabled { - mi := &file_testservice_proto_msgTypes[0] + mi := &file_testservice_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -59,7 +118,7 @@ func (x *TestRequest) String() string { func (*TestRequest) ProtoMessage() {} func (x *TestRequest) ProtoReflect() protoreflect.Message { - mi := &file_testservice_proto_msgTypes[0] + mi := &file_testservice_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -72,7 +131,7 @@ func (x *TestRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TestRequest.ProtoReflect.Descriptor instead. func (*TestRequest) Descriptor() ([]byte, []int) { - return file_testservice_proto_rawDescGZIP(), []int{0} + return file_testservice_proto_rawDescGZIP(), []int{1} } func (x *TestRequest) GetInput() string { @@ -82,6 +141,34 @@ func (x *TestRequest) GetInput() string { return "" } +func (x *TestRequest) GetListScalar() []string { + if x != nil { + return x.ListScalar + } + return nil +} + +func (x *TestRequest) GetListMsg() []*MyNested { + if x != nil { + return x.ListMsg + } + return nil +} + +func (x *TestRequest) GetMapScalar() map[string]string { + if x != nil { + return x.MapScalar + } + return nil +} + +func (x *TestRequest) GetMapMsg() map[string]*MyNested { + if x != nil { + return x.MapMsg + } + return nil +} + type TestResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -93,7 +180,7 @@ type TestResponse struct { func (x *TestResponse) Reset() { *x = TestResponse{} if protoimpl.UnsafeEnabled { - mi := &file_testservice_proto_msgTypes[1] + mi := &file_testservice_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -106,7 +193,7 @@ func (x *TestResponse) String() string { func (*TestResponse) ProtoMessage() {} func (x *TestResponse) ProtoReflect() protoreflect.Message { - mi := &file_testservice_proto_msgTypes[1] + mi := &file_testservice_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -119,7 +206,7 @@ func (x *TestResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use TestResponse.ProtoReflect.Descriptor instead. func (*TestResponse) Descriptor() ([]byte, []int) { - return file_testservice_proto_rawDescGZIP(), []int{1} + return file_testservice_proto_rawDescGZIP(), []int{2} } func (x *TestResponse) GetOutput() string { @@ -133,36 +220,62 @@ var File_testservice_proto protoreflect.FileDescriptor var file_testservice_proto_rawDesc = []byte{ 0x0a, 0x11, 0x74, 0x65, 0x73, 0x74, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x22, 0x23, 0x0a, - 0x0b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x69, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6e, 0x70, - 0x75, 0x74, 0x22, 0x26, 0x0a, 0x0c, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x32, 0xa0, 0x02, 0x0a, 0x0b, 0x54, - 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3c, 0x0a, 0x09, 0x54, 0x65, - 0x73, 0x74, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x12, 0x15, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x10, 0x54, 0x65, 0x73, 0x74, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x15, 0x2e, 0x54, + 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x22, 0x41, 0x0a, + 0x08, 0x4d, 0x79, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6e, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6e, 0x65, 0x12, 0x21, 0x0a, + 0x09, 0x73, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x03, 0x80, 0x01, 0x01, 0x52, 0x09, 0x73, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, + 0x22, 0x81, 0x03, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, + 0x63, 0x61, 0x6c, 0x61, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x73, + 0x74, 0x53, 0x63, 0x61, 0x6c, 0x61, 0x72, 0x12, 0x2d, 0x0a, 0x08, 0x6c, 0x69, 0x73, 0x74, 0x5f, + 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x54, 0x65, 0x73, 0x74, + 0x64, 0x61, 0x74, 0x61, 0x2e, 0x4d, 0x79, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x07, 0x6c, + 0x69, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x43, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x73, 0x63, + 0x61, 0x6c, 0x61, 0x72, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x54, 0x65, 0x73, + 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x2e, 0x4d, 0x61, 0x70, 0x53, 0x63, 0x61, 0x6c, 0x61, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x09, 0x6d, 0x61, 0x70, 0x53, 0x63, 0x61, 0x6c, 0x61, 0x72, 0x12, 0x3a, 0x0a, 0x07, 0x6d, + 0x61, 0x70, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, - 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, - 0x45, 0x0a, 0x10, 0x54, 0x65, 0x73, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x12, 0x15, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, - 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x54, 0x65, 0x73, - 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x45, 0x0a, 0x0e, 0x54, 0x65, 0x73, 0x74, 0x42, 0x69, - 0x64, 0x69, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x15, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, - 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x1b, 0x0a, - 0x19, 0x54, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x57, 0x69, 0x74, 0x68, - 0x6f, 0x75, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x53, 0x6e, 0x6f, 0x77, 0x66, 0x6c, 0x61, - 0x6b, 0x65, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x73, 0x61, 0x6e, 0x73, 0x73, 0x68, 0x65, 0x6c, - 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x74, 0x2e, 0x4d, 0x61, 0x70, 0x4d, 0x73, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x06, 0x6d, 0x61, 0x70, 0x4d, 0x73, 0x67, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x53, 0x63, + 0x61, 0x6c, 0x61, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x4d, 0x0a, 0x0b, 0x4d, 0x61, 0x70, 0x4d, 0x73, 0x67, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x28, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x4d, 0x79, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x22, 0x26, 0x0a, 0x0c, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x32, 0xa0, 0x02, 0x0a, + 0x0b, 0x54, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3c, 0x0a, 0x09, + 0x54, 0x65, 0x73, 0x74, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x12, 0x15, 0x2e, 0x54, 0x65, 0x73, 0x74, + 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x10, 0x54, 0x65, + 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x15, + 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, + 0x01, 0x12, 0x45, 0x0a, 0x10, 0x54, 0x65, 0x73, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x15, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x54, + 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x45, 0x0a, 0x0e, 0x54, 0x65, 0x73, 0x74, + 0x42, 0x69, 0x64, 0x69, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x15, 0x2e, 0x54, 0x65, 0x73, + 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, + 0x1b, 0x0a, 0x19, 0x54, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x57, 0x69, + 0x74, 0x68, 0x6f, 0x75, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x42, 0x34, 0x5a, 0x32, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x53, 0x6e, 0x6f, 0x77, 0x66, + 0x6c, 0x61, 0x6b, 0x65, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x73, 0x61, 0x6e, 0x73, 0x73, 0x68, + 0x65, 0x6c, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, + 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -177,25 +290,32 @@ func file_testservice_proto_rawDescGZIP() []byte { return file_testservice_proto_rawDescData } -var file_testservice_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_testservice_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_testservice_proto_goTypes = []interface{}{ - (*TestRequest)(nil), // 0: Testdata.TestRequest - (*TestResponse)(nil), // 1: Testdata.TestResponse + (*MyNested)(nil), // 0: Testdata.MyNested + (*TestRequest)(nil), // 1: Testdata.TestRequest + (*TestResponse)(nil), // 2: Testdata.TestResponse + nil, // 3: Testdata.TestRequest.MapScalarEntry + nil, // 4: Testdata.TestRequest.MapMsgEntry } var file_testservice_proto_depIdxs = []int32{ - 0, // 0: Testdata.TestService.TestUnary:input_type -> Testdata.TestRequest - 0, // 1: Testdata.TestService.TestServerStream:input_type -> Testdata.TestRequest - 0, // 2: Testdata.TestService.TestClientStream:input_type -> Testdata.TestRequest - 0, // 3: Testdata.TestService.TestBidiStream:input_type -> Testdata.TestRequest - 1, // 4: Testdata.TestService.TestUnary:output_type -> Testdata.TestResponse - 1, // 5: Testdata.TestService.TestServerStream:output_type -> Testdata.TestResponse - 1, // 6: Testdata.TestService.TestClientStream:output_type -> Testdata.TestResponse - 1, // 7: Testdata.TestService.TestBidiStream:output_type -> Testdata.TestResponse - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 0, // 0: Testdata.TestRequest.list_msg:type_name -> Testdata.MyNested + 3, // 1: Testdata.TestRequest.map_scalar:type_name -> Testdata.TestRequest.MapScalarEntry + 4, // 2: Testdata.TestRequest.map_msg:type_name -> Testdata.TestRequest.MapMsgEntry + 0, // 3: Testdata.TestRequest.MapMsgEntry.value:type_name -> Testdata.MyNested + 1, // 4: Testdata.TestService.TestUnary:input_type -> Testdata.TestRequest + 1, // 5: Testdata.TestService.TestServerStream:input_type -> Testdata.TestRequest + 1, // 6: Testdata.TestService.TestClientStream:input_type -> Testdata.TestRequest + 1, // 7: Testdata.TestService.TestBidiStream:input_type -> Testdata.TestRequest + 2, // 8: Testdata.TestService.TestUnary:output_type -> Testdata.TestResponse + 2, // 9: Testdata.TestService.TestServerStream:output_type -> Testdata.TestResponse + 2, // 10: Testdata.TestService.TestClientStream:output_type -> Testdata.TestResponse + 2, // 11: Testdata.TestService.TestBidiStream:output_type -> Testdata.TestResponse + 8, // [8:12] is the sub-list for method output_type + 4, // [4:8] 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_testservice_proto_init() } @@ -205,7 +325,7 @@ func file_testservice_proto_init() { } if !protoimpl.UnsafeEnabled { file_testservice_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TestRequest); i { + switch v := v.(*MyNested); i { case 0: return &v.state case 1: @@ -217,6 +337,18 @@ func file_testservice_proto_init() { } } file_testservice_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testservice_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TestResponse); i { case 0: return &v.state @@ -235,7 +367,7 @@ func file_testservice_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_testservice_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 5, NumExtensions: 0, NumServices: 2, }, diff --git a/proxy/testdata/testservice.proto b/proxy/testdata/testservice.proto index 4840e556..d3089c41 100644 --- a/proxy/testdata/testservice.proto +++ b/proxy/testdata/testservice.proto @@ -20,8 +20,19 @@ package Testdata; option go_package = "github.com/Snowflake-Labs/sansshell/proxy/testdata"; +message MyNested { + string fine = 1; + string sensitive = 2 [debug_redact = true]; +} + message TestRequest { string input = 1; + + repeated string list_scalar = 2; + repeated MyNested list_msg = 3; + + map map_scalar = 4; + map map_msg = 5; } message TestResponse { diff --git a/proxy/testdata/testservice_grpc.pb.go b/proxy/testdata/testservice_grpc.pb.go index 9b1460fb..ea5dded6 100644 --- a/proxy/testdata/testservice_grpc.pb.go +++ b/proxy/testdata/testservice_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.9 +// - protoc v4.25.0 // source: testservice.proto package testdata