Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add masking rule policy in store proto (#7769)

h3n4l432928312c77
diff --git a/frontend/src/types/proto/store/policy.ts b/frontend/src/types/proto/store/policy.ts
index ddf565f826..ace636c3ba 100644
--- a/frontend/src/types/proto/store/policy.ts
+++ b/frontend/src/types/proto/store/policy.ts
@@ -45,6 +45,15 @@ export interface MaskData {
maskingLevel: MaskingLevel;
}
+export interface MaskingRulePolicy {
+ rules: MaskingRulePolicy_MaskingRule[];
+}
+
+export interface MaskingRulePolicy_MaskingRule {
+ condition?: Expr | undefined;
+ maskingLevel: MaskingLevel;
+}
+
function createBaseIamPolicy(): IamPolicy {
return { bindings: [] };
}
@@ -365,6 +374,143 @@ export const MaskData = {
},
};
+function createBaseMaskingRulePolicy(): MaskingRulePolicy {
+ return { rules: [] };
+}
+
+export const MaskingRulePolicy = {
+ encode(message: MaskingRulePolicy, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ for (const v of message.rules) {
+ MaskingRulePolicy_MaskingRule.encode(v!, writer.uint32(10).fork()).ldelim();
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): MaskingRulePolicy {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseMaskingRulePolicy();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+
+ message.rules.push(MaskingRulePolicy_MaskingRule.decode(reader, reader.uint32()));
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): MaskingRulePolicy {
+ return {
+ rules: Array.isArray(object?.rules)
+ ? object.rules.map((e: any) => MaskingRulePolicy_MaskingRule.fromJSON(e))
+ : [],
+ };
+ },
+
+ toJSON(message: MaskingRulePolicy): unknown {
+ const obj: any = {};
+ if (message.rules) {
+ obj.rules = message.rules.map((e) => e ? MaskingRulePolicy_MaskingRule.toJSON(e) : undefined);
+ } else {
+ obj.rules = [];
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<MaskingRulePolicy>): MaskingRulePolicy {
+ return MaskingRulePolicy.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<MaskingRulePolicy>): MaskingRulePolicy {
+ const message = createBaseMaskingRulePolicy();
+ message.rules = object.rules?.map((e) => MaskingRulePolicy_MaskingRule.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+function createBaseMaskingRulePolicy_MaskingRule(): MaskingRulePolicy_MaskingRule {
+ return { condition: undefined, maskingLevel: 0 };
+}
+
+export const MaskingRulePolicy_MaskingRule = {
+ encode(message: MaskingRulePolicy_MaskingRule, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.condition !== undefined) {
+ Expr.encode(message.condition, writer.uint32(10).fork()).ldelim();
+ }
+ if (message.maskingLevel !== 0) {
+ writer.uint32(16).int32(message.maskingLevel);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): MaskingRulePolicy_MaskingRule {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseMaskingRulePolicy_MaskingRule();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+
+ message.condition = Expr.decode(reader, reader.uint32());
+ continue;
+ case 2:
+ if (tag !== 16) {
+ break;
+ }
+
+ message.maskingLevel = reader.int32() as any;
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): MaskingRulePolicy_MaskingRule {
+ return {
+ condition: isSet(object.condition) ? Expr.fromJSON(object.condition) : undefined,
+ maskingLevel: isSet(object.maskingLevel) ? maskingLevelFromJSON(object.maskingLevel) : 0,
+ };
+ },
+
+ toJSON(message: MaskingRulePolicy_MaskingRule): unknown {
+ const obj: any = {};
+ message.condition !== undefined && (obj.condition = message.condition ? Expr.toJSON(message.condition) : undefined);
+ message.maskingLevel !== undefined && (obj.maskingLevel = maskingLevelToJSON(message.maskingLevel));
+ return obj;
+ },
+
+ create(base?: DeepPartial<MaskingRulePolicy_MaskingRule>): MaskingRulePolicy_MaskingRule {
+ return MaskingRulePolicy_MaskingRule.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<MaskingRulePolicy_MaskingRule>): MaskingRulePolicy_MaskingRule {
+ const message = createBaseMaskingRulePolicy_MaskingRule();
+ message.condition = (object.condition !== undefined && object.condition !== null)
+ ? Expr.fromPartial(object.condition)
+ : undefined;
+ message.maskingLevel = object.maskingLevel ?? 0;
+ return message;
+ },
+};
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 0de6019d8d..f6ea3cb688 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -120,6 +120,8 @@
- [IamPolicy](#bytebase-store-IamPolicy)
- [MaskData](#bytebase-store-MaskData)
- [MaskingPolicy](#bytebase-store-MaskingPolicy)
+ - [MaskingRulePolicy](#bytebase-store-MaskingRulePolicy)
+ - [MaskingRulePolicy.MaskingRule](#bytebase-store-MaskingRulePolicy-MaskingRule)
- [store/setting.proto](#store_setting-proto)
- [AgentPluginSetting](#bytebase-store-AgentPluginSetting)
@@ -1864,6 +1866,37 @@ Reference: https://cloud.google.com/pubsub/docs/reference/rpc/google.iam.v1#bind
+
+<a name="bytebase-store-MaskingRulePolicy"></a>
+
+### MaskingRulePolicy
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| rules | [MaskingRulePolicy.MaskingRule](#bytebase-store-MaskingRulePolicy-MaskingRule) | repeated | |
+
+
+
+
+
+
+<a name="bytebase-store-MaskingRulePolicy-MaskingRule"></a>
+
+### MaskingRulePolicy.MaskingRule
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| condition | [google.type.Expr](#google-type-Expr) | | |
+| masking_level | [MaskingLevel](#bytebase-store-MaskingLevel) | | |
+
+
+
+
+
diff --git a/proto/generated-go/store/policy.pb.go b/proto/generated-go/store/policy.pb.go
index 127502ec71..bd7eabad0e 100644
--- a/proto/generated-go/store/policy.pb.go
+++ b/proto/generated-go/store/policy.pb.go
@@ -269,6 +269,108 @@ func (x *MaskData) GetMaskingLevel() MaskingLevel {
return MaskingLevel_MASKING_LEVEL_UNSPECIFIED
}
+type MaskingRulePolicy struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Rules []*MaskingRulePolicy_MaskingRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"`
+}
+
+func (x *MaskingRulePolicy) Reset() {
+ *x = MaskingRulePolicy{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_policy_proto_msgTypes[4]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *MaskingRulePolicy) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*MaskingRulePolicy) ProtoMessage() {}
+
+func (x *MaskingRulePolicy) ProtoReflect() protoreflect.Message {
+ mi := &file_store_policy_proto_msgTypes[4]
+ 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 MaskingRulePolicy.ProtoReflect.Descriptor instead.
+func (*MaskingRulePolicy) Descriptor() ([]byte, []int) {
+ return file_store_policy_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *MaskingRulePolicy) GetRules() []*MaskingRulePolicy_MaskingRule {
+ if x != nil {
+ return x.Rules
+ }
+ return nil
+}
+
+type MaskingRulePolicy_MaskingRule struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Condition *expr.Expr `protobuf:"bytes,1,opt,name=condition,proto3" json:"condition,omitempty"`
+ MaskingLevel MaskingLevel `protobuf:"varint,2,opt,name=masking_level,json=maskingLevel,proto3,enum=bytebase.store.MaskingLevel" json:"masking_level,omitempty"`
+}
+
+func (x *MaskingRulePolicy_MaskingRule) Reset() {
+ *x = MaskingRulePolicy_MaskingRule{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_policy_proto_msgTypes[5]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *MaskingRulePolicy_MaskingRule) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*MaskingRulePolicy_MaskingRule) ProtoMessage() {}
+
+func (x *MaskingRulePolicy_MaskingRule) ProtoReflect() protoreflect.Message {
+ mi := &file_store_policy_proto_msgTypes[5]
+ 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 MaskingRulePolicy_MaskingRule.ProtoReflect.Descriptor instead.
+func (*MaskingRulePolicy_MaskingRule) Descriptor() ([]byte, []int) {
+ return file_store_policy_proto_rawDescGZIP(), []int{4, 0}
+}
+
+func (x *MaskingRulePolicy_MaskingRule) GetCondition() *expr.Expr {
+ if x != nil {
+ return x.Condition
+ }
+ return nil
+}
+
+func (x *MaskingRulePolicy_MaskingRule) GetMaskingLevel() MaskingLevel {
+ if x != nil {
+ return x.MaskingLevel
+ }
+ return MaskingLevel_MASKING_LEVEL_UNSPECIFIED
+}
+
var File_store_policy_proto protoreflect.FileDescriptor
var file_store_policy_proto_rawDesc = []byte{
@@ -304,9 +406,23 @@ var file_store_policy_proto_rawDesc = []byte{
0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e,
0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72,
0x65, 0x2e, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x0c,
- 0x6d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x42, 0x14, 0x5a, 0x12,
- 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f,
- 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x6d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xdc, 0x01, 0x0a,
+ 0x11, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x50, 0x6f, 0x6c, 0x69,
+ 0x63, 0x79, 0x12, 0x43, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
+ 0x0b, 0x32, 0x2d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f,
+ 0x72, 0x65, 0x2e, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x50, 0x6f,
+ 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65,
+ 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x1a, 0x81, 0x01, 0x0a, 0x0b, 0x4d, 0x61, 0x73, 0x6b,
+ 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x2f, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x69,
+ 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x67, 0x6f, 0x6f,
+ 0x67, 0x6c, 0x65, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x45, 0x78, 0x70, 0x72, 0x52, 0x09, 0x63,
+ 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x0d, 0x6d, 0x61, 0x73, 0x6b,
+ 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32,
+ 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65,
+ 0x2e, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x0c, 0x6d,
+ 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x42, 0x14, 0x5a, 0x12, 0x67,
+ 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72,
+ 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -321,25 +437,30 @@ func file_store_policy_proto_rawDescGZIP() []byte {
return file_store_policy_proto_rawDescData
}
-var file_store_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_store_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_store_policy_proto_goTypes = []interface{}{
- (*IamPolicy)(nil), // 0: bytebase.store.IamPolicy
- (*Binding)(nil), // 1: bytebase.store.Binding
- (*MaskingPolicy)(nil), // 2: bytebase.store.MaskingPolicy
- (*MaskData)(nil), // 3: bytebase.store.MaskData
- (*expr.Expr)(nil), // 4: google.type.Expr
- (MaskingLevel)(0), // 5: bytebase.store.MaskingLevel
+ (*IamPolicy)(nil), // 0: bytebase.store.IamPolicy
+ (*Binding)(nil), // 1: bytebase.store.Binding
+ (*MaskingPolicy)(nil), // 2: bytebase.store.MaskingPolicy
+ (*MaskData)(nil), // 3: bytebase.store.MaskData
+ (*MaskingRulePolicy)(nil), // 4: bytebase.store.MaskingRulePolicy
+ (*MaskingRulePolicy_MaskingRule)(nil), // 5: bytebase.store.MaskingRulePolicy.MaskingRule
+ (*expr.Expr)(nil), // 6: google.type.Expr
+ (MaskingLevel)(0), // 7: bytebase.store.MaskingLevel
}
var file_store_policy_proto_depIdxs = []int32{
1, // 0: bytebase.store.IamPolicy.bindings:type_name -> bytebase.store.Binding
- 4, // 1: bytebase.store.Binding.condition:type_name -> google.type.Expr
+ 6, // 1: bytebase.store.Binding.condition:type_name -> google.type.Expr
3, // 2: bytebase.store.MaskingPolicy.mask_data:type_name -> bytebase.store.MaskData
- 5, // 3: bytebase.store.MaskData.masking_level:type_name -> bytebase.store.MaskingLevel
- 4, // [4:4] is the sub-list for method output_type
- 4, // [4:4] 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
+ 7, // 3: bytebase.store.MaskData.masking_level:type_name -> bytebase.store.MaskingLevel
+ 5, // 4: bytebase.store.MaskingRulePolicy.rules:type_name -> bytebase.store.MaskingRulePolicy.MaskingRule
+ 6, // 5: bytebase.store.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr
+ 7, // 6: bytebase.store.MaskingRulePolicy.MaskingRule.masking_level:type_name -> bytebase.store.MaskingLevel
+ 7, // [7:7] is the sub-list for method output_type
+ 7, // [7:7] is the sub-list for method input_type
+ 7, // [7:7] is the sub-list for extension type_name
+ 7, // [7:7] is the sub-list for extension extendee
+ 0, // [0:7] is the sub-list for field type_name
}
func init() { file_store_policy_proto_init() }
@@ -397,6 +518,30 @@ func file_store_policy_proto_init() {
return nil
}
}
+ file_store_policy_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*MaskingRulePolicy); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_store_policy_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*MaskingRulePolicy_MaskingRule); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -404,7 +549,7 @@ func file_store_policy_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_store_policy_proto_rawDesc,
NumEnums: 0,
- NumMessages: 4,
+ NumMessages: 6,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/proto/store/policy.proto b/proto/store/policy.proto
index edb3ec064c..de7ad058ed 100644
--- a/proto/store/policy.proto
+++ b/proto/store/policy.proto
@@ -42,3 +42,12 @@ message MaskData {
string semantic_category_id = 4;
MaskingLevel masking_level = 5;
}
+
+message MaskingRulePolicy {
+ message MaskingRule {
+ google.type.Expr condition = 1;
+
+ MaskingLevel masking_level = 2;
+ }
+ repeated MaskingRule rules = 1;
+}