Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: remove risk intermediate layer from approval workflow (#18201)
p0ny90f07c2594ff
diff --git a/backend/api/v1/issue_service_converter.go b/backend/api/v1/issue_service_converter.goindex fc60b6cdd2..c31a6a941d 100644--- a/backend/api/v1/issue_service_converter.go+++ b/backend/api/v1/issue_service_converter.go@@ -289,7 +289,6 @@ func convertToIssueRiskLevel(riskLevel storepb.RiskLevel) v1pb.RiskLevel {func convertToApprovalTemplate(template *storepb.ApprovalTemplate) *v1pb.ApprovalTemplate {return &v1pb.ApprovalTemplate{- Id: template.Id,Flow: convertToApprovalFlow(template.Flow),Title: template.Title,Description: template.Description,diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.goindex 4bd1fc149f..378d8baafd 100644--- a/backend/api/v1/setting_service.go+++ b/backend/api/v1/setting_service.go@@ -302,8 +302,8 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *connect.Reqflow := convertApprovalFlow(rule.Template.Flow)payload.Rules = append(payload.Rules, &storepb.WorkspaceApprovalSetting_Rule{Condition: rule.Condition,+ Source: storepb.WorkspaceApprovalSetting_Rule_Source(rule.Source),Template: &storepb.ApprovalTemplate{- Id: rule.Template.Id,Flow: flow,Title: rule.Template.Title,Description: rule.Template.Description,diff --git a/backend/api/v1/setting_service_converter.go b/backend/api/v1/setting_service_converter.goindex 7c2f49c65f..5bdcfc7b70 100644--- a/backend/api/v1/setting_service_converter.go+++ b/backend/api/v1/setting_service_converter.go@@ -54,6 +54,7 @@ func convertToSettingMessage(setting *store.SettingMessage, profile *config.Proffor _, rule := range storeValue.Rules {template := convertToApprovalTemplate(rule.Template)v1Value.Rules = append(v1Value.Rules, &v1pb.WorkspaceApprovalSetting_Rule{+ Source: v1pb.WorkspaceApprovalSetting_Rule_Source(rule.Source),Condition: rule.Condition,Template: template,})diff --git a/backend/common/cel.go b/backend/common/cel.goindex 2108627bef..d9d5bfbd62 100644--- a/backend/common/cel.go+++ b/backend/common/cel.go@@ -35,9 +35,25 @@ var RiskFactors = []cel.EnvOption{}// ApprovalFactors are the variables when finding the approval template.+// After the risk layer removal (3.13), approval rules use the same variables as risk evaluation.var ApprovalFactors = []cel.EnvOption{- cel.Variable(CELAttributeLevel, cel.StringType),- cel.Variable(CELAttributeSource, cel.StringType),+ // Resource scope+ cel.Variable(CELAttributeResourceEnvironmentID, cel.StringType),+ cel.Variable(CELAttributeResourceProjectID, cel.StringType),+ cel.Variable(CELAttributeResourceInstanceID, cel.StringType),+ cel.Variable(CELAttributeResourceDBEngine, cel.StringType),+ cel.Variable(CELAttributeResourceDatabaseName, cel.StringType),+ cel.Variable(CELAttributeResourceSchemaName, cel.StringType),+ cel.Variable(CELAttributeResourceTableName, cel.StringType),+ // Statement scope+ cel.Variable(CELAttributeStatementAffectedRows, cel.IntType),+ cel.Variable(CELAttributeStatementTableRows, cel.IntType),+ cel.Variable(CELAttributeStatementSQLType, cel.StringType),+ cel.Variable(CELAttributeStatementText, cel.StringType),+ // Request scope+ cel.Variable(CELAttributeRequestExpirationDays, cel.IntType),+ cel.Variable(CELAttributeRequestRole, cel.StringType),+ // Size limitcel.ParserExpressionSizeLimit(celLimit),}diff --git a/backend/generated-go/store/approval.pb.go b/backend/generated-go/store/approval.pb.goindex bed0dc0d00..0a2d624647 100644--- a/backend/generated-go/store/approval.pb.go+++ b/backend/generated-go/store/approval.pb.go@@ -163,10 +163,6 @@ func (x *IssuePayloadApproval) GetRiskLevel() RiskLevel {// ApprovalTemplate defines the approval workflow and requirements for an issue.type ApprovalTemplate struct {state protoimpl.MessageState `protogen:"open.v1"`- // The unique identifier for the approval template.- // Built-in templates use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").- // Custom templates use a UUID or other unique identifier.- Id string `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"`// The approval workflow specification.Flow *ApprovalFlow `protobuf:"bytes,1,opt,name=flow,proto3" json:"flow,omitempty"`// Human-readable title of the approval template.@@ -207,13 +203,6 @@ func (*ApprovalTemplate) Descriptor() ([]byte, []int) {return file_store_approval_proto_rawDescGZIP(), []int{1}}-func (x *ApprovalTemplate) GetId() string {- if x != nil {- return x.Id- }- return ""-}-func (x *ApprovalTemplate) GetFlow() *ApprovalFlow {if x != nil {return x.Flow@@ -355,9 +344,8 @@ const file_store_approval_proto_rawDesc = "" +"\x12STATUS_UNSPECIFIED\x10\x00\x12\v\n" +"\aPENDING\x10\x01\x12\f\n" +"\bAPPROVED\x10\x02\x12\f\n" +- "\bREJECTED\x10\x03\"\x8c\x01\n" +- "\x10ApprovalTemplate\x12\x0e\n" +- "\x02id\x18\x04 \x01(\tR\x02id\x120\n" ++ "\bREJECTED\x10\x03\"|\n" ++ "\x10ApprovalTemplate\x120\n" +"\x04flow\x18\x01 \x01(\v2\x1c.bytebase.store.ApprovalFlowR\x04flow\x12\x14\n" +"\x05title\x18\x02 \x01(\tR\x05title\x12 \n" +"\vdescription\x18\x03 \x01(\tR\vdescription\"$\n" +diff --git a/backend/generated-go/store/approval_equal.pb.go b/backend/generated-go/store/approval_equal.pb.goindex 24ab61d434..95c04d2a67 100644--- a/backend/generated-go/store/approval_equal.pb.go+++ b/backend/generated-go/store/approval_equal.pb.go@@ -56,9 +56,6 @@ func (x *ApprovalTemplate) Equal(y *ApprovalTemplate) bool {if x == nil || y == nil {return x == nil && y == nil}- if x.Id != y.Id {- return false- }if !x.Flow.Equal(y.Flow) {return false}diff --git a/backend/generated-go/store/setting.pb.go b/backend/generated-go/store/setting.pb.goindex 5ce185d004..5751148059 100644--- a/backend/generated-go/store/setting.pb.go+++ b/backend/generated-go/store/setting.pb.go@@ -219,6 +219,64 @@ func (Announcement_AlertLevel) EnumDescriptor() ([]byte, []int) {return file_store_setting_proto_rawDescGZIP(), []int{1, 0}}+type WorkspaceApprovalSetting_Rule_Source int32++const (+ WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED WorkspaceApprovalSetting_Rule_Source = 0+ WorkspaceApprovalSetting_Rule_DDL WorkspaceApprovalSetting_Rule_Source = 1+ WorkspaceApprovalSetting_Rule_DML WorkspaceApprovalSetting_Rule_Source = 2+ WorkspaceApprovalSetting_Rule_CREATE_DATABASE WorkspaceApprovalSetting_Rule_Source = 3+ WorkspaceApprovalSetting_Rule_EXPORT_DATA WorkspaceApprovalSetting_Rule_Source = 4+ WorkspaceApprovalSetting_Rule_REQUEST_ROLE WorkspaceApprovalSetting_Rule_Source = 5+)++// Enum value maps for WorkspaceApprovalSetting_Rule_Source.+var (+ WorkspaceApprovalSetting_Rule_Source_name = map[int32]string{+ 0: "SOURCE_UNSPECIFIED",+ 1: "DDL",+ 2: "DML",+ 3: "CREATE_DATABASE",+ 4: "EXPORT_DATA",+ 5: "REQUEST_ROLE",+ }+ WorkspaceApprovalSetting_Rule_Source_value = map[string]int32{+ "SOURCE_UNSPECIFIED": 0,+ "DDL": 1,+ "DML": 2,+ "CREATE_DATABASE": 3,+ "EXPORT_DATA": 4,+ "REQUEST_ROLE": 5,+ }+)++func (x WorkspaceApprovalSetting_Rule_Source) Enum() *WorkspaceApprovalSetting_Rule_Source {+ p := new(WorkspaceApprovalSetting_Rule_Source)+ *p = x+ return p+}++func (x WorkspaceApprovalSetting_Rule_Source) String() string {+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))+}++func (WorkspaceApprovalSetting_Rule_Source) Descriptor() protoreflect.EnumDescriptor {+ return file_store_setting_proto_enumTypes[3].Descriptor()+}++func (WorkspaceApprovalSetting_Rule_Source) Type() protoreflect.EnumType {+ return &file_store_setting_proto_enumTypes[3]+}++func (x WorkspaceApprovalSetting_Rule_Source) Number() protoreflect.EnumNumber {+ return protoreflect.EnumNumber(x)+}++// Deprecated: Use WorkspaceApprovalSetting_Rule_Source.Descriptor instead.+func (WorkspaceApprovalSetting_Rule_Source) EnumDescriptor() ([]byte, []int) {+ return file_store_setting_proto_rawDescGZIP(), []int{2, 0, 0}+}+type Algorithm_InnerOuterMask_MaskType int32const (@@ -252,11 +310,11 @@ func (x Algorithm_InnerOuterMask_MaskType) String() string {}func (Algorithm_InnerOuterMask_MaskType) Descriptor() protoreflect.EnumDescriptor {- return file_store_setting_proto_enumTypes[3].Descriptor()+ return file_store_setting_proto_enumTypes[4].Descriptor()}func (Algorithm_InnerOuterMask_MaskType) Type() protoreflect.EnumType {- return &file_store_setting_proto_enumTypes[3]+ return &file_store_setting_proto_enumTypes[4]}func (x Algorithm_InnerOuterMask_MaskType) Number() protoreflect.EnumNumber {@@ -307,11 +365,11 @@ func (x AISetting_Provider) String() string {}func (AISetting_Provider) Descriptor() protoreflect.EnumDescriptor {- return file_store_setting_proto_enumTypes[4].Descriptor()+ return file_store_setting_proto_enumTypes[5].Descriptor()}func (AISetting_Provider) Type() protoreflect.EnumType {- return &file_store_setting_proto_enumTypes[4]+ return &file_store_setting_proto_enumTypes[5]}func (x AISetting_Provider) Number() protoreflect.EnumNumber {@@ -1162,9 +1220,10 @@ func (x *EnvironmentSetting) GetEnvironments() []*EnvironmentSetting_Environment}type WorkspaceApprovalSetting_Rule struct {- state protoimpl.MessageState `protogen:"open.v1"`- Template *ApprovalTemplate `protobuf:"bytes,1,opt,name=template,proto3" json:"template,omitempty"`- Condition *expr.Expr `protobuf:"bytes,2,opt,name=condition,proto3" json:"condition,omitempty"`+ state protoimpl.MessageState `protogen:"open.v1"`+ Template *ApprovalTemplate `protobuf:"bytes,1,opt,name=template,proto3" json:"template,omitempty"`+ Condition *expr.Expr `protobuf:"bytes,2,opt,name=condition,proto3" json:"condition,omitempty"`+ Source WorkspaceApprovalSetting_Rule_Source `protobuf:"varint,3,opt,name=source,proto3,enum=bytebase.store.WorkspaceApprovalSetting_Rule_Source" json:"source,omitempty"`unknownFields protoimpl.UnknownFieldssizeCache protoimpl.SizeCache}@@ -1213,6 +1272,13 @@ func (x *WorkspaceApprovalSetting_Rule) GetCondition() *expr.Expr {return nil}+func (x *WorkspaceApprovalSetting_Rule) GetSource() WorkspaceApprovalSetting_Rule_Source {+ if x != nil {+ return x.Source+ }+ return WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED+}+type SchemaTemplateSetting_FieldTemplate struct {state protoimpl.MessageState `protogen:"open.v1"`Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`@@ -2495,12 +2561,20 @@ const file_store_setting_proto_rawDesc = "" +"\x17ALERT_LEVEL_UNSPECIFIED\x10\x00\x12\x14\n" +"\x10ALERT_LEVEL_INFO\x10\x01\x12\x17\n" +"\x13ALERT_LEVEL_WARNING\x10\x02\x12\x18\n" +- "\x14ALERT_LEVEL_CRITICAL\x10\x03\"\xd6\x01\n" ++ "\x14ALERT_LEVEL_CRITICAL\x10\x03\"\x91\x03\n" +"\x18WorkspaceApprovalSetting\x12C\n" +- "\x05rules\x18\x01 \x03(\v2-.bytebase.store.WorkspaceApprovalSetting.RuleR\x05rules\x1au\n" ++ "\x05rules\x18\x01 \x03(\v2-.bytebase.store.WorkspaceApprovalSetting.RuleR\x05rules\x1a\xaf\x02\n" +"\x04Rule\x12<\n" +"\btemplate\x18\x01 \x01(\v2 .bytebase.store.ApprovalTemplateR\btemplate\x12/\n" +- "\tcondition\x18\x02 \x01(\v2\x11.google.type.ExprR\tcondition\"\xd0\x06\n" ++ "\tcondition\x18\x02 \x01(\v2\x11.google.type.ExprR\tcondition\x12L\n" ++ "\x06source\x18\x03 \x01(\x0e24.bytebase.store.WorkspaceApprovalSetting.Rule.SourceR\x06source\"j\n" ++ "\x06Source\x12\x16\n" ++ "\x12SOURCE_UNSPECIFIED\x10\x00\x12\a\n" ++ "\x03DDL\x10\x01\x12\a\n" ++ "\x03DML\x10\x02\x12\x13\n" ++ "\x0fCREATE_DATABASE\x10\x03\x12\x0f\n" ++ "\vEXPORT_DATA\x10\x04\x12\x10\n" ++ "\fREQUEST_ROLE\x10\x05\"\xd0\x06\n" +"\x15SchemaTemplateSetting\x12\\\n" +"\x0ffield_templates\x18\x01 \x03(\v23.bytebase.store.SchemaTemplateSetting.FieldTemplateR\x0efieldTemplates\x12S\n" +"\fcolumn_types\x18\x02 \x03(\v20.bytebase.store.SchemaTemplateSetting.ColumnTypeR\vcolumnTypes\x12\\\n" +@@ -2683,106 +2757,108 @@ func file_store_setting_proto_rawDescGZIP() []byte {return file_store_setting_proto_rawDescData}-var file_store_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 5)+var file_store_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 6)var file_store_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 34)var file_store_setting_proto_goTypes = []any{(SettingName)(0), // 0: bytebase.store.SettingName(DatabaseChangeMode)(0), // 1: bytebase.store.DatabaseChangeMode(Announcement_AlertLevel)(0), // 2: bytebase.store.Announcement.AlertLevel- (Algorithm_InnerOuterMask_MaskType)(0), // 3: bytebase.store.Algorithm.InnerOuterMask.MaskType- (AISetting_Provider)(0), // 4: bytebase.store.AISetting.Provider- (*WorkspaceProfileSetting)(nil), // 5: bytebase.store.WorkspaceProfileSetting- (*Announcement)(nil), // 6: bytebase.store.Announcement- (*WorkspaceApprovalSetting)(nil), // 7: bytebase.store.WorkspaceApprovalSetting- (*SchemaTemplateSetting)(nil), // 8: bytebase.store.SchemaTemplateSetting- (*DataClassificationSetting)(nil), // 9: bytebase.store.DataClassificationSetting- (*SemanticTypeSetting)(nil), // 10: bytebase.store.SemanticTypeSetting- (*Algorithm)(nil), // 11: bytebase.store.Algorithm- (*AppIMSetting)(nil), // 12: bytebase.store.AppIMSetting- (*SCIMSetting)(nil), // 13: bytebase.store.SCIMSetting- (*PasswordRestrictionSetting)(nil), // 14: bytebase.store.PasswordRestrictionSetting- (*AISetting)(nil), // 15: bytebase.store.AISetting- (*EnvironmentSetting)(nil), // 16: bytebase.store.EnvironmentSetting- (*WorkspaceApprovalSetting_Rule)(nil), // 17: bytebase.store.WorkspaceApprovalSetting.Rule- (*SchemaTemplateSetting_FieldTemplate)(nil), // 18: bytebase.store.SchemaTemplateSetting.FieldTemplate- (*SchemaTemplateSetting_ColumnType)(nil), // 19: bytebase.store.SchemaTemplateSetting.ColumnType- (*SchemaTemplateSetting_TableTemplate)(nil), // 20: bytebase.store.SchemaTemplateSetting.TableTemplate- (*DataClassificationSetting_DataClassificationConfig)(nil), // 21: bytebase.store.DataClassificationSetting.DataClassificationConfig- (*DataClassificationSetting_DataClassificationConfig_Level)(nil), // 22: bytebase.store.DataClassificationSetting.DataClassificationConfig.Level- (*DataClassificationSetting_DataClassificationConfig_DataClassification)(nil), // 23: bytebase.store.DataClassificationSetting.DataClassificationConfig.DataClassification- nil, // 24: bytebase.store.DataClassificationSetting.DataClassificationConfig.ClassificationEntry- (*SemanticTypeSetting_SemanticType)(nil), // 25: bytebase.store.SemanticTypeSetting.SemanticType- (*Algorithm_FullMask)(nil), // 26: bytebase.store.Algorithm.FullMask- (*Algorithm_RangeMask)(nil), // 27: bytebase.store.Algorithm.RangeMask- (*Algorithm_MD5Mask)(nil), // 28: bytebase.store.Algorithm.MD5Mask- (*Algorithm_InnerOuterMask)(nil), // 29: bytebase.store.Algorithm.InnerOuterMask- (*Algorithm_RangeMask_Slice)(nil), // 30: bytebase.store.Algorithm.RangeMask.Slice- (*AppIMSetting_Slack)(nil), // 31: bytebase.store.AppIMSetting.Slack- (*AppIMSetting_Feishu)(nil), // 32: bytebase.store.AppIMSetting.Feishu- (*AppIMSetting_Wecom)(nil), // 33: bytebase.store.AppIMSetting.Wecom- (*AppIMSetting_Lark)(nil), // 34: bytebase.store.AppIMSetting.Lark- (*AppIMSetting_DingTalk)(nil), // 35: bytebase.store.AppIMSetting.DingTalk- (*AppIMSetting_IMSetting)(nil), // 36: bytebase.store.AppIMSetting.IMSetting- (*EnvironmentSetting_Environment)(nil), // 37: bytebase.store.EnvironmentSetting.Environment- nil, // 38: bytebase.store.EnvironmentSetting.Environment.TagsEntry- (*durationpb.Duration)(nil), // 39: google.protobuf.Duration- (*ApprovalTemplate)(nil), // 40: bytebase.store.ApprovalTemplate- (*expr.Expr)(nil), // 41: google.type.Expr- (Engine)(0), // 42: bytebase.store.Engine- (*ColumnMetadata)(nil), // 43: bytebase.store.ColumnMetadata- (*ColumnCatalog)(nil), // 44: bytebase.store.ColumnCatalog- (*TableMetadata)(nil), // 45: bytebase.store.TableMetadata- (*TableCatalog)(nil), // 46: bytebase.store.TableCatalog- (ProjectWebhook_Type)(0), // 47: bytebase.store.ProjectWebhook.Type+ (WorkspaceApprovalSetting_Rule_Source)(0), // 3: bytebase.store.WorkspaceApprovalSetting.Rule.Source+ (Algorithm_InnerOuterMask_MaskType)(0), // 4: bytebase.store.Algorithm.InnerOuterMask.MaskType+ (AISetting_Provider)(0), // 5: bytebase.store.AISetting.Provider+ (*WorkspaceProfileSetting)(nil), // 6: bytebase.store.WorkspaceProfileSetting+ (*Announcement)(nil), // 7: bytebase.store.Announcement+ (*WorkspaceApprovalSetting)(nil), // 8: bytebase.store.WorkspaceApprovalSetting+ (*SchemaTemplateSetting)(nil), // 9: bytebase.store.SchemaTemplateSetting+ (*DataClassificationSetting)(nil), // 10: bytebase.store.DataClassificationSetting+ (*SemanticTypeSetting)(nil), // 11: bytebase.store.SemanticTypeSetting+ (*Algorithm)(nil), // 12: bytebase.store.Algorithm+ (*AppIMSetting)(nil), // 13: bytebase.store.AppIMSetting+ (*SCIMSetting)(nil), // 14: bytebase.store.SCIMSetting+ (*PasswordRestrictionSetting)(nil), // 15: bytebase.store.PasswordRestrictionSetting+ (*AISetting)(nil), // 16: bytebase.store.AISetting+ (*EnvironmentSetting)(nil), // 17: bytebase.store.EnvironmentSetting+ (*WorkspaceApprovalSetting_Rule)(nil), // 18: bytebase.store.WorkspaceApprovalSetting.Rule+ (*SchemaTemplateSetting_FieldTemplate)(nil), // 19: bytebase.store.SchemaTemplateSetting.FieldTemplate+ (*SchemaTemplateSetting_ColumnType)(nil), // 20: bytebase.store.SchemaTemplateSetting.ColumnType+ (*SchemaTemplateSetting_TableTemplate)(nil), // 21: bytebase.store.SchemaTemplateSetting.TableTemplate+ (*DataClassificationSetting_DataClassificationConfig)(nil), // 22: bytebase.store.DataClassificationSetting.DataClassificationConfig+ (*DataClassificationSetting_DataClassificationConfig_Level)(nil), // 23: bytebase.store.DataClassificationSetting.DataClassificationConfig.Level+ (*DataClassificationSetting_DataClassificationConfig_DataClassification)(nil), // 24: bytebase.store.DataClassificationSetting.DataClassificationConfig.DataClassification+ nil, // 25: bytebase.store.DataClassificationSetting.DataClassificationConfig.ClassificationEntry+ (*SemanticTypeSetting_SemanticType)(nil), // 26: bytebase.store.SemanticTypeSetting.SemanticType+ (*Algorithm_FullMask)(nil), // 27: bytebase.store.Algorithm.FullMask+ (*Algorithm_RangeMask)(nil), // 28: bytebase.store.Algorithm.RangeMask+ (*Algorithm_MD5Mask)(nil), // 29: bytebase.store.Algorithm.MD5Mask+ (*Algorithm_InnerOuterMask)(nil), // 30: bytebase.store.Algorithm.InnerOuterMask+ (*Algorithm_RangeMask_Slice)(nil), // 31: bytebase.store.Algorithm.RangeMask.Slice+ (*AppIMSetting_Slack)(nil), // 32: bytebase.store.AppIMSetting.Slack+ (*AppIMSetting_Feishu)(nil), // 33: bytebase.store.AppIMSetting.Feishu+ (*AppIMSetting_Wecom)(nil), // 34: bytebase.store.AppIMSetting.Wecom+ (*AppIMSetting_Lark)(nil), // 35: bytebase.store.AppIMSetting.Lark+ (*AppIMSetting_DingTalk)(nil), // 36: bytebase.store.AppIMSetting.DingTalk+ (*AppIMSetting_IMSetting)(nil), // 37: bytebase.store.AppIMSetting.IMSetting+ (*EnvironmentSetting_Environment)(nil), // 38: bytebase.store.EnvironmentSetting.Environment+ nil, // 39: bytebase.store.EnvironmentSetting.Environment.TagsEntry+ (*durationpb.Duration)(nil), // 40: google.protobuf.Duration+ (*ApprovalTemplate)(nil), // 41: bytebase.store.ApprovalTemplate+ (*expr.Expr)(nil), // 42: google.type.Expr+ (Engine)(0), // 43: bytebase.store.Engine+ (*ColumnMetadata)(nil), // 44: bytebase.store.ColumnMetadata+ (*ColumnCatalog)(nil), // 45: bytebase.store.ColumnCatalog+ (*TableMetadata)(nil), // 46: bytebase.store.TableMetadata+ (*TableCatalog)(nil), // 47: bytebase.store.TableCatalog+ (ProjectWebhook_Type)(0), // 48: bytebase.store.ProjectWebhook.Type}var file_store_setting_proto_depIdxs = []int32{- 39, // 0: bytebase.store.WorkspaceProfileSetting.token_duration:type_name -> google.protobuf.Duration- 6, // 1: bytebase.store.WorkspaceProfileSetting.announcement:type_name -> bytebase.store.Announcement- 39, // 2: bytebase.store.WorkspaceProfileSetting.maximum_role_expiration:type_name -> google.protobuf.Duration+ 40, // 0: bytebase.store.WorkspaceProfileSetting.token_duration:type_name -> google.protobuf.Duration+ 7, // 1: bytebase.store.WorkspaceProfileSetting.announcement:type_name -> bytebase.store.Announcement+ 40, // 2: bytebase.store.WorkspaceProfileSetting.maximum_role_expiration:type_name -> google.protobuf.Duration1, // 3: bytebase.store.WorkspaceProfileSetting.database_change_mode:type_name -> bytebase.store.DatabaseChangeMode- 39, // 4: bytebase.store.WorkspaceProfileSetting.inactive_session_timeout:type_name -> google.protobuf.Duration+ 40, // 4: bytebase.store.WorkspaceProfileSetting.inactive_session_timeout:type_name -> google.protobuf.Duration2, // 5: bytebase.store.Announcement.level:type_name -> bytebase.store.Announcement.AlertLevel- 17, // 6: bytebase.store.WorkspaceApprovalSetting.rules:type_name -> bytebase.store.WorkspaceApprovalSetting.Rule- 18, // 7: bytebase.store.SchemaTemplateSetting.field_templates:type_name -> bytebase.store.SchemaTemplateSetting.FieldTemplate- 19, // 8: bytebase.store.SchemaTemplateSetting.column_types:type_name -> bytebase.store.SchemaTemplateSetting.ColumnType- 20, // 9: bytebase.store.SchemaTemplateSetting.table_templates:type_name -> bytebase.store.SchemaTemplateSetting.TableTemplate- 21, // 10: bytebase.store.DataClassificationSetting.configs:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig- 25, // 11: bytebase.store.SemanticTypeSetting.types:type_name -> bytebase.store.SemanticTypeSetting.SemanticType- 26, // 12: bytebase.store.Algorithm.full_mask:type_name -> bytebase.store.Algorithm.FullMask- 27, // 13: bytebase.store.Algorithm.range_mask:type_name -> bytebase.store.Algorithm.RangeMask- 28, // 14: bytebase.store.Algorithm.md5_mask:type_name -> bytebase.store.Algorithm.MD5Mask- 29, // 15: bytebase.store.Algorithm.inner_outer_mask:type_name -> bytebase.store.Algorithm.InnerOuterMask- 36, // 16: bytebase.store.AppIMSetting.settings:type_name -> bytebase.store.AppIMSetting.IMSetting- 39, // 17: bytebase.store.PasswordRestrictionSetting.password_rotation:type_name -> google.protobuf.Duration- 4, // 18: bytebase.store.AISetting.provider:type_name -> bytebase.store.AISetting.Provider- 37, // 19: bytebase.store.EnvironmentSetting.environments:type_name -> bytebase.store.EnvironmentSetting.Environment- 40, // 20: bytebase.store.WorkspaceApprovalSetting.Rule.template:type_name -> bytebase.store.ApprovalTemplate- 41, // 21: bytebase.store.WorkspaceApprovalSetting.Rule.condition:type_name -> google.type.Expr- 42, // 22: bytebase.store.SchemaTemplateSetting.FieldTemplate.engine:type_name -> bytebase.store.Engine- 43, // 23: bytebase.store.SchemaTemplateSetting.FieldTemplate.column:type_name -> bytebase.store.ColumnMetadata- 44, // 24: bytebase.store.SchemaTemplateSetting.FieldTemplate.catalog:type_name -> bytebase.store.ColumnCatalog- 42, // 25: bytebase.store.SchemaTemplateSetting.ColumnType.engine:type_name -> bytebase.store.Engine- 42, // 26: bytebase.store.SchemaTemplateSetting.TableTemplate.engine:type_name -> bytebase.store.Engine- 45, // 27: bytebase.store.SchemaTemplateSetting.TableTemplate.table:type_name -> bytebase.store.TableMetadata- 46, // 28: bytebase.store.SchemaTemplateSetting.TableTemplate.catalog:type_name -> bytebase.store.TableCatalog- 22, // 29: bytebase.store.DataClassificationSetting.DataClassificationConfig.levels:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig.Level- 24, // 30: bytebase.store.DataClassificationSetting.DataClassificationConfig.classification:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig.ClassificationEntry- 23, // 31: bytebase.store.DataClassificationSetting.DataClassificationConfig.ClassificationEntry.value:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig.DataClassification- 11, // 32: bytebase.store.SemanticTypeSetting.SemanticType.algorithm:type_name -> bytebase.store.Algorithm- 30, // 33: bytebase.store.Algorithm.RangeMask.slices:type_name -> bytebase.store.Algorithm.RangeMask.Slice- 3, // 34: bytebase.store.Algorithm.InnerOuterMask.type:type_name -> bytebase.store.Algorithm.InnerOuterMask.MaskType- 47, // 35: bytebase.store.AppIMSetting.IMSetting.type:type_name -> bytebase.store.ProjectWebhook.Type- 31, // 36: bytebase.store.AppIMSetting.IMSetting.slack:type_name -> bytebase.store.AppIMSetting.Slack- 32, // 37: bytebase.store.AppIMSetting.IMSetting.feishu:type_name -> bytebase.store.AppIMSetting.Feishu- 33, // 38: bytebase.store.AppIMSetting.IMSetting.wecom:type_name -> bytebase.store.AppIMSetting.Wecom- 34, // 39: bytebase.store.AppIMSetting.IMSetting.lark:type_name -> bytebase.store.AppIMSetting.Lark- 35, // 40: bytebase.store.AppIMSetting.IMSetting.dingtalk:type_name -> bytebase.store.AppIMSetting.DingTalk- 38, // 41: bytebase.store.EnvironmentSetting.Environment.tags:type_name -> bytebase.store.EnvironmentSetting.Environment.TagsEntry- 42, // [42:42] is the sub-list for method output_type- 42, // [42:42] is the sub-list for method input_type- 42, // [42:42] is the sub-list for extension type_name- 42, // [42:42] is the sub-list for extension extendee- 0, // [0:42] is the sub-list for field type_name+ 18, // 6: bytebase.store.WorkspaceApprovalSetting.rules:type_name -> bytebase.store.WorkspaceApprovalSetting.Rule+ 19, // 7: bytebase.store.SchemaTemplateSetting.field_templates:type_name -> bytebase.store.SchemaTemplateSetting.FieldTemplate+ 20, // 8: bytebase.store.SchemaTemplateSetting.column_types:type_name -> bytebase.store.SchemaTemplateSetting.ColumnType+ 21, // 9: bytebase.store.SchemaTemplateSetting.table_templates:type_name -> bytebase.store.SchemaTemplateSetting.TableTemplate+ 22, // 10: bytebase.store.DataClassificationSetting.configs:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig+ 26, // 11: bytebase.store.SemanticTypeSetting.types:type_name -> bytebase.store.SemanticTypeSetting.SemanticType+ 27, // 12: bytebase.store.Algorithm.full_mask:type_name -> bytebase.store.Algorithm.FullMask+ 28, // 13: bytebase.store.Algorithm.range_mask:type_name -> bytebase.store.Algorithm.RangeMask+ 29, // 14: bytebase.store.Algorithm.md5_mask:type_name -> bytebase.store.Algorithm.MD5Mask+ 30, // 15: bytebase.store.Algorithm.inner_outer_mask:type_name -> bytebase.store.Algorithm.InnerOuterMask+ 37, // 16: bytebase.store.AppIMSetting.settings:type_name -> bytebase.store.AppIMSetting.IMSetting+ 40, // 17: bytebase.store.PasswordRestrictionSetting.password_rotation:type_name -> google.protobuf.Duration+ 5, // 18: bytebase.store.AISetting.provider:type_name -> bytebase.store.AISetting.Provider+ 38, // 19: bytebase.store.EnvironmentSetting.environments:type_name -> bytebase.store.EnvironmentSetting.Environment+ 41, // 20: bytebase.store.WorkspaceApprovalSetting.Rule.template:type_name -> bytebase.store.ApprovalTemplate+ 42, // 21: bytebase.store.WorkspaceApprovalSetting.Rule.condition:type_name -> google.type.Expr+ 3, // 22: bytebase.store.WorkspaceApprovalSetting.Rule.source:type_name -> bytebase.store.WorkspaceApprovalSetting.Rule.Source+ 43, // 23: bytebase.store.SchemaTemplateSetting.FieldTemplate.engine:type_name -> bytebase.store.Engine+ 44, // 24: bytebase.store.SchemaTemplateSetting.FieldTemplate.column:type_name -> bytebase.store.ColumnMetadata+ 45, // 25: bytebase.store.SchemaTemplateSetting.FieldTemplate.catalog:type_name -> bytebase.store.ColumnCatalog+ 43, // 26: bytebase.store.SchemaTemplateSetting.ColumnType.engine:type_name -> bytebase.store.Engine+ 43, // 27: bytebase.store.SchemaTemplateSetting.TableTemplate.engine:type_name -> bytebase.store.Engine+ 46, // 28: bytebase.store.SchemaTemplateSetting.TableTemplate.table:type_name -> bytebase.store.TableMetadata+ 47, // 29: bytebase.store.SchemaTemplateSetting.TableTemplate.catalog:type_name -> bytebase.store.TableCatalog+ 23, // 30: bytebase.store.DataClassificationSetting.DataClassificationConfig.levels:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig.Level+ 25, // 31: bytebase.store.DataClassificationSetting.DataClassificationConfig.classification:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig.ClassificationEntry+ 24, // 32: bytebase.store.DataClassificationSetting.DataClassificationConfig.ClassificationEntry.value:type_name -> bytebase.store.DataClassificationSetting.DataClassificationConfig.DataClassification+ 12, // 33: bytebase.store.SemanticTypeSetting.SemanticType.algorithm:type_name -> bytebase.store.Algorithm+ 31, // 34: bytebase.store.Algorithm.RangeMask.slices:type_name -> bytebase.store.Algorithm.RangeMask.Slice+ 4, // 35: bytebase.store.Algorithm.InnerOuterMask.type:type_name -> bytebase.store.Algorithm.InnerOuterMask.MaskType+ 48, // 36: bytebase.store.AppIMSetting.IMSetting.type:type_name -> bytebase.store.ProjectWebhook.Type+ 32, // 37: bytebase.store.AppIMSetting.IMSetting.slack:type_name -> bytebase.store.AppIMSetting.Slack+ 33, // 38: bytebase.store.AppIMSetting.IMSetting.feishu:type_name -> bytebase.store.AppIMSetting.Feishu+ 34, // 39: bytebase.store.AppIMSetting.IMSetting.wecom:type_name -> bytebase.store.AppIMSetting.Wecom+ 35, // 40: bytebase.store.AppIMSetting.IMSetting.lark:type_name -> bytebase.store.AppIMSetting.Lark+ 36, // 41: bytebase.store.AppIMSetting.IMSetting.dingtalk:type_name -> bytebase.store.AppIMSetting.DingTalk+ 39, // 42: bytebase.store.EnvironmentSetting.Environment.tags:type_name -> bytebase.store.EnvironmentSetting.Environment.TagsEntry+ 43, // [43:43] is the sub-list for method output_type+ 43, // [43:43] is the sub-list for method input_type+ 43, // [43:43] is the sub-list for extension type_name+ 43, // [43:43] is the sub-list for extension extendee+ 0, // [0:43] is the sub-list for field type_name}func init() { file_store_setting_proto_init() }@@ -2813,7 +2889,7 @@ func file_store_setting_proto_init() {File: protoimpl.DescBuilder{GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_setting_proto_rawDesc), len(file_store_setting_proto_rawDesc)),- NumEnums: 5,+ NumEnums: 6,NumMessages: 34,NumExtensions: 0,NumServices: 0,diff --git a/backend/generated-go/store/setting_equal.pb.go b/backend/generated-go/store/setting_equal.pb.goindex e3faf17dbc..bf13229128 100644--- a/backend/generated-go/store/setting_equal.pb.go+++ b/backend/generated-go/store/setting_equal.pb.go@@ -96,6 +96,9 @@ func (x *WorkspaceApprovalSetting_Rule) Equal(y *WorkspaceApprovalSetting_Rule)} else if !proto.Equal(x.Condition, y.Condition) {return false}+ if x.Source != y.Source {+ return false+ }return true}diff --git a/backend/generated-go/v1/issue_service.pb.go b/backend/generated-go/v1/issue_service.pb.goindex 0468e27976..975ed56485 100644--- a/backend/generated-go/v1/issue_service.pb.go+++ b/backend/generated-go/v1/issue_service.pb.go@@ -1455,10 +1455,6 @@ func (x *GrantRequest) GetExpiration() *durationpb.Duration {type ApprovalTemplate struct {state protoimpl.MessageState `protogen:"open.v1"`- // The unique identifier for the approval template.- // For built-in templates, use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").- // For custom templates, use a UUID or other unique identifier.- Id string `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"`// The approval flow definition.Flow *ApprovalFlow `protobuf:"bytes,1,opt,name=flow,proto3" json:"flow,omitempty"`// The title of the approval template.@@ -1499,13 +1495,6 @@ func (*ApprovalTemplate) Descriptor() ([]byte, []int) {return file_v1_issue_service_proto_rawDescGZIP(), []int{14}}-func (x *ApprovalTemplate) GetId() string {- if x != nil {- return x.Id- }- return ""-}-func (x *ApprovalTemplate) GetFlow() *ApprovalFlow {if x != nil {return x.Flow@@ -2587,9 +2576,8 @@ const file_v1_issue_service_proto_rawDesc = "" +"\tcondition\x18\x03 \x01(\v2\x11.google.type.ExprR\tcondition\x129\n" +"\n" +"expiration\x18\x04 \x01(\v2\x19.google.protobuf.DurationR\n" +- "expiration\"\x89\x01\n" +- "\x10ApprovalTemplate\x12\x0e\n" +- "\x02id\x18\x04 \x01(\tR\x02id\x12-\n" ++ "expiration\"y\n" ++ "\x10ApprovalTemplate\x12-\n" +"\x04flow\x18\x01 \x01(\v2\x19.bytebase.v1.ApprovalFlowR\x04flow\x12\x14\n" +"\x05title\x18\x02 \x01(\tR\x05title\x12 \n" +"\vdescription\x18\x03 \x01(\tR\vdescription\"$\n" +diff --git a/backend/generated-go/v1/issue_service_equal.pb.go b/backend/generated-go/v1/issue_service_equal.pb.goindex 802cdc45ef..2a7815893b 100644--- a/backend/generated-go/v1/issue_service_equal.pb.go+++ b/backend/generated-go/v1/issue_service_equal.pb.go@@ -379,9 +379,6 @@ func (x *ApprovalTemplate) Equal(y *ApprovalTemplate) bool {if x == nil || y == nil {return x == nil && y == nil}- if x.Id != y.Id {- return false- }if !x.Flow.Equal(y.Flow) {return false}diff --git a/backend/generated-go/v1/setting_service.pb.go b/backend/generated-go/v1/setting_service.pb.goindex 7fb0d1c26b..6fcecc2ed6 100644--- a/backend/generated-go/v1/setting_service.pb.go+++ b/backend/generated-go/v1/setting_service.pb.go@@ -221,6 +221,64 @@ func (Announcement_AlertLevel) EnumDescriptor() ([]byte, []int) {return file_v1_setting_service_proto_rawDescGZIP(), []int{9, 0}}+type WorkspaceApprovalSetting_Rule_Source int32++const (+ WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED WorkspaceApprovalSetting_Rule_Source = 0+ WorkspaceApprovalSetting_Rule_DDL WorkspaceApprovalSetting_Rule_Source = 1+ WorkspaceApprovalSetting_Rule_DML WorkspaceApprovalSetting_Rule_Source = 2+ WorkspaceApprovalSetting_Rule_CREATE_DATABASE WorkspaceApprovalSetting_Rule_Source = 3+ WorkspaceApprovalSetting_Rule_EXPORT_DATA WorkspaceApprovalSetting_Rule_Source = 4+ WorkspaceApprovalSetting_Rule_REQUEST_ROLE WorkspaceApprovalSetting_Rule_Source = 5+)++// Enum value maps for WorkspaceApprovalSetting_Rule_Source.+var (+ WorkspaceApprovalSetting_Rule_Source_name = map[int32]string{+ 0: "SOURCE_UNSPECIFIED",+ 1: "DDL",+ 2: "DML",+ 3: "CREATE_DATABASE",+ 4: "EXPORT_DATA",+ 5: "REQUEST_ROLE",+ }+ WorkspaceApprovalSetting_Rule_Source_value = map[string]int32{+ "SOURCE_UNSPECIFIED": 0,+ "DDL": 1,+ "DML": 2,+ "CREATE_DATABASE": 3,+ "EXPORT_DATA": 4,+ "REQUEST_ROLE": 5,+ }+)++func (x WorkspaceApprovalSetting_Rule_Source) Enum() *WorkspaceApprovalSetting_Rule_Source {+ p := new(WorkspaceApprovalSetting_Rule_Source)+ *p = x+ return p+}++func (x WorkspaceApprovalSetting_Rule_Source) String() string {+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))+}++func (WorkspaceApprovalSetting_Rule_Source) Descriptor() protoreflect.EnumDescriptor {+ return file_v1_setting_service_proto_enumTypes[3].Descriptor()+}++func (WorkspaceApprovalSetting_Rule_Source) Type() protoreflect.EnumType {+ return &file_v1_setting_service_proto_enumTypes[3]+}++func (x WorkspaceApprovalSetting_Rule_Source) Number() protoreflect.EnumNumber {+ return protoreflect.EnumNumber(x)+}++// Deprecated: Use WorkspaceApprovalSetting_Rule_Source.Descriptor instead.+func (WorkspaceApprovalSetting_Rule_Source) EnumDescriptor() ([]byte, []int) {+ return file_v1_setting_service_proto_rawDescGZIP(), []int{10, 0, 0}+}+type Algorithm_InnerOuterMask_MaskType int32const (@@ -254,11 +312,11 @@ func (x Algorithm_InnerOuterMask_MaskType) String() string {}func (Algorithm_InnerOuterMask_MaskType) Descriptor() protoreflect.EnumDescriptor {- return file_v1_setting_service_proto_enumTypes[3].Descriptor()+ return file_v1_setting_service_proto_enumTypes[4].Descriptor()}func (Algorithm_InnerOuterMask_MaskType) Type() protoreflect.EnumType {- return &file_v1_setting_service_proto_enumTypes[3]+ return &file_v1_setting_service_proto_enumTypes[4]}func (x Algorithm_InnerOuterMask_MaskType) Number() protoreflect.EnumNumber {@@ -309,11 +367,11 @@ func (x AISetting_Provider) String() string {}func (AISetting_Provider) Descriptor() protoreflect.EnumDescriptor {- return file_v1_setting_service_proto_enumTypes[4].Descriptor()+ return file_v1_setting_service_proto_enumTypes[5].Descriptor()}func (AISetting_Provider) Type() protoreflect.EnumType {- return &file_v1_setting_service_proto_enumTypes[4]+ return &file_v1_setting_service_proto_enumTypes[5]}func (x AISetting_Provider) Number() protoreflect.EnumNumber {@@ -2108,13 +2166,34 @@ type WorkspaceApprovalSetting_Rule struct {// The condition that is associated with the rule.// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec//- // Support variables:- // source: the risk source, check the Source enum in the Risk message for the values, support "==" operator.- // level: the risk level, support 100 (low), 200 (moderate) and 300 (high), support "==" operator.+ // The `source` field filters which rules apply. The `condition` field then evaluates with full context.+ //+ // All supported variables:+ // statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.+ // statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.+ // resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.+ // resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for values.+ // statement.sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.+ // resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.+ // request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ //+ // When source is DDL/DML, support: statement.*, resource.* (excluding request.*)+ // When source is CREATE_DATABASE, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name+ // When source is EXPORT_DATA, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name, resource.schema_name, resource.table_name+ // When source is REQUEST_ROLE, support: resource.project_id, request.expiration_days, request.role//// For examples:- // (source == "DML" && level == 200) || (source == "DDL" && level == 300)- Condition *expr.Expr `protobuf:"bytes,2,opt,name=condition,proto3" json:"condition,omitempty"`+ // resource.environment_id == "prod" && statement.affected_rows >= 100+ // resource.table_name.matches("sensitive_.*") && resource.db_engine == "MYSQL"+ //+ // Legacy format (deprecated): source == "DDL" && level == "HIGH"+ Condition *expr.Expr `protobuf:"bytes,2,opt,name=condition,proto3" json:"condition,omitempty"`+ Source WorkspaceApprovalSetting_Rule_Source `protobuf:"varint,3,opt,name=source,proto3,enum=bytebase.v1.WorkspaceApprovalSetting_Rule_Source" json:"source,omitempty"`unknownFields protoimpl.UnknownFieldssizeCache protoimpl.SizeCache}@@ -2163,6 +2242,13 @@ func (x *WorkspaceApprovalSetting_Rule) GetCondition() *expr.Expr {return nil}+func (x *WorkspaceApprovalSetting_Rule) GetSource() WorkspaceApprovalSetting_Rule_Source {+ if x != nil {+ return x.Source+ }+ return WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED+}+type SchemaTemplateSetting_FieldTemplate struct {state protoimpl.MessageState `protogen:"open.v1"`Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`@@ -3131,12 +3217,20 @@ const file_v1_setting_service_proto_rawDesc = "" +"\x17ALERT_LEVEL_UNSPECIFIED\x10\x00\x12\b\n" +"\x04INFO\x10\x01\x12\v\n" +"\aWARNING\x10\x02\x12\f\n" +- "\bCRITICAL\x10\x03\"\xd0\x01\n" ++ "\bCRITICAL\x10\x03\"\x88\x03\n" +"\x18WorkspaceApprovalSetting\x12@\n" +- "\x05rules\x18\x01 \x03(\v2*.bytebase.v1.WorkspaceApprovalSetting.RuleR\x05rules\x1ar\n" ++ "\x05rules\x18\x01 \x03(\v2*.bytebase.v1.WorkspaceApprovalSetting.RuleR\x05rules\x1a\xa9\x02\n" +"\x04Rule\x129\n" +"\btemplate\x18\x01 \x01(\v2\x1d.bytebase.v1.ApprovalTemplateR\btemplate\x12/\n" +- "\tcondition\x18\x02 \x01(\v2\x11.google.type.ExprR\tcondition\"\xb2\x06\n" ++ "\tcondition\x18\x02 \x01(\v2\x11.google.type.ExprR\tcondition\x12I\n" ++ "\x06source\x18\x03 \x01(\x0e21.bytebase.v1.WorkspaceApprovalSetting.Rule.SourceR\x06source\"j\n" ++ "\x06Source\x12\x16\n" ++ "\x12SOURCE_UNSPECIFIED\x10\x00\x12\a\n" ++ "\x03DDL\x10\x01\x12\a\n" ++ "\x03DML\x10\x02\x12\x13\n" ++ "\x0fCREATE_DATABASE\x10\x03\x12\x0f\n" ++ "\vEXPORT_DATA\x10\x04\x12\x10\n" ++ "\fREQUEST_ROLE\x10\x05\"\xb2\x06\n" +"\x15SchemaTemplateSetting\x12Y\n" +"\x0ffield_templates\x18\x01 \x03(\v20.bytebase.v1.SchemaTemplateSetting.FieldTemplateR\x0efieldTemplates\x12P\n" +"\fcolumn_types\x18\x02 \x03(\v2-.bytebase.v1.SchemaTemplateSetting.ColumnTypeR\vcolumnTypes\x12Y\n" +@@ -3276,135 +3370,137 @@ func file_v1_setting_service_proto_rawDescGZIP() []byte {return file_v1_setting_service_proto_rawDescData}-var file_v1_setting_service_proto_enumTypes = make([]protoimpl.EnumInfo, 5)+var file_v1_setting_service_proto_enumTypes = make([]protoimpl.EnumInfo, 6)var file_v1_setting_service_proto_msgTypes = make([]protoimpl.MessageInfo, 41)var file_v1_setting_service_proto_goTypes = []any{(DatabaseChangeMode)(0), // 0: bytebase.v1.DatabaseChangeMode(Setting_SettingName)(0), // 1: bytebase.v1.Setting.SettingName(Announcement_AlertLevel)(0), // 2: bytebase.v1.Announcement.AlertLevel- (Algorithm_InnerOuterMask_MaskType)(0), // 3: bytebase.v1.Algorithm.InnerOuterMask.MaskType- (AISetting_Provider)(0), // 4: bytebase.v1.AISetting.Provider- (*ListSettingsRequest)(nil), // 5: bytebase.v1.ListSettingsRequest- (*ListSettingsResponse)(nil), // 6: bytebase.v1.ListSettingsResponse- (*GetSettingRequest)(nil), // 7: bytebase.v1.GetSettingRequest- (*GetSettingResponse)(nil), // 8: bytebase.v1.GetSettingResponse- (*UpdateSettingRequest)(nil), // 9: bytebase.v1.UpdateSettingRequest- (*Setting)(nil), // 10: bytebase.v1.Setting- (*Value)(nil), // 11: bytebase.v1.Value- (*AppIMSetting)(nil), // 12: bytebase.v1.AppIMSetting- (*WorkspaceProfileSetting)(nil), // 13: bytebase.v1.WorkspaceProfileSetting- (*Announcement)(nil), // 14: bytebase.v1.Announcement- (*WorkspaceApprovalSetting)(nil), // 15: bytebase.v1.WorkspaceApprovalSetting- (*SchemaTemplateSetting)(nil), // 16: bytebase.v1.SchemaTemplateSetting- (*DataClassificationSetting)(nil), // 17: bytebase.v1.DataClassificationSetting- (*SemanticTypeSetting)(nil), // 18: bytebase.v1.SemanticTypeSetting- (*Algorithm)(nil), // 19: bytebase.v1.Algorithm- (*SCIMSetting)(nil), // 20: bytebase.v1.SCIMSetting- (*PasswordRestrictionSetting)(nil), // 21: bytebase.v1.PasswordRestrictionSetting- (*AISetting)(nil), // 22: bytebase.v1.AISetting- (*EnvironmentSetting)(nil), // 23: bytebase.v1.EnvironmentSetting- (*AppIMSetting_Slack)(nil), // 24: bytebase.v1.AppIMSetting.Slack- (*AppIMSetting_Feishu)(nil), // 25: bytebase.v1.AppIMSetting.Feishu- (*AppIMSetting_Wecom)(nil), // 26: bytebase.v1.AppIMSetting.Wecom- (*AppIMSetting_Lark)(nil), // 27: bytebase.v1.AppIMSetting.Lark- (*AppIMSetting_DingTalk)(nil), // 28: bytebase.v1.AppIMSetting.DingTalk- (*AppIMSetting_IMSetting)(nil), // 29: bytebase.v1.AppIMSetting.IMSetting- (*WorkspaceApprovalSetting_Rule)(nil), // 30: bytebase.v1.WorkspaceApprovalSetting.Rule- (*SchemaTemplateSetting_FieldTemplate)(nil), // 31: bytebase.v1.SchemaTemplateSetting.FieldTemplate- (*SchemaTemplateSetting_ColumnType)(nil), // 32: bytebase.v1.SchemaTemplateSetting.ColumnType- (*SchemaTemplateSetting_TableTemplate)(nil), // 33: bytebase.v1.SchemaTemplateSetting.TableTemplate- (*DataClassificationSetting_DataClassificationConfig)(nil), // 34: bytebase.v1.DataClassificationSetting.DataClassificationConfig- (*DataClassificationSetting_DataClassificationConfig_Level)(nil), // 35: bytebase.v1.DataClassificationSetting.DataClassificationConfig.Level- (*DataClassificationSetting_DataClassificationConfig_DataClassification)(nil), // 36: bytebase.v1.DataClassificationSetting.DataClassificationConfig.DataClassification- nil, // 37: bytebase.v1.DataClassificationSetting.DataClassificationConfig.ClassificationEntry- (*SemanticTypeSetting_SemanticType)(nil), // 38: bytebase.v1.SemanticTypeSetting.SemanticType- (*Algorithm_FullMask)(nil), // 39: bytebase.v1.Algorithm.FullMask- (*Algorithm_RangeMask)(nil), // 40: bytebase.v1.Algorithm.RangeMask- (*Algorithm_MD5Mask)(nil), // 41: bytebase.v1.Algorithm.MD5Mask- (*Algorithm_InnerOuterMask)(nil), // 42: bytebase.v1.Algorithm.InnerOuterMask- (*Algorithm_RangeMask_Slice)(nil), // 43: bytebase.v1.Algorithm.RangeMask.Slice- (*EnvironmentSetting_Environment)(nil), // 44: bytebase.v1.EnvironmentSetting.Environment- nil, // 45: bytebase.v1.EnvironmentSetting.Environment.TagsEntry- (*fieldmaskpb.FieldMask)(nil), // 46: google.protobuf.FieldMask- (*durationpb.Duration)(nil), // 47: google.protobuf.Duration- (Webhook_Type)(0), // 48: bytebase.v1.Webhook.Type- (*ApprovalTemplate)(nil), // 49: bytebase.v1.ApprovalTemplate- (*expr.Expr)(nil), // 50: google.type.Expr- (Engine)(0), // 51: bytebase.v1.Engine- (*ColumnMetadata)(nil), // 52: bytebase.v1.ColumnMetadata- (*ColumnCatalog)(nil), // 53: bytebase.v1.ColumnCatalog- (*TableMetadata)(nil), // 54: bytebase.v1.TableMetadata- (*TableCatalog)(nil), // 55: bytebase.v1.TableCatalog+ (WorkspaceApprovalSetting_Rule_Source)(0), // 3: bytebase.v1.WorkspaceApprovalSetting.Rule.Source+ (Algorithm_InnerOuterMask_MaskType)(0), // 4: bytebase.v1.Algorithm.InnerOuterMask.MaskType+ (AISetting_Provider)(0), // 5: bytebase.v1.AISetting.Provider+ (*ListSettingsRequest)(nil), // 6: bytebase.v1.ListSettingsRequest+ (*ListSettingsResponse)(nil), // 7: bytebase.v1.ListSettingsResponse+ (*GetSettingRequest)(nil), // 8: bytebase.v1.GetSettingRequest+ (*GetSettingResponse)(nil), // 9: bytebase.v1.GetSettingResponse+ (*UpdateSettingRequest)(nil), // 10: bytebase.v1.UpdateSettingRequest+ (*Setting)(nil), // 11: bytebase.v1.Setting+ (*Value)(nil), // 12: bytebase.v1.Value+ (*AppIMSetting)(nil), // 13: bytebase.v1.AppIMSetting+ (*WorkspaceProfileSetting)(nil), // 14: bytebase.v1.WorkspaceProfileSetting+ (*Announcement)(nil), // 15: bytebase.v1.Announcement+ (*WorkspaceApprovalSetting)(nil), // 16: bytebase.v1.WorkspaceApprovalSetting+ (*SchemaTemplateSetting)(nil), // 17: bytebase.v1.SchemaTemplateSetting+ (*DataClassificationSetting)(nil), // 18: bytebase.v1.DataClassificationSetting+ (*SemanticTypeSetting)(nil), // 19: bytebase.v1.SemanticTypeSetting+ (*Algorithm)(nil), // 20: bytebase.v1.Algorithm+ (*SCIMSetting)(nil), // 21: bytebase.v1.SCIMSetting+ (*PasswordRestrictionSetting)(nil), // 22: bytebase.v1.PasswordRestrictionSetting+ (*AISetting)(nil), // 23: bytebase.v1.AISetting+ (*EnvironmentSetting)(nil), // 24: bytebase.v1.EnvironmentSetting+ (*AppIMSetting_Slack)(nil), // 25: bytebase.v1.AppIMSetting.Slack+ (*AppIMSetting_Feishu)(nil), // 26: bytebase.v1.AppIMSetting.Feishu+ (*AppIMSetting_Wecom)(nil), // 27: bytebase.v1.AppIMSetting.Wecom+ (*AppIMSetting_Lark)(nil), // 28: bytebase.v1.AppIMSetting.Lark+ (*AppIMSetting_DingTalk)(nil), // 29: bytebase.v1.AppIMSetting.DingTalk+ (*AppIMSetting_IMSetting)(nil), // 30: bytebase.v1.AppIMSetting.IMSetting+ (*WorkspaceApprovalSetting_Rule)(nil), // 31: bytebase.v1.WorkspaceApprovalSetting.Rule+ (*SchemaTemplateSetting_FieldTemplate)(nil), // 32: bytebase.v1.SchemaTemplateSetting.FieldTemplate+ (*SchemaTemplateSetting_ColumnType)(nil), // 33: bytebase.v1.SchemaTemplateSetting.ColumnType+ (*SchemaTemplateSetting_TableTemplate)(nil), // 34: bytebase.v1.SchemaTemplateSetting.TableTemplate+ (*DataClassificationSetting_DataClassificationConfig)(nil), // 35: bytebase.v1.DataClassificationSetting.DataClassificationConfig+ (*DataClassificationSetting_DataClassificationConfig_Level)(nil), // 36: bytebase.v1.DataClassificationSetting.DataClassificationConfig.Level+ (*DataClassificationSetting_DataClassificationConfig_DataClassification)(nil), // 37: bytebase.v1.DataClassificationSetting.DataClassificationConfig.DataClassification+ nil, // 38: bytebase.v1.DataClassificationSetting.DataClassificationConfig.ClassificationEntry+ (*SemanticTypeSetting_SemanticType)(nil), // 39: bytebase.v1.SemanticTypeSetting.SemanticType+ (*Algorithm_FullMask)(nil), // 40: bytebase.v1.Algorithm.FullMask+ (*Algorithm_RangeMask)(nil), // 41: bytebase.v1.Algorithm.RangeMask+ (*Algorithm_MD5Mask)(nil), // 42: bytebase.v1.Algorithm.MD5Mask+ (*Algorithm_InnerOuterMask)(nil), // 43: bytebase.v1.Algorithm.InnerOuterMask+ (*Algorithm_RangeMask_Slice)(nil), // 44: bytebase.v1.Algorithm.RangeMask.Slice+ (*EnvironmentSetting_Environment)(nil), // 45: bytebase.v1.EnvironmentSetting.Environment+ nil, // 46: bytebase.v1.EnvironmentSetting.Environment.TagsEntry+ (*fieldmaskpb.FieldMask)(nil), // 47: google.protobuf.FieldMask+ (*durationpb.Duration)(nil), // 48: google.protobuf.Duration+ (Webhook_Type)(0), // 49: bytebase.v1.Webhook.Type+ (*ApprovalTemplate)(nil), // 50: bytebase.v1.ApprovalTemplate+ (*expr.Expr)(nil), // 51: google.type.Expr+ (Engine)(0), // 52: bytebase.v1.Engine+ (*ColumnMetadata)(nil), // 53: bytebase.v1.ColumnMetadata+ (*ColumnCatalog)(nil), // 54: bytebase.v1.ColumnCatalog+ (*TableMetadata)(nil), // 55: bytebase.v1.TableMetadata+ (*TableCatalog)(nil), // 56: bytebase.v1.TableCatalog}var file_v1_setting_service_proto_depIdxs = []int32{- 10, // 0: bytebase.v1.ListSettingsResponse.settings:type_name -> bytebase.v1.Setting- 10, // 1: bytebase.v1.GetSettingResponse.setting:type_name -> bytebase.v1.Setting- 10, // 2: bytebase.v1.UpdateSettingRequest.setting:type_name -> bytebase.v1.Setting- 46, // 3: bytebase.v1.UpdateSettingRequest.update_mask:type_name -> google.protobuf.FieldMask- 11, // 4: bytebase.v1.Setting.value:type_name -> bytebase.v1.Value- 12, // 5: bytebase.v1.Value.app_im_setting_value:type_name -> bytebase.v1.AppIMSetting- 13, // 6: bytebase.v1.Value.workspace_profile_setting_value:type_name -> bytebase.v1.WorkspaceProfileSetting- 15, // 7: bytebase.v1.Value.workspace_approval_setting_value:type_name -> bytebase.v1.WorkspaceApprovalSetting- 16, // 8: bytebase.v1.Value.schema_template_setting_value:type_name -> bytebase.v1.SchemaTemplateSetting- 17, // 9: bytebase.v1.Value.data_classification_setting_value:type_name -> bytebase.v1.DataClassificationSetting- 18, // 10: bytebase.v1.Value.semantic_type_setting_value:type_name -> bytebase.v1.SemanticTypeSetting- 20, // 11: bytebase.v1.Value.scim_setting:type_name -> bytebase.v1.SCIMSetting- 21, // 12: bytebase.v1.Value.password_restriction_setting:type_name -> bytebase.v1.PasswordRestrictionSetting- 22, // 13: bytebase.v1.Value.ai_setting:type_name -> bytebase.v1.AISetting- 23, // 14: bytebase.v1.Value.environment_setting:type_name -> bytebase.v1.EnvironmentSetting- 29, // 15: bytebase.v1.AppIMSetting.settings:type_name -> bytebase.v1.AppIMSetting.IMSetting- 47, // 16: bytebase.v1.WorkspaceProfileSetting.token_duration:type_name -> google.protobuf.Duration- 14, // 17: bytebase.v1.WorkspaceProfileSetting.announcement:type_name -> bytebase.v1.Announcement- 47, // 18: bytebase.v1.WorkspaceProfileSetting.maximum_role_expiration:type_name -> google.protobuf.Duration+ 11, // 0: bytebase.v1.ListSettingsResponse.settings:type_name -> bytebase.v1.Setting+ 11, // 1: bytebase.v1.GetSettingResponse.setting:type_name -> bytebase.v1.Setting+ 11, // 2: bytebase.v1.UpdateSettingRequest.setting:type_name -> bytebase.v1.Setting+ 47, // 3: bytebase.v1.UpdateSettingRequest.update_mask:type_name -> google.protobuf.FieldMask+ 12, // 4: bytebase.v1.Setting.value:type_name -> bytebase.v1.Value+ 13, // 5: bytebase.v1.Value.app_im_setting_value:type_name -> bytebase.v1.AppIMSetting+ 14, // 6: bytebase.v1.Value.workspace_profile_setting_value:type_name -> bytebase.v1.WorkspaceProfileSetting+ 16, // 7: bytebase.v1.Value.workspace_approval_setting_value:type_name -> bytebase.v1.WorkspaceApprovalSetting+ 17, // 8: bytebase.v1.Value.schema_template_setting_value:type_name -> bytebase.v1.SchemaTemplateSetting+ 18, // 9: bytebase.v1.Value.data_classification_setting_value:type_name -> bytebase.v1.DataClassificationSetting+ 19, // 10: bytebase.v1.Value.semantic_type_setting_value:type_name -> bytebase.v1.SemanticTypeSetting+ 21, // 11: bytebase.v1.Value.scim_setting:type_name -> bytebase.v1.SCIMSetting+ 22, // 12: bytebase.v1.Value.password_restriction_setting:type_name -> bytebase.v1.PasswordRestrictionSetting+ 23, // 13: bytebase.v1.Value.ai_setting:type_name -> bytebase.v1.AISetting+ 24, // 14: bytebase.v1.Value.environment_setting:type_name -> bytebase.v1.EnvironmentSetting+ 30, // 15: bytebase.v1.AppIMSetting.settings:type_name -> bytebase.v1.AppIMSetting.IMSetting+ 48, // 16: bytebase.v1.WorkspaceProfileSetting.token_duration:type_name -> google.protobuf.Duration+ 15, // 17: bytebase.v1.WorkspaceProfileSetting.announcement:type_name -> bytebase.v1.Announcement+ 48, // 18: bytebase.v1.WorkspaceProfileSetting.maximum_role_expiration:type_name -> google.protobuf.Duration0, // 19: bytebase.v1.WorkspaceProfileSetting.database_change_mode:type_name -> bytebase.v1.DatabaseChangeMode- 47, // 20: bytebase.v1.WorkspaceProfileSetting.inactive_session_timeout:type_name -> google.protobuf.Duration+ 48, // 20: bytebase.v1.WorkspaceProfileSetting.inactive_session_timeout:type_name -> google.protobuf.Duration2, // 21: bytebase.v1.Announcement.level:type_name -> bytebase.v1.Announcement.AlertLevel- 30, // 22: bytebase.v1.WorkspaceApprovalSetting.rules:type_name -> bytebase.v1.WorkspaceApprovalSetting.Rule- 31, // 23: bytebase.v1.SchemaTemplateSetting.field_templates:type_name -> bytebase.v1.SchemaTemplateSetting.FieldTemplate- 32, // 24: bytebase.v1.SchemaTemplateSetting.column_types:type_name -> bytebase.v1.SchemaTemplateSetting.ColumnType- 33, // 25: bytebase.v1.SchemaTemplateSetting.table_templates:type_name -> bytebase.v1.SchemaTemplateSetting.TableTemplate- 34, // 26: bytebase.v1.DataClassificationSetting.configs:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig- 38, // 27: bytebase.v1.SemanticTypeSetting.types:type_name -> bytebase.v1.SemanticTypeSetting.SemanticType- 39, // 28: bytebase.v1.Algorithm.full_mask:type_name -> bytebase.v1.Algorithm.FullMask- 40, // 29: bytebase.v1.Algorithm.range_mask:type_name -> bytebase.v1.Algorithm.RangeMask- 41, // 30: bytebase.v1.Algorithm.md5_mask:type_name -> bytebase.v1.Algorithm.MD5Mask- 42, // 31: bytebase.v1.Algorithm.inner_outer_mask:type_name -> bytebase.v1.Algorithm.InnerOuterMask- 47, // 32: bytebase.v1.PasswordRestrictionSetting.password_rotation:type_name -> google.protobuf.Duration- 4, // 33: bytebase.v1.AISetting.provider:type_name -> bytebase.v1.AISetting.Provider- 44, // 34: bytebase.v1.EnvironmentSetting.environments:type_name -> bytebase.v1.EnvironmentSetting.Environment- 48, // 35: bytebase.v1.AppIMSetting.IMSetting.type:type_name -> bytebase.v1.Webhook.Type- 24, // 36: bytebase.v1.AppIMSetting.IMSetting.slack:type_name -> bytebase.v1.AppIMSetting.Slack- 25, // 37: bytebase.v1.AppIMSetting.IMSetting.feishu:type_name -> bytebase.v1.AppIMSetting.Feishu- 26, // 38: bytebase.v1.AppIMSetting.IMSetting.wecom:type_name -> bytebase.v1.AppIMSetting.Wecom- 27, // 39: bytebase.v1.AppIMSetting.IMSetting.lark:type_name -> bytebase.v1.AppIMSetting.Lark- 28, // 40: bytebase.v1.AppIMSetting.IMSetting.dingtalk:type_name -> bytebase.v1.AppIMSetting.DingTalk- 49, // 41: bytebase.v1.WorkspaceApprovalSetting.Rule.template:type_name -> bytebase.v1.ApprovalTemplate- 50, // 42: bytebase.v1.WorkspaceApprovalSetting.Rule.condition:type_name -> google.type.Expr- 51, // 43: bytebase.v1.SchemaTemplateSetting.FieldTemplate.engine:type_name -> bytebase.v1.Engine- 52, // 44: bytebase.v1.SchemaTemplateSetting.FieldTemplate.column:type_name -> bytebase.v1.ColumnMetadata- 53, // 45: bytebase.v1.SchemaTemplateSetting.FieldTemplate.catalog:type_name -> bytebase.v1.ColumnCatalog- 51, // 46: bytebase.v1.SchemaTemplateSetting.ColumnType.engine:type_name -> bytebase.v1.Engine- 51, // 47: bytebase.v1.SchemaTemplateSetting.TableTemplate.engine:type_name -> bytebase.v1.Engine- 54, // 48: bytebase.v1.SchemaTemplateSetting.TableTemplate.table:type_name -> bytebase.v1.TableMetadata- 55, // 49: bytebase.v1.SchemaTemplateSetting.TableTemplate.catalog:type_name -> bytebase.v1.TableCatalog- 35, // 50: bytebase.v1.DataClassificationSetting.DataClassificationConfig.levels:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig.Level- 37, // 51: bytebase.v1.DataClassificationSetting.DataClassificationConfig.classification:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig.ClassificationEntry- 36, // 52: bytebase.v1.DataClassificationSetting.DataClassificationConfig.ClassificationEntry.value:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig.DataClassification- 19, // 53: bytebase.v1.SemanticTypeSetting.SemanticType.algorithm:type_name -> bytebase.v1.Algorithm- 43, // 54: bytebase.v1.Algorithm.RangeMask.slices:type_name -> bytebase.v1.Algorithm.RangeMask.Slice- 3, // 55: bytebase.v1.Algorithm.InnerOuterMask.type:type_name -> bytebase.v1.Algorithm.InnerOuterMask.MaskType- 45, // 56: bytebase.v1.EnvironmentSetting.Environment.tags:type_name -> bytebase.v1.EnvironmentSetting.Environment.TagsEntry- 5, // 57: bytebase.v1.SettingService.ListSettings:input_type -> bytebase.v1.ListSettingsRequest- 7, // 58: bytebase.v1.SettingService.GetSetting:input_type -> bytebase.v1.GetSettingRequest- 9, // 59: bytebase.v1.SettingService.UpdateSetting:input_type -> bytebase.v1.UpdateSettingRequest- 6, // 60: bytebase.v1.SettingService.ListSettings:output_type -> bytebase.v1.ListSettingsResponse- 10, // 61: bytebase.v1.SettingService.GetSetting:output_type -> bytebase.v1.Setting- 10, // 62: bytebase.v1.SettingService.UpdateSetting:output_type -> bytebase.v1.Setting- 60, // [60:63] is the sub-list for method output_type- 57, // [57:60] is the sub-list for method input_type- 57, // [57:57] is the sub-list for extension type_name- 57, // [57:57] is the sub-list for extension extendee- 0, // [0:57] is the sub-list for field type_name+ 31, // 22: bytebase.v1.WorkspaceApprovalSetting.rules:type_name -> bytebase.v1.WorkspaceApprovalSetting.Rule+ 32, // 23: bytebase.v1.SchemaTemplateSetting.field_templates:type_name -> bytebase.v1.SchemaTemplateSetting.FieldTemplate+ 33, // 24: bytebase.v1.SchemaTemplateSetting.column_types:type_name -> bytebase.v1.SchemaTemplateSetting.ColumnType+ 34, // 25: bytebase.v1.SchemaTemplateSetting.table_templates:type_name -> bytebase.v1.SchemaTemplateSetting.TableTemplate+ 35, // 26: bytebase.v1.DataClassificationSetting.configs:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig+ 39, // 27: bytebase.v1.SemanticTypeSetting.types:type_name -> bytebase.v1.SemanticTypeSetting.SemanticType+ 40, // 28: bytebase.v1.Algorithm.full_mask:type_name -> bytebase.v1.Algorithm.FullMask+ 41, // 29: bytebase.v1.Algorithm.range_mask:type_name -> bytebase.v1.Algorithm.RangeMask+ 42, // 30: bytebase.v1.Algorithm.md5_mask:type_name -> bytebase.v1.Algorithm.MD5Mask+ 43, // 31: bytebase.v1.Algorithm.inner_outer_mask:type_name -> bytebase.v1.Algorithm.InnerOuterMask+ 48, // 32: bytebase.v1.PasswordRestrictionSetting.password_rotation:type_name -> google.protobuf.Duration+ 5, // 33: bytebase.v1.AISetting.provider:type_name -> bytebase.v1.AISetting.Provider+ 45, // 34: bytebase.v1.EnvironmentSetting.environments:type_name -> bytebase.v1.EnvironmentSetting.Environment+ 49, // 35: bytebase.v1.AppIMSetting.IMSetting.type:type_name -> bytebase.v1.Webhook.Type+ 25, // 36: bytebase.v1.AppIMSetting.IMSetting.slack:type_name -> bytebase.v1.AppIMSetting.Slack+ 26, // 37: bytebase.v1.AppIMSetting.IMSetting.feishu:type_name -> bytebase.v1.AppIMSetting.Feishu+ 27, // 38: bytebase.v1.AppIMSetting.IMSetting.wecom:type_name -> bytebase.v1.AppIMSetting.Wecom+ 28, // 39: bytebase.v1.AppIMSetting.IMSetting.lark:type_name -> bytebase.v1.AppIMSetting.Lark+ 29, // 40: bytebase.v1.AppIMSetting.IMSetting.dingtalk:type_name -> bytebase.v1.AppIMSetting.DingTalk+ 50, // 41: bytebase.v1.WorkspaceApprovalSetting.Rule.template:type_name -> bytebase.v1.ApprovalTemplate+ 51, // 42: bytebase.v1.WorkspaceApprovalSetting.Rule.condition:type_name -> google.type.Expr+ 3, // 43: bytebase.v1.WorkspaceApprovalSetting.Rule.source:type_name -> bytebase.v1.WorkspaceApprovalSetting.Rule.Source+ 52, // 44: bytebase.v1.SchemaTemplateSetting.FieldTemplate.engine:type_name -> bytebase.v1.Engine+ 53, // 45: bytebase.v1.SchemaTemplateSetting.FieldTemplate.column:type_name -> bytebase.v1.ColumnMetadata+ 54, // 46: bytebase.v1.SchemaTemplateSetting.FieldTemplate.catalog:type_name -> bytebase.v1.ColumnCatalog+ 52, // 47: bytebase.v1.SchemaTemplateSetting.ColumnType.engine:type_name -> bytebase.v1.Engine+ 52, // 48: bytebase.v1.SchemaTemplateSetting.TableTemplate.engine:type_name -> bytebase.v1.Engine+ 55, // 49: bytebase.v1.SchemaTemplateSetting.TableTemplate.table:type_name -> bytebase.v1.TableMetadata+ 56, // 50: bytebase.v1.SchemaTemplateSetting.TableTemplate.catalog:type_name -> bytebase.v1.TableCatalog+ 36, // 51: bytebase.v1.DataClassificationSetting.DataClassificationConfig.levels:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig.Level+ 38, // 52: bytebase.v1.DataClassificationSetting.DataClassificationConfig.classification:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig.ClassificationEntry+ 37, // 53: bytebase.v1.DataClassificationSetting.DataClassificationConfig.ClassificationEntry.value:type_name -> bytebase.v1.DataClassificationSetting.DataClassificationConfig.DataClassification+ 20, // 54: bytebase.v1.SemanticTypeSetting.SemanticType.algorithm:type_name -> bytebase.v1.Algorithm+ 44, // 55: bytebase.v1.Algorithm.RangeMask.slices:type_name -> bytebase.v1.Algorithm.RangeMask.Slice+ 4, // 56: bytebase.v1.Algorithm.InnerOuterMask.type:type_name -> bytebase.v1.Algorithm.InnerOuterMask.MaskType+ 46, // 57: bytebase.v1.EnvironmentSetting.Environment.tags:type_name -> bytebase.v1.EnvironmentSetting.Environment.TagsEntry+ 6, // 58: bytebase.v1.SettingService.ListSettings:input_type -> bytebase.v1.ListSettingsRequest+ 8, // 59: bytebase.v1.SettingService.GetSetting:input_type -> bytebase.v1.GetSettingRequest+ 10, // 60: bytebase.v1.SettingService.UpdateSetting:input_type -> bytebase.v1.UpdateSettingRequest+ 7, // 61: bytebase.v1.SettingService.ListSettings:output_type -> bytebase.v1.ListSettingsResponse+ 11, // 62: bytebase.v1.SettingService.GetSetting:output_type -> bytebase.v1.Setting+ 11, // 63: bytebase.v1.SettingService.UpdateSetting:output_type -> bytebase.v1.Setting+ 61, // [61:64] is the sub-list for method output_type+ 58, // [58:61] is the sub-list for method input_type+ 58, // [58:58] is the sub-list for extension type_name+ 58, // [58:58] is the sub-list for extension extendee+ 0, // [0:58] is the sub-list for field type_name}func init() { file_v1_setting_service_proto_init() }@@ -3450,7 +3546,7 @@ func file_v1_setting_service_proto_init() {File: protoimpl.DescBuilder{GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_setting_service_proto_rawDesc), len(file_v1_setting_service_proto_rawDesc)),- NumEnums: 5,+ NumEnums: 6,NumMessages: 41,NumExtensions: 0,NumServices: 1,diff --git a/backend/generated-go/v1/setting_service_equal.pb.go b/backend/generated-go/v1/setting_service_equal.pb.goindex 75c3567388..29ccc692dd 100644--- a/backend/generated-go/v1/setting_service_equal.pb.go+++ b/backend/generated-go/v1/setting_service_equal.pb.go@@ -365,6 +365,9 @@ func (x *WorkspaceApprovalSetting_Rule) Equal(y *WorkspaceApprovalSetting_Rule)} else if !proto.Equal(x.Condition, y.Condition) {return false}+ if x.Source != y.Source {+ return false+ }return true}diff --git a/backend/migrator/migration/3.13/0000##migrate_risk_to_approval_rules.sql b/backend/migrator/migration/3.13/0000##migrate_risk_to_approval_rules.sqlnew file mode 100644index 0000000000..e62fdeb090--- /dev/null+++ b/backend/migrator/migration/3.13/0000##migrate_risk_to_approval_rules.sql@@ -0,0 +1,215 @@+-- Migrate risk-based approval rules to direct approval rules+--+-- This migration converts the two-step approval evaluation (risk → approval rule)+-- into a single-step direct evaluation (approval rule with full CEL conditions).+--+-- Before:+-- Risk table: source + level + CEL expression (e.g., resource.environment_id == "prod")+-- Approval rules: source + level match → template (e.g., source == "DDL" && level == "HIGH")+--+-- After:+-- Approval rules: source enum + direct CEL condition → template+-- Risk table: No longer used for approval flow (kept for cleanup in later release)+--+-- The migration:+-- 1. For each risk (ordered by source, then level priority HIGH → MODERATE → LOW)+-- 2. Find the approval rule template that matches this risk's (source, level)+-- 3. Create a new approval rule with source enum + risk's CEL expression + template+-- 4. Add fallback rules (condition = "true") for UNSPECIFIED level per source++-- Helper: Convert risk source string to approval rule source enum name+CREATE OR REPLACE FUNCTION pg_temp.risk_source_to_enum(source_str text)+RETURNS text AS $$+BEGIN+ RETURN CASE source_str+ WHEN 'bb.risk.database.schema.update' THEN 'DDL'+ WHEN 'bb.risk.database.data.update' THEN 'DML'+ WHEN 'bb.risk.database.create' THEN 'CREATE_DATABASE'+ WHEN 'bb.risk.database.data.export' THEN 'EXPORT_DATA'+ WHEN 'bb.risk.request.role' THEN 'REQUEST_ROLE'+ ELSE 'SOURCE_UNSPECIFIED'+ END;+END;+$$ LANGUAGE plpgsql;++-- Helper: Convert approval rule source enum name to risk source string+CREATE OR REPLACE FUNCTION pg_temp.enum_to_risk_source(enum_str text)+RETURNS text AS $$+BEGIN+ RETURN CASE enum_str+ WHEN 'DDL' THEN 'bb.risk.database.schema.update'+ WHEN 'DML' THEN 'bb.risk.database.data.update'+ WHEN 'CREATE_DATABASE' THEN 'bb.risk.database.create'+ WHEN 'EXPORT_DATA' THEN 'bb.risk.database.data.export'+ WHEN 'REQUEST_ROLE' THEN 'bb.risk.request.role'+ ELSE ''+ END;+END;+$$ LANGUAGE plpgsql;++-- Helper: Get level priority (lower = higher priority)+CREATE OR REPLACE FUNCTION pg_temp.level_priority(level_str text)+RETURNS int AS $$+BEGIN+ RETURN CASE level_str+ WHEN 'HIGH' THEN 1+ WHEN 'MODERATE' THEN 2+ WHEN 'LOW' THEN 3+ WHEN 'RISK_LEVEL_UNSPECIFIED' THEN 4+ ELSE 5+ END;+END;+$$ LANGUAGE plpgsql;++-- Helper: Evaluate if a CEL expression matches given source and level+-- This is a simplified parser that handles common patterns like:+-- - source == "DDL" && level == "HIGH"+-- - (source == "DDL" && level == "HIGH") || (source == "DML" && level == "MODERATE")+CREATE OR REPLACE FUNCTION pg_temp.cel_matches_source_level(+ cel_expr text,+ source_val text,+ level_val text+)+RETURNS boolean AS $$+DECLARE+ clause text;+ source_in_clause boolean;+ level_in_clause boolean;+BEGIN+ -- Split expression by '||' (OR operator) and check each clause+ -- For a match, source and level must appear TOGETHER in the same AND clause+ FOR clause IN SELECT unnest(string_to_array(cel_expr, '||'))+ LOOP+ -- Check if this clause contains the source+ source_in_clause := (+ clause LIKE '%source == "' || source_val || '"%'+ OR clause LIKE '%source == ''' || source_val || '''%'+ );++ -- Check if this clause contains the level+ level_in_clause := (+ clause LIKE '%level == "' || level_val || '"%'+ OR clause LIKE '%level == ''' || level_val || '''%'+ );++ -- If both source and level are in the same clause, it's a match+ IF source_in_clause AND level_in_clause THEN+ RETURN true;+ END IF;+ END LOOP;++ RETURN false;+END;+$$ LANGUAGE plpgsql;++-- Main migration: Update WORKSPACE_APPROVAL setting+WITH+-- Step 1: Get all active risks with their source enum names+active_risks AS (+ SELECT+ r.id,+ r.source AS source_str,+ pg_temp.risk_source_to_enum(r.source) AS source_enum,+ r.level,+ r.expression->'expression' AS expression,+ pg_temp.level_priority(r.level) AS priority+ FROM risk r+ WHERE r.active = true+),++-- Step 2: Get the current approval setting+current_setting AS (+ SELECT+ value::jsonb AS setting_json+ FROM setting+ WHERE name = 'WORKSPACE_APPROVAL'+),++-- Step 3: Extract current approval rules (old format)+old_rules AS (+ SELECT+ rule_idx,+ rule->'condition'->>'expression' AS condition_expr,+ rule->'template' AS template+ FROM current_setting,+ jsonb_array_elements(setting_json->'rules') WITH ORDINALITY AS arr(rule, rule_idx)+),++-- Step 4: Match risks to approval rule templates+-- For each risk, find the approval rule template that matches its (source, level)+risk_to_template AS (+ SELECT DISTINCT ON (ar.id)+ ar.id AS risk_id,+ ar.source_enum,+ ar.expression,+ ar.priority,+ orr.template+ FROM active_risks ar+ CROSS JOIN old_rules orr+ WHERE pg_temp.cel_matches_source_level(orr.condition_expr, ar.source_enum, ar.level)+ ORDER BY ar.id, orr.rule_idx -- Take the first matching rule (preserve rule ordering)+),++-- Step 5: Get distinct sources that have approval rules+sources_with_rules AS (+ SELECT DISTINCT source_enum FROM risk_to_template+),++-- Step 6: Add virtual UNSPECIFIED fallback rules+-- These match when no specific risk matches (condition = "true")+unspecified_fallbacks AS (+ SELECT+ swr.source_enum,+ '"true"'::jsonb AS expression,+ 100 AS priority, -- Lower priority than any actual risk+ orr.template+ FROM sources_with_rules swr+ CROSS JOIN old_rules orr+ WHERE pg_temp.cel_matches_source_level(orr.condition_expr, swr.source_enum, 'RISK_LEVEL_UNSPECIFIED')+),++-- Step 7: Combine actual risks and fallbacks, ordered by source then priority+all_new_rules AS (+ -- Actual risks+ SELECT+ source_enum,+ expression,+ priority,+ template+ FROM risk_to_template++ UNION ALL++ -- UNSPECIFIED fallbacks+ SELECT+ source_enum,+ expression,+ priority,+ template+ FROM unspecified_fallbacks++ ORDER BY source_enum, priority+),++-- Step 8: Build the new rules array with explicit ordering+new_rules_json AS (+ SELECT jsonb_agg(+ jsonb_build_object(+ 'source', source_enum,+ 'condition', jsonb_build_object('expression', expression),+ 'template', template+ )+ ORDER BY source_enum, priority+ ) AS rules+ FROM all_new_rules+)++-- Step 9: Update the setting with new rules+UPDATE setting+SET value = jsonb_build_object('rules', COALESCE(nr.rules, '[]'::jsonb))::text+FROM new_rules_json nr+WHERE name = 'WORKSPACE_APPROVAL'+ AND EXISTS (SELECT 1 FROM current_setting);++-- Handle case where WORKSPACE_APPROVAL setting doesn't exist or has no rules+-- (no update needed, approval flow will work without rules - no approval required)diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 526cbefbce..13f412fe1e 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -12,7 +12,7 @@ import (func TestLatestVersion(t *testing.T) {files, err := getSortedVersionedFiles()require.NoError(t, err)- require.Equal(t, semver.MustParse("3.12.5"), *files[len(files)-1].version)+ require.Equal(t, semver.MustParse("3.13.0"), *files[len(files)-1].version)}func TestVersionUnique(t *testing.T) {diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.goindex f037ac8303..9d4120d1b4 100644--- a/backend/runner/approval/runner.go+++ b/backend/runner/approval/runner.go@@ -5,8 +5,8 @@ import ("context""fmt""log/slog"+ "maps""math"- "slices""sync""time"@@ -84,11 +84,6 @@ func (r *Runner) Run(ctx context.Context, wg *sync.WaitGroup) {}func (r *Runner) runOnce(ctx context.Context) {- risks, err := r.store.ListRisks(ctx)- if err != nil {- slog.Error("failed to list risks", log.BBError(err))- return- }approvalSetting, err := r.store.GetWorkspaceApprovalSetting(ctx)if err != nil {slog.Error("failed to get workspace approval setting", log.BBError(err))@@ -100,7 +95,7 @@ func (r *Runner) runOnce(ctx context.Context) {if !ok {return true}- done, err := r.findApprovalTemplateForIssue(ctx, issue, risks, approvalSetting)+ done, err := r.findApprovalTemplateForIssue(ctx, issue, approvalSetting)if err != nil {slog.Error("failed to find approval template for issue", slog.Int("issue", issue.UID), log.BBError(err))}@@ -127,35 +122,46 @@ func (r *Runner) retryFindApprovalTemplate(ctx context.Context) {}}-func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.IssueMessage, risks []*store.RiskMessage, approvalSetting *storepb.WorkspaceApprovalSetting) (bool, error) {+func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.IssueMessage, approvalSetting *storepb.WorkspaceApprovalSetting) (bool, error) {payload := issue.Payloadif payload.Approval != nil && payload.Approval.ApprovalFindingDone {return true, nil}- approvalTemplate, riskLevel, done, err := func() (*storepb.ApprovalTemplate, storepb.RiskLevel, bool, error) {- // no need to find if- // - feature is not enabled+ approvalTemplate, done, err := func() (*storepb.ApprovalTemplate, bool, error) {+ // no need to find if feature is not enabledif r.licenseService.IsFeatureEnabled(v1pb.PlanFeature_FEATURE_APPROVAL_WORKFLOW) != nil {// nolint:nilerr- return nil, 0, true, nil+ return nil, true, nil+ }++ // Step 1: Determine approval source from issue type+ approvalSource, err := r.getApprovalSourceFromIssue(ctx, issue)+ if err != nil {+ return nil, false, errors.Wrap(err, "failed to get approval source from issue")+ }+ if approvalSource == storepb.WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED {+ // Cannot determine source, no approval needed+ return nil, true, nil}- riskLevel, riskSource, done, err := r.getIssueRisk(ctx, issue, risks)+ // Step 2: Build CEL variables for evaluation+ celVarsList, done, err := r.buildCELVariablesForIssue(ctx, issue)if err != nil {- err = errors.Wrap(err, "failed to get issue risk level")- return nil, 0, false, err+ return nil, false, errors.Wrap(err, "failed to build CEL variables for issue")}if !done {- return nil, 0, false, nil+ // Not ready yet (e.g., waiting for plan check runs)+ return nil, false, nil}- approvalTemplate, err := getApprovalTemplate(approvalSetting, riskLevel, riskSource)+ // Step 3: Find matching approval template+ approvalTemplate, err := getApprovalTemplate(approvalSetting, approvalSource, celVarsList)if err != nil {- return nil, 0, false, errors.Wrapf(err, "failed to get approval template, riskLevel: %v", riskLevel)+ return nil, false, errors.Wrapf(err, "failed to get approval template for source: %v", approvalSource)}- return approvalTemplate, riskLevel, true, nil+ return approvalTemplate, true, nil}()if err != nil {if updateErr := updateIssueApprovalPayload(ctx, r.store, issue, &storepb.IssuePayloadApproval{@@ -182,7 +188,7 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.payload.Approval = &storepb.IssuePayloadApproval{ApprovalFindingDone: true,- RiskLevel: riskLevel,+ RiskLevel: storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, // Risk level no longer calculated after 3.13ApprovalTemplate: approvalTemplate,Approvers: nil,}@@ -267,92 +273,124 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.return true, nil}-func getApprovalTemplate(approvalSetting *storepb.WorkspaceApprovalSetting, riskLevel storepb.RiskLevel, riskSource store.RiskSource) (*storepb.ApprovalTemplate, error) {+// getApprovalTemplate finds the first matching approval template for the given source and CEL variables.+// After the risk layer removal (3.13), approval rules are directly evaluated with full CEL context.+// The rules are ordered by priority (HIGH risk rules first, then MODERATE, then LOW, then UNSPECIFIED).+// First matching rule wins.+//+// Parameters:+// - approvalSetting: workspace approval setting containing rules+// - riskSource: the approval source enum (DDL, DML, CREATE_DATABASE, EXPORT_DATA, REQUEST_ROLE)+// - celVarsList: list of CEL variable maps (one per task/component in the issue)+//+// For each rule filtered by source, we check if ANY of the celVars maps matches the condition.+// This preserves the "maximum risk" behavior: if any task matches a high-priority rule, that template is used.+func getApprovalTemplate(approvalSetting *storepb.WorkspaceApprovalSetting, riskSource storepb.WorkspaceApprovalSetting_Rule_Source, celVarsList []map[string]any) (*storepb.ApprovalTemplate, error) {if len(approvalSetting.Rules) == 0 {return nil, nil}+ if len(celVarsList) == 0 {+ return nil, nil+ }e, err := cel.NewEnv(common.ApprovalFactors...)if err != nil {return nil, err}++ // Rules are already ordered by priority (migration ensures this)+ // First matching rule winsfor _, rule := range approvalSetting.Rules {+ // Filter by source+ if rule.Source != riskSource {+ continue+ }++ // Empty condition means this rule always matches (fallback rule)if rule.Condition == nil || rule.Condition.Expression == "" {continue}++ // Special case: "true" expression always matches (fallback from UNSPECIFIED level)+ if rule.Condition.Expression == "true" {+ return rule.Template, nil+ }+ast, issues := e.Compile(rule.Condition.Expression)if issues != nil && issues.Err() != nil {return nil, issues.Err()}- prg, err := e.Program(ast)+ prg, err := e.Program(ast, cel.EvalOptions(cel.OptPartialEval))if err != nil {return nil, errors.Wrap(err, "failed to compile expression")}- out, _, err := prg.Eval(map[string]any{- common.CELAttributeLevel: riskLevel.String(),- common.CELAttributeSource: apiv1.ConvertToV1Source(riskSource).String(),- })- if err != nil {- return nil, err- }- if res, ok := out.Equal(celtypes.True).Value().(bool); ok && res {- return rule.Template, nil+ // Check if ANY of the CEL variable maps matches this rule's condition+ for _, celVars := range celVarsList {+ vars, err := e.PartialVars(celVars)+ if err != nil {+ return nil, errors.Wrap(err, "failed to create partial vars")+ }+ out, _, err := prg.Eval(vars)+ if err != nil {+ // Evaluation error - continue to next celVars map+ continue+ }+ if res, ok := out.Equal(celtypes.True).Value().(bool); ok && res {+ return rule.Template, nil+ }}}return nil, nil}-func (r *Runner) getIssueRisk(ctx context.Context, issue *store.IssueMessage, risks []*store.RiskMessage) (storepb.RiskLevel, store.RiskSource, bool, error) {- // sort by level DESC, higher risks go first.- slices.SortFunc(risks, func(a, b *store.RiskMessage) int {- if a.Level > b.Level {- return -1- } else if a.Level < b.Level {- return 1- }- return 0- })-+// buildCELVariablesForIssue builds the CEL variable maps for evaluating approval rules.+// Returns a list of CEL variable maps (one per task/component), done flag, and error.+// done=false means the caller should retry later (e.g., waiting for plan check runs).+func (r *Runner) buildCELVariablesForIssue(ctx context.Context, issue *store.IssueMessage) ([]map[string]any, bool, error) {switch issue.Type {case storepb.Issue_GRANT_REQUEST:- return r.getGrantRequestIssueRisk(ctx, issue, risks)+ return r.buildCELVariablesForGrantRequest(ctx, issue)case storepb.Issue_DATABASE_CHANGE:- return r.getDatabaseGeneralIssueRisk(ctx, issue, risks)+ return r.buildCELVariablesForDatabaseChange(ctx, issue)case storepb.Issue_DATABASE_EXPORT:- return r.getDatabaseDataExportIssueRisk(ctx, issue, risks)+ return r.buildCELVariablesForDataExport(ctx, issue)default:- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Errorf("unknown issue type %v", issue.Type)+ return nil, false, errors.Errorf("unknown issue type %v", issue.Type)}}-func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.IssueMessage, risks []*store.RiskMessage) (storepb.RiskLevel, store.RiskSource, bool, error) {+// buildCELVariablesForDatabaseChange builds CEL variables for DATABASE_CHANGE issues.+// This includes DDL and DML operations.+func (r *Runner) buildCELVariablesForDatabaseChange(ctx context.Context, issue *store.IssueMessage) ([]map[string]any, bool, error) {if issue.PlanUID == nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Errorf("expected plan UID in issue %v", issue.UID)+ return nil, false, errors.Errorf("expected plan UID in issue %v", issue.UID)}plan, err := r.store.GetPlan(ctx, &store.FindPlanMessage{UID: issue.PlanUID})if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to get plan %v", *issue.PlanUID)+ return nil, false, errors.Wrapf(err, "failed to get plan %v", *issue.PlanUID)}if plan == nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Errorf("plan %v not found", *issue.PlanUID)+ return nil, false, errors.Errorf("plan %v not found", *issue.PlanUID)}- // Conclude risk source from task types.+ // Check if we can conclude the operation typeriskSource := getRiskSourceFromPlan(plan.Config)- // Cannot conclude risk source.if riskSource == store.RiskSourceUnknown {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, true, nil+ // Cannot determine source, return done=true with empty list (no approval needed)+ return []map[string]any{{}}, true, nil}+ // Check plan check runs statusplanCheckRuns, err := r.store.ListPlanCheckRuns(ctx, &store.FindPlanCheckRunMessage{PlanUID: &plan.UID,Type: &[]store.PlanCheckRunType{store.PlanCheckDatabaseStatementSummaryReport},})if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to list plan check runs for plan %v", plan.UID)+ return nil, false, errors.Wrapf(err, "failed to list plan check runs for plan %v", plan.UID)}+type Key struct {InstanceID stringDatabaseName string@@ -366,61 +404,34 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.IlatestPlanCheckRun[key] = run}- // Get the max risk level of the same risk source.- // risks is sorted by level DESC, so we just need to return the 1st matched risk.- var maxRiskSourceRiskLevel storepb.RiskLevel- for _, risk := range risks {- if !risk.Active {- continue- }- if risk.Source != riskSource {- continue- }- maxRiskSourceRiskLevel = risk.Level- break- }-- // If any plan check run is skipped because of large SQL,- // return the max risk level in the risks of the same risk source.- for _, run := range latestPlanCheckRun {- for _, result := range run.Result.GetResults() {- if result.GetCode() == common.SizeExceeded.Int32() {- return maxRiskSourceRiskLevel, riskSource, true, nil- }- }- }-+ // Wait for plan check runs to completevar planCheckRunDone int- // the latest plan check run is not done yet, return done=falsefor _, run := range latestPlanCheckRun {if run.Status != store.PlanCheckRunStatusRunning {planCheckRunDone++}}planCheckRunCount := len(latestPlanCheckRun)- // We have less than 5 planCheckRuns in total.- // We wait for all of them to finish.if planCheckRunCount < common.MinimumCompletedPlanCheckRun && planCheckRunCount != planCheckRunDone {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, nil+ return nil, false, nil // Not ready yet, retry later}- // We have 5 or more planCheckRuns in total.- // We need at least 5 completed plan check run.if planCheckRunCount >= common.MinimumCompletedPlanCheckRun && planCheckRunDone < common.MinimumCompletedPlanCheckRun {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, nil+ return nil, false, nil // Not ready yet, retry later}+ // Build CEL variables for each taskpipelineCreate, err := apiv1.GetPipelineCreate(ctx, r.store, r.sheetManager, r.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), issue.Project)if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrap(err, "failed to get pipeline create")+ return nil, false, errors.Wrap(err, "failed to get pipeline create")}- var maxRiskLevel storepb.RiskLevel+ var celVarsList []map[string]anyfor _, task := range pipelineCreate.Tasks {instance, err := r.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID,})if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to get instance %v", task.InstanceID)+ return nil, false, errors.Wrapf(err, "failed to get instance %v", task.InstanceID)}if instance.Deleted {continue@@ -431,7 +442,7 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.Iif sheetUID != 0 {statement, err := r.store.GetSheetStatementByID(ctx, sheetUID)if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, true, errors.Wrapf(err, "failed to get statement in sheet %v", sheetUID)+ return nil, true, errors.Wrapf(err, "failed to get statement in sheet %v", sheetUID)}taskStatement = statement}@@ -447,7 +458,7 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.IDatabaseName: task.DatabaseName,})if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err+ return nil, false, err}databaseName = database.DatabaseNameif database.EffectiveEnvironmentID != nil {@@ -455,87 +466,96 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I}}- commonArgs := map[string]any{+ // Base CEL variables+ celVars := map[string]any{common.CELAttributeResourceEnvironmentID: environmentID,common.CELAttributeResourceProjectID: issue.Project.ResourceID,common.CELAttributeResourceInstanceID: instance.ResourceID,common.CELAttributeResourceDatabaseName: databaseName,- // convert to string type otherwise cel-go will complain that storepb.Engine is not string type.- common.CELAttributeResourceDBEngine: instance.Metadata.GetEngine().String(),- common.CELAttributeStatementText: taskStatement,- }- risk, err := func() (storepb.RiskLevel, error) {- // The summary report is not always available.- // Use the greatest risk.- var greatestRiskLevel storepb.RiskLevel- riskLevel, err := apiv1.CalculateRiskLevelWithOptionalSummaryReport(ctx, risks, commonArgs, riskSource, nil)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, err- }- if riskLevel > greatestRiskLevel {- greatestRiskLevel = riskLevel- }+ common.CELAttributeResourceDBEngine: instance.Metadata.GetEngine().String(),+ common.CELAttributeStatementText: taskStatement,+ }++ // Add summary report data if available+ if run, ok := latestPlanCheckRun[Key{+ InstanceID: instance.ResourceID,+ DatabaseName: databaseName,+ }]; ok {+ for _, result := range run.Result.Results {+ report := result.GetSqlSummaryReport()+ if report == nil {+ continue+ }- if run, ok := latestPlanCheckRun[Key{- InstanceID: instance.ResourceID,- DatabaseName: databaseName,- }]; ok {- for _, result := range run.Result.Results {- report := result.GetSqlSummaryReport()- if report == nil {- continue+ // Calculate table rows from changed resources+ var tableRows int64+ var tableNames []string+ for _, db := range report.GetChangedResources().GetDatabases() {+ for _, sc := range db.GetSchemas() {+ for _, tb := range sc.GetTables() {+ tableRows += tb.GetTableRows()+ tableNames = append(tableNames, tb.Name)+ }}- riskLevel, err := apiv1.CalculateRiskLevelWithOptionalSummaryReport(ctx, risks, commonArgs, riskSource, report)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, err+ }++ celVars[common.CELAttributeStatementAffectedRows] = report.AffectedRows+ celVars[common.CELAttributeStatementTableRows] = tableRows++ // Create CEL variables for each statement type and table combination+ // to ensure we match the most appropriate approval rule+ if len(report.StatementTypes) > 0 && len(tableNames) > 0 {+ for _, statementType := range report.StatementTypes {+ for _, tableName := range tableNames {+ vars := maps.Clone(celVars)+ vars[common.CELAttributeStatementSQLType] = statementType+ vars[common.CELAttributeResourceTableName] = tableName+ celVarsList = append(celVarsList, vars)+ }}- if riskLevel > greatestRiskLevel {- greatestRiskLevel = riskLevel+ } else if len(report.StatementTypes) > 0 {+ for _, statementType := range report.StatementTypes {+ vars := maps.Clone(celVars)+ vars[common.CELAttributeStatementSQLType] = statementType+ celVarsList = append(celVarsList, vars)}+ } else {+ celVarsList = append(celVarsList, celVars)}+ break // Use first report}- return greatestRiskLevel, nil- }()- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to evaluate risk expression for risk source %v", riskSource)+ } else {+ celVarsList = append(celVarsList, celVars)}+ }- if maxRiskLevel < risk {- maxRiskLevel = risk- }- if maxRiskLevel == maxRiskSourceRiskLevel {- return maxRiskLevel, riskSource, true, nil- }+ // If no tasks, return empty list (no approval needed)+ if len(celVarsList) == 0 {+ celVarsList = append(celVarsList, map[string]any{})}- return maxRiskLevel, riskSource, true, nil+ return celVarsList, true, nil}-func (r *Runner) getDatabaseDataExportIssueRisk(ctx context.Context, issue *store.IssueMessage, risks []*store.RiskMessage) (storepb.RiskLevel, store.RiskSource, bool, error) {+// buildCELVariablesForDataExport builds CEL variables for DATABASE_EXPORT issues.+func (r *Runner) buildCELVariablesForDataExport(ctx context.Context, issue *store.IssueMessage) ([]map[string]any, bool, error) {if issue.PlanUID == nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Errorf("expected plan UID in issue %v", issue.UID)+ return nil, false, errors.Errorf("expected plan UID in issue %v", issue.UID)}plan, err := r.store.GetPlan(ctx, &store.FindPlanMessage{UID: issue.PlanUID})if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to get plan %v", *issue.PlanUID)+ return nil, false, errors.Wrapf(err, "failed to get plan %v", *issue.PlanUID)}if plan == nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Errorf("plan %v not found", *issue.PlanUID)+ return nil, false, errors.Errorf("plan %v not found", *issue.PlanUID)}pipelineCreate, err := apiv1.GetPipelineCreate(ctx, r.store, r.sheetManager, r.dbFactory, plan.Config.GetSpecs(), plan.Config.GetDeployment(), issue.Project)if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrap(err, "failed to get pipeline create")- }-- riskSource := store.RiskSourceDatabaseDataExport-- e, err := cel.NewEnv(common.RiskFactors...)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err+ return nil, false, errors.Wrap(err, "failed to get pipeline create")}- var maxRiskLevel storepb.RiskLevel+ var celVarsList []map[string]anyfor _, task := range pipelineCreate.Tasks {if task.Type != storepb.Task_DATABASE_EXPORT {continue@@ -544,7 +564,7 @@ func (r *Runner) getDatabaseDataExportIssueRisk(ctx context.Context, issue *storResourceID: &task.InstanceID,})if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to get instance %v", task.InstanceID)+ return nil, false, errors.Wrapf(err, "failed to get instance %v", task.InstanceID)}if instance.Deleted {continue@@ -555,171 +575,101 @@ func (r *Runner) getDatabaseDataExportIssueRisk(ctx context.Context, issue *storDatabaseName: task.DatabaseName,})if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err+ return nil, false, err}- databaseName := database.DatabaseName- environmentID := database.EffectiveEnvironmentID- risk, err := func() (storepb.RiskLevel, error) {- for _, risk := range risks {- if !risk.Active {- continue- }- if risk.Source != riskSource {- continue- }- if risk.Expression == nil || risk.Expression.Expression == "" {- continue- }- ast, issues := e.Parse(risk.Expression.Expression)- if issues != nil && issues.Err() != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, errors.Errorf("failed to parse expression: %v", issues.Err())- }- prg, err := e.Program(ast, cel.EvalOptions(cel.OptPartialEval))- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, err- }- envID := ""- if environmentID != nil {- envID = *environmentID- }- args := map[string]any{- common.CELAttributeResourceEnvironmentID: envID,- common.CELAttributeResourceProjectID: issue.Project.ResourceID,- common.CELAttributeResourceInstanceID: instance.ResourceID,- common.CELAttributeResourceDatabaseName: databaseName,- common.CELAttributeResourceDBEngine: instance.Metadata.GetEngine().String(),- }-- vars, err := e.PartialVars(args)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, errors.Wrapf(err, "failed to get vars")- }- out, _, err := prg.Eval(vars)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, errors.Wrapf(err, "failed to eval expression")- }- if res, ok := out.Equal(celtypes.True).Value().(bool); ok && res {- return risk.Level, nil- }- }- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, nil- }()- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrapf(err, "failed to evaluate risk expression for risk source %v", riskSource)+ envID := ""+ if database.EffectiveEnvironmentID != nil {+ envID = *database.EffectiveEnvironmentID}- if maxRiskLevel < risk {- maxRiskLevel = risk- }- if maxRiskLevel == storepb.RiskLevel_HIGH {- return maxRiskLevel, riskSource, true, nil+ celVars := map[string]any{+ common.CELAttributeResourceEnvironmentID: envID,+ common.CELAttributeResourceProjectID: issue.Project.ResourceID,+ common.CELAttributeResourceInstanceID: instance.ResourceID,+ common.CELAttributeResourceDatabaseName: database.DatabaseName,+ common.CELAttributeResourceDBEngine: instance.Metadata.GetEngine().String(),}+ celVarsList = append(celVarsList, celVars)}- return maxRiskLevel, riskSource, true, nil+ if len(celVarsList) == 0 {+ celVarsList = append(celVarsList, map[string]any{})+ }++ return celVarsList, true, nil}-func (r *Runner) getGrantRequestIssueRisk(ctx context.Context, issue *store.IssueMessage, risks []*store.RiskMessage) (storepb.RiskLevel, store.RiskSource, bool, error) {+// buildCELVariablesForGrantRequest builds CEL variables for GRANT_REQUEST issues.+func (r *Runner) buildCELVariablesForGrantRequest(ctx context.Context, issue *store.IssueMessage) ([]map[string]any, bool, error) {payload := issue.Payloadif payload.GrantRequest == nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.New("grant request payload not found")- }-- // fast path, no risks so return the DEFAULT risk level- if len(risks) == 0 {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskRequestRole, true, nil- }-- e, err := cel.NewEnv(common.RiskFactors...)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err+ return nil, false, errors.New("grant request payload not found")}factors, err := common.GetQueryExportFactors(payload.GetGrantRequest().GetCondition().GetExpression())if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrap(err, "failed to get query export factors")+ return nil, false, errors.Wrap(err, "failed to get query export factors")}- // Default to max float64 if expiration is not set. AKA no expiration.- expirationDays := math.MaxFloat64++ // Default to max int if expiration is not set (no expiration)+ expirationDays := int64(math.MaxInt32)if payload.GrantRequest.Expiration != nil {- expirationDays = payload.GrantRequest.Expiration.AsDuration().Hours() / 24+ expirationDays = int64(payload.GrantRequest.Expiration.AsDuration().Hours() / 24)}- databaseMap, err := r.getDatabaseMap(ctx, factors.Databases)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Wrap(err, "failed to retrieve database map")+ baseVars := map[string]any{+ common.CELAttributeResourceProjectID: issue.Project.ResourceID,+ common.CELAttributeRequestExpirationDays: expirationDays,+ common.CELAttributeRequestRole: payload.GrantRequest.Role,}- // Get the max risk level of the same risk source.- // risks is sorted by level DESC, so we just need to return the 1st matched risk.- for _, risk := range risks {- if !risk.Active {- continue+ // If no specific databases, create one entry per environment+ if len(factors.Databases) == 0 {+ environments, err := r.store.GetEnvironmentSetting(ctx)+ if err != nil {+ return nil, false, err}- if risk.Source != store.RiskRequestRole {- continue+ var celVarsList []map[string]any+ for _, environment := range environments.GetEnvironments() {+ celVars := make(map[string]any)+ for k, v := range baseVars {+ celVars[k] = v+ }+ celVars[common.CELAttributeResourceEnvironmentID] = environment.Id+ celVarsList = append(celVarsList, celVars)}- if risk.Expression == nil || risk.Expression.Expression == "" {- continue+ if len(celVarsList) == 0 {+ celVarsList = append(celVarsList, baseVars)}+ return celVarsList, true, nil+ }- ast, issues := e.Parse(risk.Expression.Expression)- if issues != nil && issues.Err() != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, errors.Errorf("failed to parse expression: %v", issues.Err())- }- prg, err := e.Program(ast, cel.EvalOptions(cel.OptPartialEval))- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err- }+ // Build one entry per database+ databaseMap, err := r.getDatabaseMap(ctx, factors.Databases)+ if err != nil {+ return nil, false, errors.Wrap(err, "failed to retrieve database map")+ }- args := map[string]any{- common.CELAttributeResourceProjectID: issue.Project.ResourceID,- common.CELAttributeRequestExpirationDays: expirationDays,- common.CELAttributeRequestRole: payload.GrantRequest.Role,+ var celVarsList []map[string]any+ for _, database := range databaseMap {+ celVars := make(map[string]any)+ for k, v := range baseVars {+ celVars[k] = v}- if len(factors.Databases) == 0 {- environments, err := r.store.GetEnvironmentSetting(ctx)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err- }- for _, environment := range environments.GetEnvironments() {- args[common.CELAttributeResourceEnvironmentID] = environment.Id- vars, err := e.PartialVars(args)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err- }- out, _, err := prg.Eval(vars)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err- }- if res, ok := out.Equal(celtypes.True).Value().(bool); ok && res {- return risk.Level, store.RiskRequestRole, true, nil- }- }+ if database.EffectiveEnvironmentID != nil {+ celVars[common.CELAttributeResourceEnvironmentID] = *database.EffectiveEnvironmentID+ } else {+ celVars[common.CELAttributeResourceEnvironmentID] = ""}+ celVarsList = append(celVarsList, celVars)+ }- for _, database := range databaseMap {- if database.EffectiveEnvironmentID != nil {- args[common.CELAttributeResourceEnvironmentID] = *database.EffectiveEnvironmentID- } else {- args[common.CELAttributeResourceEnvironmentID] = ""- }- vars, err := e.PartialVars(args)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err- }- out, _, err := prg.Eval(vars)- if err != nil {- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskSourceUnknown, false, err- }- if res, ok := out.Equal(celtypes.True).Value().(bool); ok && res {- return risk.Level, store.RiskRequestRole, true, nil- }- }+ if len(celVarsList) == 0 {+ celVarsList = append(celVarsList, baseVars)}- return storepb.RiskLevel_RISK_LEVEL_UNSPECIFIED, store.RiskRequestRole, true, nil+ return celVarsList, true, nil}func (r *Runner) getDatabaseMap(ctx context.Context, databases []string) (map[string]*store.DatabaseMessage, error) {@@ -777,6 +727,58 @@ func getRiskSourceFromPlan(config *storepb.PlanConfig) store.RiskSource {return store.RiskSourceUnknown}+// getApprovalSourceFromPlan determines the approval rule source enum from the plan config.+// This is used after the risk layer removal to directly filter approval rules by source.+func getApprovalSourceFromPlan(config *storepb.PlanConfig) storepb.WorkspaceApprovalSetting_Rule_Source {+ for _, spec := range config.GetSpecs() {+ switch v := spec.Config.(type) {+ case *storepb.PlanConfig_Spec_CreateDatabaseConfig:+ return storepb.WorkspaceApprovalSetting_Rule_CREATE_DATABASE+ case *storepb.PlanConfig_Spec_ChangeDatabaseConfig:+ switch v.ChangeDatabaseConfig.Type {+ case storepb.PlanConfig_ChangeDatabaseConfig_MIGRATE:+ switch v.ChangeDatabaseConfig.MigrateType {+ case storepb.MigrationType_DML:+ return storepb.WorkspaceApprovalSetting_Rule_DML+ default:+ return storepb.WorkspaceApprovalSetting_Rule_DDL+ }+ case storepb.PlanConfig_ChangeDatabaseConfig_SDL:+ return storepb.WorkspaceApprovalSetting_Rule_DDL+ default:+ return storepb.WorkspaceApprovalSetting_Rule_DDL+ }+ case *storepb.PlanConfig_Spec_ExportDataConfig:+ return storepb.WorkspaceApprovalSetting_Rule_EXPORT_DATA+ }+ }+ return storepb.WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED+}++// getApprovalSourceFromIssue determines the approval rule source enum from the issue type.+func (r *Runner) getApprovalSourceFromIssue(ctx context.Context, issue *store.IssueMessage) (storepb.WorkspaceApprovalSetting_Rule_Source, error) {+ switch issue.Type {+ case storepb.Issue_GRANT_REQUEST:+ return storepb.WorkspaceApprovalSetting_Rule_REQUEST_ROLE, nil+ case storepb.Issue_DATABASE_CHANGE:+ if issue.PlanUID == nil {+ return storepb.WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED, errors.Errorf("expected plan UID in issue %v", issue.UID)+ }+ plan, err := r.store.GetPlan(ctx, &store.FindPlanMessage{UID: issue.PlanUID})+ if err != nil {+ return storepb.WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED, errors.Wrapf(err, "failed to get plan %v", *issue.PlanUID)+ }+ if plan == nil {+ return storepb.WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED, errors.Errorf("plan %v not found", *issue.PlanUID)+ }+ return getApprovalSourceFromPlan(plan.Config), nil+ case storepb.Issue_DATABASE_EXPORT:+ return storepb.WorkspaceApprovalSetting_Rule_EXPORT_DATA, nil+ default:+ return storepb.WorkspaceApprovalSetting_Rule_SOURCE_UNSPECIFIED, errors.Errorf("unknown issue type %v", issue.Type)+ }+}+func updateIssueApprovalPayload(ctx context.Context, s *store.Store, issue *store.IssueMessage, approval *storepb.IssuePayloadApproval) error {if _, err := s.UpdateIssueV2(ctx, issue.UID, &store.UpdateIssueMessage{PayloadUpsert: &storepb.Issue{diff --git a/backend/tests/risk_calculation_test.go b/backend/tests/risk_calculation_test.goindex e494f9d761..ea45e6b800 100644--- a/backend/tests/risk_calculation_test.go+++ b/backend/tests/risk_calculation_test.go@@ -14,7 +14,11 @@ import (v1pb "github.com/bytebase/bytebase/backend/generated-go/v1")-func TestRiskLevelCalculation(t *testing.T) {+// TestApprovalRuleMatching tests that approval rules with CEL expressions+// are correctly matched and applied to issues.+// Note: As of 3.13, the risk intermediate layer is removed. Approval rules+// now directly evaluate CEL expressions instead of calculating risk levels.+func TestApprovalRuleMatching(t *testing.T) {t.Parallel()a := require.New(t)ctx := context.Background()@@ -47,8 +51,11 @@ func TestRiskLevelCalculation(t *testing.T) {err = ctl.createDatabaseV2(ctx, ctl.project, instanceResp.Msg, nil, dbName, "")a.NoError(err)- // Create a risk rule that evaluates based on environment context- // This should work without summary reports+ // Note: In 3.13+, risk rules are converted to approval rules via migration.+ // This test creates a risk rule to verify that the risk API still works+ // and that the approval flow completes without errors.+ // The actual approval template matching now evaluates CEL expressions directly+ // without calculating an intermediate risk level._, err = ctl.riskServiceClient.CreateRisk(ctx, connect.NewRequest(&v1pb.CreateRiskRequest{Risk: &v1pb.Risk{Title: "Production DDL Risk",@@ -88,26 +95,26 @@ func TestRiskLevelCalculation(t *testing.T) {}},},}))- a.NoError(err, "Plan creation should succeed even without summary reports")+ a.NoError(err, "Plan creation should succeed")// Verify plan was created successfullya.NotNil(planResp.Msg)a.Equal("Test DDL Plan", planResp.Msg.Title)- // Create issue with the plan - this triggers risk level calculation+ // Create issue with the plan - this triggers approval rule matchingissueResp, err := ctl.issueServiceClient.CreateIssue(ctx, connect.NewRequest(&v1pb.CreateIssueRequest{Parent: ctl.project.Name,Issue: &v1pb.Issue{- Title: "Test Issue for Risk Calculation",+ Title: "Test Issue for Approval Rule Matching",Type: v1pb.Issue_DATABASE_CHANGE,- Description: "Testing risk calculation without summary reports",+ Description: "Testing approval rule matching",Plan: planResp.Msg.Name,},}))- a.NoError(err, "Issue creation should succeed even without summary reports")+ a.NoError(err, "Issue creation should succeed")// Check issue status 5 times with 3 second intervals- // issue.ApprovalFindingDone indicates that the approval flow is generated and issue.RiskLevel is available+ // Wait for approval finding to completevar issue *v1pb.Issuefor i := 0; i < 5; i++ {if i > 0 {@@ -121,8 +128,8 @@ func TestRiskLevelCalculation(t *testing.T) {issue = issueGetResp.Msg// Log the current state for debugging- t.Logf("Check %d: ApprovalStatus=%v, RiskLevel=%v, ApprovalStatusError='%s'",- i+1, issue.ApprovalStatus, issue.RiskLevel, issue.ApprovalStatusError)+ t.Logf("Check %d: ApprovalStatus=%v, ApprovalStatusError='%s'",+ i+1, issue.ApprovalStatus, issue.ApprovalStatusError)// Check if approval finding is completeif issue.ApprovalStatus != v1pb.Issue_CHECKING {@@ -132,16 +139,14 @@ func TestRiskLevelCalculation(t *testing.T) {// Verify that the approval finding process completed successfullya.NotNil(issue, "Issue should be retrievable")- a.NotEqual(v1pb.Issue_CHECKING, issue.ApprovalStatus, "Approval finding should complete even without summary reports")- a.NotEqual(v1pb.Issue_ERROR, issue.ApprovalStatus, "Approval finding should not have errors despite missing summary reports")-- a.Equal(v1pb.RiskLevel_HIGH, issue.RiskLevel, "Issue risk level should be HIGH")+ a.NotEqual(v1pb.Issue_CHECKING, issue.ApprovalStatus, "Approval finding should complete")+ a.NotEqual(v1pb.Issue_ERROR, issue.ApprovalStatus, "Approval finding should not have errors")}-// TestRiskLevelCalculationWithInvalidSQL tests the fix for issue where-// risk level calculation should work without requiring summary reports.+// TestApprovalRuleMatchingWithInvalidSQL tests that approval rule matching+// works even when SQL is invalid and summary reports cannot be generated.// This is a regression test for PR #16793.-func TestRiskLevelCalculationWithInvalidSQL(t *testing.T) {+func TestApprovalRuleMatchingWithInvalidSQL(t *testing.T) {t.Parallel()a := require.New(t)ctx := context.Background()@@ -217,22 +222,22 @@ func TestRiskLevelCalculationWithInvalidSQL(t *testing.T) {}},},}))- a.NoError(err, "Plan creation should succeed even with invalid SQL that breaks summary reports")+ a.NoError(err, "Plan creation should succeed even with invalid SQL")- // Create issue with the plan - this triggers risk level calculation+ // Create issue with the plan - this triggers approval rule matchingissueResp, err := ctl.issueServiceClient.CreateIssue(ctx, connect.NewRequest(&v1pb.CreateIssueRequest{Parent: ctl.project.Name,Issue: &v1pb.Issue{Title: "Test Issue with Invalid SQL",Type: v1pb.Issue_DATABASE_CHANGE,- Description: "Testing risk calculation with invalid SQL",+ Description: "Testing approval rule matching with invalid SQL",Plan: planResp.Msg.Name,},}))a.NoError(err, "Issue creation should succeed even with invalid SQL in plan")// Check issue status 5 times with 3 second intervals- // issue.ApprovalFindingDone indicates that the approval flow is generated and issue.RiskLevel is available+ // Wait for approval finding to completevar issue *v1pb.Issuefor i := 0; i < 5; i++ {if i > 0 {@@ -246,8 +251,8 @@ func TestRiskLevelCalculationWithInvalidSQL(t *testing.T) {issue = issueGetResp.Msg// Log the current state for debugging- t.Logf("Check %d: ApprovalStatus=%v, RiskLevel=%v, ApprovalStatusError='%s'",- i+1, issue.ApprovalStatus, issue.RiskLevel, issue.ApprovalStatusError)+ t.Logf("Check %d: ApprovalStatus=%v, ApprovalStatusError='%s'",+ i+1, issue.ApprovalStatus, issue.ApprovalStatusError)// Check if approval finding is completeif issue.ApprovalStatus != v1pb.Issue_CHECKING {@@ -259,6 +264,4 @@ func TestRiskLevelCalculationWithInvalidSQL(t *testing.T) {a.NotNil(issue, "Issue should be retrievable even with invalid SQL")a.NotEqual(v1pb.Issue_CHECKING, issue.ApprovalStatus, "Approval finding should complete even with invalid SQL")a.NotEqual(v1pb.Issue_ERROR, issue.ApprovalStatus, "Approval finding should not have errors despite invalid SQL")-- a.Equal(v1pb.RiskLevel_HIGH, issue.RiskLevel, "Issue risk level should be HIGH")}diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/CustomApproval.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/CustomApproval.vueindex 62b64972eb..c0a8f4574e 100644--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/CustomApproval.vue+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/CustomApproval.vue@@ -1,31 +1,12 @@<template><div class="w-full">- <NTabs v-model:value="tab">- <NTabPane- name="rules"- :tab="$t('custom-approval.rule.rules')"- display-directive="show:lazy"- >- <RulesPanel />- </NTabPane>- <NTabPane- name="flows"- :tab="$t('custom-approval.approval-flow.approval-flows')"- display-directive="show:lazy"- >- <FlowsPanel />- </NTabPane>- </NTabs>+ <RulesPanel /></div></template><script lang="ts" setup>-import { NTabPane, NTabs } from "naive-ui";import { provideRiskFilter } from "../common/RiskFilter";-import { useCustomApprovalContext } from "./context";-import FlowsPanel from "./FlowsPanel";import RulesPanel from "./RulesPanel";-const { tab } = useCustomApprovalContext();provideRiskFilter();</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowTable.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowTable.vuedeleted file mode 100644index 1d238dfb57..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowTable.vue+++ /dev/null@@ -1,237 +0,0 @@-<template>- <div class="flex flex-col gap-y-6">- <!-- Built-in Flows Section -->- <div class="flex flex-col gap-y-2">- <div>- <h3 class="text-base font-medium">- {{ $t("custom-approval.approval-flow.built-in") }}- </h3>- <span class="textinfolabel">- {{ $t("custom-approval.approval-flow.built-in-description") }}- </span>- </div>- <NDataTable- size="small"- :columns="builtinColumns"- :data="builtinFlows"- :striped="true"- :bordered="true"- :row-key="(flow: BuiltinApprovalFlow) => flow.id"- />- </div>-- <!-- Custom Flows Section -->- <div class="flex flex-col gap-y-2">- <h3 class="text-base font-medium">- {{ $t("custom-approval.approval-flow.custom") }}- </h3>- <NDataTable- v-if="customRules.length > 0"- size="small"- :columns="customColumns"- :data="customRules"- :striped="true"- :bordered="true"- :row-key="(rule: LocalApprovalRule) => rule.template.id"- />- <div v-else class="text-sm text-control-light py-4 text-center">- {{ $t("custom-approval.approval-flow.no-custom-flows") }}- </div>- </div>- </div>-- <BBModal- v-if="state.viewFlow"- :title="$t('custom-approval.approval-flow.approval-nodes')"- @close="state.viewFlow = undefined"- >- <div class="w-[20rem]">- <StepsTable :flow="state.viewFlow" :editable="false" />- </div>- </BBModal>-</template>--<script lang="tsx" setup>-import { create as createProto } from "@bufbuild/protobuf";-import type { DataTableColumn } from "naive-ui";-import { NButton, NDataTable } from "naive-ui";-import { computed, reactive } from "vue";-import { useI18n } from "vue-i18n";-import { BBModal } from "@/bbkit";-import { SpinnerButton } from "@/components/v2/Form";-import { pushNotification, useWorkspaceApprovalSettingStore } from "@/store";-import {- BUILTIN_APPROVAL_FLOWS,- type BuiltinApprovalFlow,- isBuiltinFlowId,- type LocalApprovalRule,-} from "@/types";-import type { ApprovalFlow } from "@/types/proto-es/v1/issue_service_pb";-import { ApprovalFlowSchema } from "@/types/proto-es/v1/issue_service_pb";-import { StepsTable } from "../common";-import { useCustomApprovalContext } from "../context";--type LocalState = {- viewFlow: ApprovalFlow | undefined;-};--const state = reactive<LocalState>({- viewFlow: undefined,-});-const { t } = useI18n();-const store = useWorkspaceApprovalSettingStore();-const context = useCustomApprovalContext();-const { hasFeature, showFeatureModal, allowAdmin, dialog } = context;--const builtinFlows = computed(() => [...BUILTIN_APPROVAL_FLOWS]);--const customRules = computed(() => {- return store.config.rules.filter(- (rule) => !isBuiltinFlowId(rule.template.id)- );-});--// Helper: View flow details in modal-const viewFlow = (flow: ApprovalFlow) => {- state.viewFlow = flow;-};--// Helper: Convert BuiltinApprovalFlow to ApprovalFlow proto for viewing-const viewBuiltinFlow = (builtinFlow: BuiltinApprovalFlow) => {- state.viewFlow = createProto(ApprovalFlowSchema, {- roles: [...builtinFlow.roles],- });-};--// Helper: Render approval nodes button-const renderNodesButton = (rolesCount: number, onClick: () => void) => (- <NButton- quaternary- size="small"- type="info"- class="rounded-sm! w-(--n-height)! p-0!"- onClick={onClick}- >- {rolesCount}- </NButton>-);--// Shared column definitions-const createNameColumn = <T extends { title: string }>(- key: string = "name"-): DataTableColumn<T> => ({- title: t("common.name"),- key,- render: (item) => <div class="whitespace-nowrap">{item.title}</div>,-});--const createDescriptionColumn = <T extends { description: string }>(- key: string = "description"-): DataTableColumn<T> => ({- title: t("common.description"),- key,- render: (item) => item.description,-});--// Columns for built-in flows (read-only)-const builtinColumns = computed((): DataTableColumn<BuiltinApprovalFlow>[] => {- return [- createNameColumn<BuiltinApprovalFlow>(),- {- title: t("custom-approval.approval-flow.approval-nodes"),- key: "nodes",- width: 120,- align: "center",- render: (flow) =>- renderNodesButton(flow.roles.length, () => viewBuiltinFlow(flow)),- },- createDescriptionColumn<BuiltinApprovalFlow>(),- {- title: t("common.operations"),- key: "operations",- width: 200,- render: (flow) => (- <div class="flex gap-x-2">- <NButton size="small" onClick={() => viewBuiltinFlow(flow)}>- {t("common.view")}- </NButton>- </div>- ),- },- ];-});--// Columns for custom flows (editable)-const customColumns = computed((): DataTableColumn<LocalApprovalRule>[] => {- return [- {- title: t("common.name"),- key: "name",- render: (rule) => (- <div class="whitespace-nowrap">{rule.template?.title}</div>- ),- },- {- title: t("custom-approval.approval-flow.approval-nodes"),- key: "nodes",- width: 120,- align: "center",- render: (rule) =>- renderNodesButton(rule.template.flow?.roles.length ?? 0, () =>- viewFlow(rule.template.flow!)- ),- },- {- title: t("common.description"),- key: "description",- render: (rule) => rule.template?.description,- },- {- title: t("common.operations"),- key: "operations",- width: 200,- render: (rule) => (- <div class="flex gap-x-2">- <NButton size="small" onClick={() => editApprovalTemplate(rule)}>- {allowAdmin.value ? t("common.edit") : t("common.view")}- </NButton>- {allowAdmin.value && (- <SpinnerButton- size="small"- type="error"- tooltip={t("custom-approval.approval-flow.delete")}- onConfirm={() => deleteRule(rule)}- >- {t("common.delete")}- </SpinnerButton>- )}- </div>- ),- },- ];-});--const editApprovalTemplate = (rule: LocalApprovalRule) => {- if (!hasFeature.value) {- showFeatureModal.value = true;- return;- }- dialog.value = {- mode: "EDIT",- rule,- };-};--const deleteRule = async (rule: LocalApprovalRule) => {- try {- await store.deleteRule(rule);- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.deleted"),- });- } catch {- // nothing, exception has been handled already- }-};-</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowsPanel.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowsPanel.vuedeleted file mode 100644index 787b1a44ac..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowsPanel.vue+++ /dev/null@@ -1,11 +0,0 @@-<template>- <div class="flex flex-col items-end gap-y-4">- <FlowsToolbar />- <FlowTable />- </div>-</template>--<script lang="ts" setup>-import FlowTable from "./FlowTable.vue";-import FlowsToolbar from "./Toolbar.vue";-</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/Toolbar.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/Toolbar.vuedeleted file mode 100644index f1e93858f1..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/Toolbar.vue+++ /dev/null@@ -1,33 +0,0 @@-<template>- <div class="flex items-center gap-x-2">- <NButton type="primary" :disabled="!allowAdmin" @click="createRule">- <FeatureBadge- :feature="PlanFeature.FEATURE_APPROVAL_WORKFLOW"- class="mr-1 text-white"- />- {{ $t("common.create") }}- </NButton>- </div>-</template>--<script lang="ts" setup>-import { NButton } from "naive-ui";-import { FeatureBadge } from "@/components/FeatureGuard";-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";-import { useCustomApprovalContext } from "../context";-import { emptyLocalApprovalRule } from "../logic";--const context = useCustomApprovalContext();-const { hasFeature, showFeatureModal, allowAdmin, dialog } = context;--const createRule = () => {- if (!hasFeature.value) {- showFeatureModal.value = true;- return;- }- dialog.value = {- mode: "CREATE",- rule: emptyLocalApprovalRule(),- };-};-</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/index.ts b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/index.tsdeleted file mode 100644index d7fb17a430..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import FlowsPanel from "./FlowsPanel.vue";--export default FlowsPanel;diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleDialog.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleDialog.vuedeleted file mode 100644index 955912caaf..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleDialog.vue+++ /dev/null@@ -1,133 +0,0 @@-<template>- <BBModal- v-if="dialog"- :title="title"- :close-on-esc="false"- :before-close="beforeClose"- style="width: 50rem; max-width: calc(100vw - 5rem)"- @close="dialog = undefined"- >- <RuleForm- :dirty="state.dirty"- @cancel="cancel"- @update="state.dirty = true"- @save="handleSave"- />-- <div- v-if="state.loading"- class="absolute inset-0 flex flex-col items-center justify-center bg-white/50 rounded-lg"- >- <BBSpin />- </div>- </BBModal>-</template>--<script lang="ts" setup>-import { useDialog } from "naive-ui";-import { computed, reactive, watch } from "vue";-import { useI18n } from "vue-i18n";-import { BBModal, BBSpin } from "@/bbkit";-import { pushNotification, useWorkspaceApprovalSettingStore } from "@/store";-import type { LocalApprovalRule } from "@/types";-import { defer } from "@/utils";-import { useCustomApprovalContext } from "../context";-import RuleForm from "./RuleForm.vue";--type LocalState = {- loading: boolean;- dirty: boolean;-};--const { t } = useI18n();-const context = useCustomApprovalContext();-const { allowAdmin, dialog } = context;--const store = useWorkspaceApprovalSettingStore();-const state = reactive<LocalState>({- loading: false,- dirty: false,-});--const allowEditRule = computed(() => {- if (!allowAdmin.value) return false;- const rule = dialog.value?.rule;- if (!rule) return false;- return true;-});--const title = computed(() => {- if (dialog.value) {- if (!allowEditRule.value) {- return t("custom-approval.approval-flow.view-approval-flow");- }- const { mode } = dialog.value;- if (mode === "CREATE") {- return t("custom-approval.approval-flow.create-approval-flow");- }- if (mode === "EDIT") {- return t("custom-approval.approval-flow.edit-approval-flow");- }- }- return "";-});--const nDialog = useDialog();--const cancel = async () => {- const pass = await beforeClose();- if (pass) {- dialog.value = undefined;- }-};--const beforeClose = async () => {- if (!state.dirty) {- return true;- }- if (!allowAdmin.value) {- return true;- }- const d = defer<boolean>();- nDialog.warning({- title: t("common.close"),- content: t("common.will-lose-unsaved-data"),- maskClosable: false,- closeOnEsc: false,- positiveText: t("common.confirm"),- negativeText: t("common.cancel"),- onPositiveClick: () => d.resolve(true),- onNegativeClick: () => d.resolve(false),- });- return d.promise;-};--const handleSave = async (- newRule: LocalApprovalRule,- oldRule: LocalApprovalRule | undefined-) => {- state.loading = true;- try {- await store.upsertRule(newRule, oldRule);- state.dirty = false;- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.updated"),- });- dialog.value = undefined;- } catch {- // nothing, exception has been handled already- } finally {- state.loading = false;- }-};--watch(- dialog,- () => {- state.dirty = false;- },- { immediate: true }-);-</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleForm.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleForm.vuedeleted file mode 100644index dfe9e9cbc4..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleForm.vue+++ /dev/null@@ -1,145 +0,0 @@-<template>- <div class="max-h-[calc(100vh-10rem)] flex flex-col gap-y-4 text-sm">- <div class="flex-1 flex flex-col px-0.5 overflow-hidden gap-y-4">- <div class="flex flex-col gap-y-1">- <label class="font-medium text-control flex gap-x-1">- <RequiredStar />- {{ $t("common.name") }}- </label>- <NInput- ref="nameInputRef"- v-model:value="state.rule.template.title"- :show-count="true"- :maxlength="64"- :disabled="!allowEditRule"- @update:value="$emit('update')"- />- </div>- <div class="flex flex-col gap-y-1">- <label class="font-medium text-control flex gap-x-1">- <RequiredStar />- {{ $t("common.description") }}- </label>- <NInput- v-model:value="state.rule.template.description"- type="textarea"- :autosize="{- minRows: 3,- maxRows: 5,- }"- :disabled="!allowEditRule"- @update:value="$emit('update')"- />- </div>- <div class="w-full flex-1 flex flex-col gap-y-1 overflow-y-auto">- <label class="font-medium text-control flex gap-x-1">- <RequiredStar />- {{ $t("custom-approval.approval-flow.node.nodes") }}- </label>- <div class="text-control-light">- {{ $t("custom-approval.approval-flow.node.description") }}- </div>- <div class="py-1 flex flex-col gap-y-2">- <StepsTable- v-if="state.rule.template.flow"- :flow="state.rule.template.flow"- :editable="allowEditRule"- @update="$emit('update')"- />- </div>- </div>- </div>-- <footer- v-if="allowEditRule"- class="flex items-center justify-end gap-x-2 pt-4 border-t"- >- <NButton @click="$emit('cancel')">{{ $t("common.cancel") }}</NButton>- <NButton- type="primary"- :disabled="!allowCreateOrUpdate"- @click="handleUpsert"- >- {{ mode === "CREATE" ? $t("common.create") : $t("common.update") }}- </NButton>- </footer>- </div>-</template>--<script lang="ts" setup>-import { cloneDeep } from "lodash-es";-import { NButton, NInput } from "naive-ui";-import { computed, nextTick, onMounted, ref } from "vue";-import RequiredStar from "@/components/RequiredStar.vue";-import type { LocalApprovalRule } from "@/types";-import { StepsTable } from "../common";-import { useCustomApprovalContext } from "../context";-import { validateApprovalTemplate } from "../logic";--type LocalState = {- rule: LocalApprovalRule;-};--const props = defineProps<{- dirty?: boolean;-}>();--const emit = defineEmits<{- (event: "cancel"): void;- (event: "update"): void;- (- event: "save",- newRule: LocalApprovalRule,- oldRule: LocalApprovalRule | undefined- ): void;-}>();--const nameInputRef = ref<InstanceType<typeof NInput>>();-const context = useCustomApprovalContext();-const { allowAdmin, dialog } = context;--const mode = computed(() => dialog.value!.mode);-const rule = computed(() => dialog.value!.rule);--const resolveLocalState = (): LocalState => {- return {- rule: cloneDeep(rule.value),- };-};--const state = ref(resolveLocalState());--const allowEditRule = computed(() => {- if (!allowAdmin.value) return false;- return true;-});--const allowCreateOrUpdate = computed(() => {- if (!validateApprovalTemplate(state.value.rule.template)) {- return false;- }- if (mode.value === "EDIT") {- if (!props.dirty) return false;- }- return true;-});--const handleUpsert = () => {- if (!context.hasFeature.value) {- context.showFeatureModal.value = true;- return;- }-- const oldRule = mode.value === "EDIT" ? rule.value : undefined;- const newRule = cloneDeep(state.value.rule);- emit("save", newRule, oldRule);-};--onMounted(() => {- if (allowEditRule.value) {- nextTick(() => {- nameInputRef.value?.inputElRef?.focus();- });- }-});-</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/index.ts b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/index.tsdeleted file mode 100644index 187831bdd8..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import RuleDialog from "./RuleDialog.vue";--export default RuleDialog;diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vuedeleted file mode 100644index cf23e7d6d8..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue+++ /dev/null@@ -1,42 +0,0 @@-<template>- <i18n-t- v-if="showTips"- tag="span"- keypath="custom-approval.approval-flow.risk-not-configured-tips"- >- <template #link>- <router-link :to="{ name: WORKSPACE_ROUTE_RISKS }" class="normal-link">- {{ $t("custom-approval.approval-flow.the-related-risk-rules") }}- </router-link>- </template>- </i18n-t>-</template>--<script lang="ts" setup>-import { computed } from "vue";-import { WORKSPACE_ROUTE_RISKS } from "@/router/dashboard/workspaceRoutes";-import { useRiskStore } from "@/store";-import { DEFAULT_RISK_LEVEL } from "@/types";-import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";--const props = defineProps<{- level: number;- source: Risk_Source;- rule: string | undefined;-}>();--const riskStore = useRiskStore();--const showTips = computed(() => {- const { level, source, rule } = props;- if (!rule) return false;- if (level === DEFAULT_RISK_LEVEL) return false;- const riskList = riskStore.riskList.filter(- (risk) => risk.active && risk.level === level && risk.source == source- );- // Show a tips to configure risk rules when- // - the approval flow is configured (not "Skip approval")- // - AND the number of corresponding risk rules is 0- return riskList.length === 0;-});-</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RuleEditModal.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RuleEditModal.vuenew file mode 100644index 0000000000..fcf6a6ad4e--- /dev/null+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RuleEditModal.vue@@ -0,0 +1,198 @@+<template>+ <NModal+ :show="show"+ :mask-closable="false"+ @update:show="$emit('update:show', $event)"+ >+ <div+ class="w-[calc(100vw-8rem)] lg:max-w-[75vw] 2xl:max-w-[55vw] max-h-[calc(100vh-10rem)] bg-white rounded-lg shadow-lg flex flex-col overflow-hidden"+ >+ <div class="px-6 py-4 border-b flex items-center justify-between">+ <h2 class="text-lg font-medium text-control">+ {{+ mode === "create"+ ? $t("custom-approval.approval-flow.create-approval-flow")+ : $t("custom-approval.approval-flow.edit-rule")+ }}+ </h2>+ </div>++ <div class="flex-1 flex flex-col px-6 py-4 overflow-hidden gap-y-4">+ <div class="flex-1 flex flex-col gap-y-2 overflow-y-auto">+ <h3 class="font-medium text-sm text-control">+ {{ $t("cel.condition.self") }}+ </h3>+ <div class="text-sm text-control-light">+ {{ $t("cel.condition.description-tips") }}+ </div>+ <ExprEditor+ :expr="state.conditionExpr"+ :allow-admin="allowAdmin"+ :enable-raw-expression="true"+ :factor-list="factorList"+ :option-config-map="optionConfigMap"+ @update="handleUpdate"+ />+ </div>++ <div class="flex flex-col gap-y-2">+ <h3 class="font-medium text-sm text-control">+ {{ $t("custom-approval.approval-flow.node.nodes") }}+ </h3>+ <div class="text-sm text-control-light">+ {{ $t("custom-approval.approval-flow.node.description") }}+ </div>+ <StepsTable+ :flow="state.flow"+ :editable="true"+ @update="handleUpdate"+ />+ </div>+ </div>++ <footer+ class="flex items-center justify-end gap-x-2 px-6 py-4 border-t"+ >+ <NButton @click="$emit('update:show', false)">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ type="primary"+ :disabled="!allowSave"+ @click="handleSave"+ >+ {{ mode === "create" ? $t("common.create") : $t("common.update") }}+ </NButton>+ </footer>+ </div>+ </NModal>+</template>++<script lang="ts" setup>+import { create as createProto } from "@bufbuild/protobuf";+import { cloneDeep, head } from "lodash-es";+import { NButton, NModal } from "naive-ui";+import { computed, reactive, watch } from "vue";+import ExprEditor from "@/components/ExprEditor";+import type { ConditionGroupExpr } from "@/plugins/cel";+import {+ buildCELExpr,+ emptySimpleExpr,+ resolveCELExpr,+ validateSimpleExpr,+ wrapAsGroup,+} from "@/plugins/cel";+import type { LocalApprovalRule } from "@/types";+import type { ApprovalFlow } from "@/types/proto-es/v1/issue_service_pb";+import { ApprovalFlowSchema } from "@/types/proto-es/v1/issue_service_pb";+import type { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";+import {+ batchConvertCELStringToParsedExpr,+ batchConvertParsedExprToCELString,+} from "@/utils";+import {+ getApprovalFactorList,+ getApprovalOptionConfigMap,+} from "../../common/utils";+import { StepsTable } from "../common";+import { useCustomApprovalContext } from "../context";++type LocalState = {+ conditionExpr: ConditionGroupExpr;+ flow: ApprovalFlow;+};++const props = defineProps<{+ show: boolean;+ mode: "create" | "edit";+ source: WorkspaceApprovalSetting_Rule_Source;+ rule?: LocalApprovalRule;+}>();++const emit = defineEmits<{+ (event: "update:show", show: boolean): void;+ (event: "save", rule: Partial<LocalApprovalRule>): void;+}>();++const context = useCustomApprovalContext();+const { allowAdmin } = context;++const state = reactive<LocalState>({+ conditionExpr: wrapAsGroup(emptySimpleExpr()),+ flow: createProto(ApprovalFlowSchema, { roles: [] }),+});++const factorList = computed(() => getApprovalFactorList(props.source));+const optionConfigMap = computed(() =>+ getApprovalOptionConfigMap(props.source)+);++const allowSave = computed(() => {+ if (!state.conditionExpr) return false;+ if (!validateSimpleExpr(state.conditionExpr)) return false;+ if (state.flow.roles.length === 0) return false;+ return true;+});++const resolveLocalState = async () => {+ if (props.rule) {+ let expr: ConditionGroupExpr = wrapAsGroup(emptySimpleExpr());+ if (props.rule.condition) {+ const parsedExprs = await batchConvertCELStringToParsedExpr([+ props.rule.condition,+ ]);+ const celExpr = head(parsedExprs);+ if (celExpr) {+ expr = wrapAsGroup(resolveCELExpr(celExpr));+ }+ }+ state.conditionExpr = expr;+ state.flow = cloneDeep(props.rule.flow);+ } else {+ state.conditionExpr = wrapAsGroup(emptySimpleExpr());+ state.flow = createProto(ApprovalFlowSchema, { roles: [] });+ }+};++const handleUpdate = () => {+ // Trigger reactivity+};++const handleSave = async () => {+ if (!context.hasFeature.value) {+ context.showFeatureModal.value = true;+ return;+ }++ const celexpr = await buildCELExpr(state.conditionExpr);+ if (!celexpr) {+ return;+ }++ const expressions = await batchConvertParsedExprToCELString([celexpr]);+ const condition = expressions[0];++ const ruleData: Partial<LocalApprovalRule> = {+ condition,+ conditionExpr: cloneDeep(state.conditionExpr),+ flow: cloneDeep(state.flow),+ source: props.source,+ };++ if (props.rule) {+ ruleData.uid = props.rule.uid;+ }++ emit("save", ruleData);+};++watch(+ () => props.show,+ (newShow) => {+ if (newShow) {+ resolveLocalState();+ }+ },+ { immediate: true }+);+</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RuleSelect.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RuleSelect.vuedeleted file mode 100644index b5eb25bf63..0000000000--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RuleSelect.vue+++ /dev/null@@ -1,141 +0,0 @@-<template>- <div- class="flex items-center"- :class="attrs.class as VueClass"- :style="attrs.style as VueStyle"- >- <label v-if="label" class="mr-2">{{ label }}</label>- <SpinnerSelect- :value="value"- :on-update="onUpdate"- :options="options"- :placeholder="$t('custom-approval.approval-flow.select')"- :consistent-menu-width="false"- :disabled="disabled || !allowAdmin"- :filterable="true"- class="bb-rule-select"- v-bind="selectAttrs"- />- <NButton- v-if="link"- quaternary- type="info"- class="rounded-sm! w-(--n-height)! p-0! ml-1!"- :disabled="!selectedRule || !allowAdmin"- @click="toApprovalFlow"- >- <heroicons:pencil-square class="w-5 h-5" />- </NButton>- </div>-</template>--<script lang="ts" setup>-import { omit } from "lodash-es";-import type { SelectOption } from "naive-ui";-import { NButton, type SelectProps } from "naive-ui";-import { computed, useAttrs } from "vue";-import { useI18n } from "vue-i18n";-import { SpinnerSelect } from "@/components/v2/Form";-import { useWorkspaceApprovalSettingStore } from "@/store";-import { BUILTIN_APPROVAL_FLOWS, isBuiltinFlowId } from "@/types";-import type { VueClass, VueStyle } from "@/utils";-import { useCustomApprovalContext } from "../context";--export interface ApprovalTemplateSelectorProps- extends /* @vue-ignore */ SelectProps {- label?: string;- link?: boolean;- disabled?: boolean;- value?: string;- onUpdate: (value: string | undefined) => Promise<any>;- selectClass?: VueClass;- selectStyle?: VueStyle;-}-const props = defineProps<ApprovalTemplateSelectorProps>();--defineEmits<{- (event: "update:value", value: string | undefined): void;-}>();--const { t } = useI18n();-const store = useWorkspaceApprovalSettingStore();-const context = useCustomApprovalContext();-const { allowAdmin, hasFeature, showFeatureModal } = context;--const attrs = useAttrs();-const selectAttrs = computed(() => ({- ...omit(attrs, "class", "style"),- class: props.selectClass,- style: props.selectStyle,-}));--const options = computed(() => {- // Custom flow options (filter out built-in flows that are in the database)- const customRuleOptions = store.config.rules- .filter((rule) => !isBuiltinFlowId(rule.template.id))- .map<SelectOption>((rule) => ({- label: rule.template.title,- value: rule.template.id,- }));-- // Built-in flow options - only show most commonly used ones- const commonBuiltinFlows = [- "bb.project-owner",- "bb.workspace-dba",- "bb.project-owner-workspace-dba",- "bb.project-owner-workspace-dba-workspace-admin",- ];-- const builtinOptions = BUILTIN_APPROVAL_FLOWS.filter((flow) =>- commonBuiltinFlows.includes(flow.id)- ).map<SelectOption>((flow) => ({- label: flow.title,- value: flow.id,- }));-- const options: SelectOption[] = [- { value: "", label: t("custom-approval.approval-flow.skip") },- ];-- // Add custom flows group FIRST (most likely to be selected)- if (customRuleOptions.length > 0) {- options.push({- type: "group",- label: t("custom-approval.approval-flow.custom"),- key: "custom-group",- children: customRuleOptions,- } as SelectOption);- }-- // Add built-in flows group SECOND (less commonly used)- if (builtinOptions.length > 0) {- options.push({- type: "group",- label: t("custom-approval.approval-flow.built-in"),- key: "builtin-group",- children: builtinOptions,- } as SelectOption);- }-- return options;-});--const selectedRule = computed(() => {- return store.config.rules.find((rule) => rule.template.id === props.value);-});--const toApprovalFlow = () => {- const rule = selectedRule.value;- if (!rule) {- return;- }- if (!hasFeature.value) {- showFeatureModal.value = true;- return;- }- context.dialog.value = {- mode: "EDIT",- rule,- };-};-</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vueindex 713bf4205e..0a2148af60 100644--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vue+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vue@@ -9,8 +9,15 @@</template><script lang="ts" setup>-import { useSupportedSourceList } from "@/types";+import { computed } from "vue";+import { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";import RulesSection from "./RulesSection.vue";-const supportedSourceList = useSupportedSourceList();+const supportedSourceList = computed(() => [+ WorkspaceApprovalSetting_Rule_Source.DDL,+ WorkspaceApprovalSetting_Rule_Source.DML,+ WorkspaceApprovalSetting_Rule_Source.CREATE_DATABASE,+ WorkspaceApprovalSetting_Rule_Source.EXPORT_DATA,+ WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE,+]);</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vueindex 6805685a54..2417fb19dc 100644--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue@@ -1,118 +1,176 @@<template><div class="flex flex-col gap-y-2">- <div class="flex items-center justify-start">+ <div class="flex items-center justify-between"><div class="font-medium text-base">- {{ sourceText(source) }}+ {{ sourceDisplayText }}</div>+ <NTooltip>+ <template #trigger>+ <HelpCircleIcon class="w-4 h-4 text-control-light cursor-help" />+ </template>+ {{ $t("custom-approval.rule.first-match-wins") }}+ </NTooltip></div>- <div>- <NDataTable- size="small"- :columns="columns"- :data="rows"- :striped="true"- :bordered="true"- :row-key="(row: Row) => String(row.level)"- />++ <NDataTable+ size="small"+ :columns="columns"+ :data="rules"+ :striped="true"+ :bordered="true"+ :row-key="(row: LocalApprovalRule) => row.uid"+ />++ <div class="mt-2">+ <NButton size="small" @click="handleAddRule">+ <template #icon>+ <PlusIcon class="w-4" />+ </template>+ {{ $t("custom-approval.approval-flow.add-rule") }}+ </NButton></div>++ <RuleEditModal+ v-model:show="showModal"+ :mode="modalMode"+ :source="source"+ :rule="editingRule"+ @save="handleSaveRule"+ /></div></template><script lang="tsx" setup>+import {+ HelpCircleIcon,+ PencilIcon,+ PlusIcon,+ TrashIcon,+} from "lucide-vue-next";import type { DataTableColumn } from "naive-ui";-import { NDataTable } from "naive-ui";-import { computed } from "vue";+import { NButton, NDataTable, NPopconfirm, NTooltip } from "naive-ui";+import { computed, ref } from "vue";import { useI18n } from "vue-i18n";import { pushNotification, useWorkspaceApprovalSettingStore } from "@/store";-import type { ParsedApprovalRule } from "@/types";-import { DEFAULT_RISK_LEVEL, PresetRiskLevelList } from "@/types";-import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";-import { levelText, sourceText, useRiskFilter } from "../../common";+import type { LocalApprovalRule } from "@/types";+import type { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";+import { formatApprovalFlow } from "@/utils";+import { approvalSourceText } from "../../common/utils";import { useCustomApprovalContext } from "../context";-import RiskTips from "./RiskTips.vue";-import RuleSelect from "./RuleSelect.vue";--type Row = {- level: number;- rule: string | undefined; // ApprovalTemplate.id-};+import RuleEditModal from "./RuleEditModal.vue";const props = defineProps<{- source: Risk_Source;+ source: WorkspaceApprovalSetting_Rule_Source;}>();const { t } = useI18n();const store = useWorkspaceApprovalSettingStore();const context = useCustomApprovalContext();-const columns = computed((): DataTableColumn<Row>[] => {- return [- {- title: t("custom-approval.risk.self"),- key: "level",- width: 160,- render: (row) => levelText(row.level),- },- {- title: t("custom-approval.approval-flow.self"),- key: "rule",- render: (row) => (- <div class="flex items-center gap-x-2">- <RuleSelect- class="flex-1 max-w-md min-w-40"- value={row.rule}- onUpdate={(rule: string | undefined) => updateRow(row, rule)}- />- <RiskTips level={row.level} source={props.source} rule={row.rule} />- </div>- ),- },- ];-});+const showModal = ref(false);+const modalMode = ref<"create" | "edit">("create");+const editingRule = ref<LocalApprovalRule | undefined>();-const filter = useRiskFilter();+const rules = computed(() => store.getRulesBySource(props.source));-const rulesMap = computed(() => {- const map = new Map<number, ParsedApprovalRule>();- store.config.parsed- .filter((item) => item.source === props.source)- .forEach((item) => {- map.set(item.level, item);- });- return map;-});+const sourceDisplayText = computed(() => approvalSourceText(props.source));-const rows = computed(() => {- const filteredLevelList = [...filter.levels.value.values()];- filteredLevelList.sort((a, b) => -(a - b)); // by level DESC- const displayLevelList =- filteredLevelList.length === 0- ? [...PresetRiskLevelList.map((item) => item.level), DEFAULT_RISK_LEVEL]- : filteredLevelList;+const columns = computed((): DataTableColumn<LocalApprovalRule>[] => [+ {+ title: t("cel.condition.self"),+ key: "condition",+ ellipsis: { tooltip: true },+ render: (row) => (+ <code class="text-xs bg-control-bg px-1 py-0.5 rounded">+ {row.condition || "true"}+ </code>+ ),+ },+ {+ title: t("custom-approval.approval-flow.self"),+ key: "flow",+ width: 280,+ render: (row) => formatApprovalFlow(row.flow),+ },+ {+ title: t("common.operations"),+ key: "operations",+ width: 100,+ render: (row) => (+ <div class="flex gap-x-1">+ <NButton size="tiny" onClick={() => handleEditRule(row)}>+ <PencilIcon class="w-3" />+ </NButton>+ <NPopconfirm+ onPositiveClick={() => handleDeleteRule(row)}+ positiveText={t("common.confirm")}+ negativeText={t("common.cancel")}+ >+ {{+ trigger: () => (+ <NButton size="tiny">+ <TrashIcon class="w-3" />+ </NButton>+ ),+ default: () => t("common.confirm") + "?",+ }}+ </NPopconfirm>+ </div>+ ),+ },+]);++const handleAddRule = () => {+ if (!context.hasFeature.value) {+ context.showFeatureModal.value = true;+ return;+ }+ modalMode.value = "create";+ editingRule.value = undefined;+ showModal.value = true;+};- return displayLevelList.map<Row>((level) => ({- level,- rule: rulesMap.value.get(level)?.rule ?? "",- }));-});+const handleEditRule = (rule: LocalApprovalRule) => {+ if (!context.hasFeature.value) {+ context.showFeatureModal.value = true;+ return;+ }+ modalMode.value = "edit";+ editingRule.value = rule;+ showModal.value = true;+};-const updateRow = async (row: Row, rule: string | undefined) => {+const handleDeleteRule = async (rule: LocalApprovalRule) => {if (!context.hasFeature.value) {context.showFeatureModal.value = true;return;}+ try {+ await store.deleteRule(rule.uid);+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.deleted"),+ });+ } catch {+ // Error handled by store+ }+};- const { source } = props;- const { level } = row;+const handleSaveRule = async (ruleData: Partial<LocalApprovalRule>) => {try {- await store.updateRuleFlow(source, level, rule);+ if (modalMode.value === "create") {+ await store.addRule(ruleData as Omit<LocalApprovalRule, "uid">);+ } else if (editingRule.value && ruleData.uid) {+ await store.updateRule(ruleData.uid, ruleData);+ }pushNotification({module: "bytebase",style: "SUCCESS",title: t("common.updated"),});} catch {- // nothing, exception has been handled already+ // Error handled by store}};</script>diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/context.ts b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/context.tsindex 1ad2916019..5d4a534e86 100644--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/context.ts+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/context.ts@@ -1,22 +1,10 @@import { type InjectionKey, inject, provide, type Ref } from "vue";-import type { LocalApprovalRule } from "@/types";--export const TabValueList = ["rules", "flows", "external-approval"] as const;-export type TabValue = (typeof TabValueList)[number];--export type DialogContext = {- mode: "EDIT" | "CREATE";- rule: LocalApprovalRule;-};export type CustomApprovalContext = {hasFeature: Ref<boolean>;showFeatureModal: Ref<boolean>;allowAdmin: Ref<boolean>;ready: Ref<boolean>;- tab: Ref<TabValue>;-- dialog: Ref<DialogContext | undefined>;};export const KEY = Symbol(diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/index.ts b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/index.tsindex 49f3b47509..ced1598bb0 100644--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/index.ts+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/index.ts@@ -1,6 +1,5 @@import CustomApproval from "./CustomApproval.vue";-import ApprovalRuleDialog from "./RuleDialog";export default CustomApproval;export * from "./context";-export { CustomApproval, ApprovalRuleDialog };+export { CustomApproval };diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.ts b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.tsindex 98be58afe3..e96807d8ca 100644--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.ts+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.ts@@ -1,15 +1,14 @@import { create as createProto } from "@bufbuild/protobuf";import { v4 as uuidv4 } from "uuid";import type { LocalApprovalRule } from "@/types";-import { ApprovalTemplateSchema } from "@/types/proto-es/v1/issue_service_pb";+import { ApprovalFlowSchema } from "@/types/proto-es/v1/issue_service_pb";+import { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";export const emptyLocalApprovalRule = (): LocalApprovalRule => {return {- template: createProto(ApprovalTemplateSchema, {- id: uuidv4(),- flow: {- roles: [],- },- }),+ uid: uuidv4(),+ source: WorkspaceApprovalSetting_Rule_Source.SOURCE_UNSPECIFIED,+ condition: "",+ flow: createProto(ApprovalFlowSchema, { roles: [] }),};};diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.tsindex 9d21f3e63b..86ba1f4388 100644--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts@@ -23,6 +23,7 @@ import {import { Engine, RiskLevel } from "@/types/proto-es/v1/common_pb";import type { Project } from "@/types/proto-es/v1/project_service_pb";import { type Risk, Risk_Source } from "@/types/proto-es/v1/risk_service_pb";+import { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";import {displayRoleTitle,engineNameV1,@@ -339,3 +340,84 @@ export const getOptionConfigMap = (source: Risk_Source) => {return map;}, new Map<Factor, OptionConfig>());};++// Overload for new approval rule source enum+export const approvalSourceText = (+ source: WorkspaceApprovalSetting_Rule_Source+) => {+ switch (source) {+ case WorkspaceApprovalSetting_Rule_Source.SOURCE_UNSPECIFIED:+ return t("common.all");+ case WorkspaceApprovalSetting_Rule_Source.DDL:+ return t("custom-approval.risk-rule.risk.namespace.ddl");+ case WorkspaceApprovalSetting_Rule_Source.DML:+ return t("custom-approval.risk-rule.risk.namespace.dml");+ case WorkspaceApprovalSetting_Rule_Source.CREATE_DATABASE:+ return t("custom-approval.risk-rule.risk.namespace.create_database");+ case WorkspaceApprovalSetting_Rule_Source.EXPORT_DATA:+ return t("custom-approval.risk-rule.risk.namespace.data_export");+ case WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE:+ return t("custom-approval.risk-rule.risk.namespace.request-role");+ default:+ return "UNRECOGNIZED";+ }+};++// Map between WorkspaceApprovalSetting_Rule_Source and Factor lists+export const ApprovalSourceFactorMap: Map<+ WorkspaceApprovalSetting_Rule_Source,+ Factor[]+> = new Map([+ [+ WorkspaceApprovalSetting_Rule_Source.DDL,+ RiskSourceFactorMap.get(Risk_Source.DDL) || [],+ ],+ [+ WorkspaceApprovalSetting_Rule_Source.DML,+ RiskSourceFactorMap.get(Risk_Source.DML) || [],+ ],+ [+ WorkspaceApprovalSetting_Rule_Source.CREATE_DATABASE,+ RiskSourceFactorMap.get(Risk_Source.CREATE_DATABASE) || [],+ ],+ [+ WorkspaceApprovalSetting_Rule_Source.EXPORT_DATA,+ RiskSourceFactorMap.get(Risk_Source.DATA_EXPORT) || [],+ ],+ [+ WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE,+ RiskSourceFactorMap.get(Risk_Source.REQUEST_ROLE) || [],+ ],+]);++export const getApprovalFactorList = (+ source: WorkspaceApprovalSetting_Rule_Source+) => {+ return ApprovalSourceFactorMap.get(source) ?? [];+};++export const getApprovalOptionConfigMap = (+ source: WorkspaceApprovalSetting_Rule_Source+) => {+ const riskSource = approvalSourceToRiskSource(source);+ return getOptionConfigMap(riskSource);+};++const approvalSourceToRiskSource = (+ source: WorkspaceApprovalSetting_Rule_Source+): Risk_Source => {+ switch (source) {+ case WorkspaceApprovalSetting_Rule_Source.DDL:+ return Risk_Source.DDL;+ case WorkspaceApprovalSetting_Rule_Source.DML:+ return Risk_Source.DML;+ case WorkspaceApprovalSetting_Rule_Source.CREATE_DATABASE:+ return Risk_Source.CREATE_DATABASE;+ case WorkspaceApprovalSetting_Rule_Source.EXPORT_DATA:+ return Risk_Source.DATA_EXPORT;+ case WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE:+ return Risk_Source.REQUEST_ROLE;+ default:+ return Risk_Source.SOURCE_UNSPECIFIED;+ }+};diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex c94e493cb9..62b7cac4d0 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2669,16 +2669,7 @@},"approval-flow": {"self": "Approval Flow",- "approval-flows": "Approval Flows",- "approval-nodes": "Approval nodes",- "delete": "Delete approval flow",- "select": "Select approval flow","create-approval-flow": "Create approval flow",- "edit-approval-flow": "Edit approval flow",- "built-in": "Built-in Flows",- "built-in-description": "Built-in flows are read-only and cannot be deleted.",- "custom": "Custom Flows",- "no-custom-flows": "No custom approval flows created yet. Click 'Create Flow' to add one.","node": {"nodes": "Approval nodes","description": "Only one approval is required on this node when there are multiple approvers.",@@ -2687,22 +2678,20 @@"add": "Add node","delete": "Delete approval node"},- "view-approval-flow": "View approval flow","skip": "Skip manual approval",- "risk-not-configured-tips": "Make sure you have defined {link}.",- "the-related-risk-rules": "the related risk rules","issue-review": {"sent-back": "Sent back","review-sent-back-by": "Review sent back by {user}"- }+ },+ "add-rule": "Add rule",+ "edit-rule": "Edit rule"},"risk": {- "self": "Risk","risks": "Risks","description": "Risk Center defines the risk levels for different database operations under different conditions. And risk levels determine the corresponding custom approval flows."},"rule": {- "rules": "Rules"+ "first-match-wins": "Rules are evaluated in order. First matching rule applies."},"issue-review": {"approve-issue": "Approve issue?",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 6a3fb21781..2db616c68c 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2669,16 +2669,7 @@},"approval-flow": {"self": "Flujo de aprobación",- "approval-flows": "Flujos de Aprobación",- "approval-nodes": "Nodos de aprobación",- "delete": "Eliminar flujo de aprobación",- "select": "Seleccionar flujo de aprobación","create-approval-flow": "Crear flujo de aprobación",- "edit-approval-flow": "Editar flujo de aprobación",- "built-in": "Flujos Integrados",- "built-in-description": "Los flujos integrados son de solo lectura y no se pueden eliminar.",- "custom": "Flujos Personalizados",- "no-custom-flows": "Aún no se han creado flujos de aprobación personalizados. Haga clic en 'Crear Flujo' para agregar uno.","node": {"nodes": "Nodos de aprobación","description": "Solo se requiere una aprobación en este nodo cuando hay múltiples aprobadores.",@@ -2687,22 +2678,20 @@"add": "Agregar nodo","delete": "Eliminar nodo de aprobación"},- "view-approval-flow": "Ver flujo de aprobación","skip": "Omitir aprobación manual",- "risk-not-configured-tips": "Asegúrese de haber definido {link}.",- "the-related-risk-rules": "las reglas de riesgo relacionadas","issue-review": {"sent-back": "Devuelto","review-sent-back-by": "Reseña enviada por {user}"- }+ },+ "add-rule": "Agregar regla",+ "edit-rule": "Editar regla"},"risk": {- "self": "Riesgo","risks": "Riesgo","description": "El Centro de riesgo define los niveles de riesgo para diferentes operaciones de base de datos en diferentes condiciones. Y los niveles de riesgo determinan los flujos de aprobación personalizados correspondientes."},"rule": {- "rules": "Reglas"+ "first-match-wins": "Las reglas se evalúan en orden. Se aplica la primera regla coincidente."},"issue-review": {"approve-issue": "¿Aprobar incidencia?",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex d1931cb7f6..330d17130e 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2669,16 +2669,7 @@},"approval-flow": {"self": "承認の流れ",- "approval-flows": "承認の流れ",- "approval-nodes": "承認ノード",- "delete": "承認フローの削除",- "select": "承認フローの選択","create-approval-flow": "承認フローの作成",- "edit-approval-flow": "承認フローの編集",- "built-in": "組み込み承認フロー",- "built-in-description": "組み込みフローは読み取り専用であり、削除できません。",- "custom": "カスタム承認フロー",- "no-custom-flows": "カスタム承認フローがまだ作成されていません。「承認フローを作成」をクリックして追加してください。","node": {"nodes": "承認ノード","description": "ノードに複数の承認者がいる場合、必要な承認は 1 つだけです。",@@ -2687,22 +2678,20 @@"add": "ノードの追加","delete": "承認ノードの削除"},- "view-approval-flow": "承認フローを見る","skip": "手動承認をスキップする",- "risk-not-configured-tips": "{link} が定義されていることを確認してください。",- "the-related-risk-rules": "関連するリスクルール","issue-review": {"sent-back": "戻ってきた","review-sent-back-by": "{user} から承認が返されました"- }+ },+ "add-rule": "ルールを追加",+ "edit-rule": "ルールを編集"},"risk": {- "self": "リスク","risks": "リスク","description": "リスク センターは、さまざまな条件下でのさまざまなデータベース操作のリスク レベルを定義します。リスク レベルによって、イシューのカスタム承認プロセスが決まります。"},"rule": {- "rules": "ルール"+ "first-match-wins": "ルールは順番に評価されます。最初に一致するルールが適用されます。"},"issue-review": {"approve-issue": "イシューを承認しますか?",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex f0169b7d6c..7c5d901820 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -2669,16 +2669,7 @@},"approval-flow": {"self": "Quy trình phê duyệt",- "approval-flows": "Quy trình phê duyệt",- "approval-nodes": "Nút phê duyệt",- "delete": "Xóa quy trình phê duyệt",- "select": "Chọn quy trình phê duyệt","create-approval-flow": "Tạo quy trình phê duyệt",- "edit-approval-flow": "Chỉnh sửa quy trình phê duyệt",- "built-in": "Quy trình Tích hợp sẵn",- "built-in-description": "Các luồng tích hợp chỉ có thể đọc và không thể xóa.",- "custom": "Quy trình Tùy chỉnh",- "no-custom-flows": "Chưa có quy trình phê duyệt tùy chỉnh nào được tạo. Nhấp vào 'Tạo Quy trình' để thêm.","node": {"nodes": "Nút phê duyệt","description": "Chỉ cần một phê duyệt trên nút này khi có nhiều người phê duyệt.",@@ -2687,22 +2678,20 @@"add": "Thêm nút","delete": "Xóa nút phê duyệt"},- "view-approval-flow": "Xem quy trình phê duyệt","skip": "Bỏ qua phê duyệt thủ công",- "risk-not-configured-tips": "Đảm bảo bạn đã xác định {link}.",- "the-related-risk-rules": "các quy tắc rủi ro liên quan","issue-review": {"sent-back": "Đã gửi lại","review-sent-back-by": "Đánh giá đã gửi lại bởi {user}"- }+ },+ "add-rule": "Thêm quy tắc",+ "edit-rule": "Chỉnh sửa quy tắc"},"risk": {- "self": "Rủi ro","risks": "Rủi ro","description": "Trung tâm rủi ro xác định mức độ rủi ro cho các hoạt động cơ sở dữ liệu khác nhau trong các điều kiện khác nhau. Và mức độ rủi ro xác định quy trình phê duyệt tùy chỉnh tương ứng."},"rule": {- "rules": "Quy tắc"+ "first-match-wins": "Các quy tắc được đánh giá theo thứ tự. Quy tắc phù hợp đầu tiên sẽ được áp dụng."},"issue-review": {"approve-issue": "Phê duyệt vấn đề?",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 20f744d23e..b7500d7235 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2669,16 +2669,7 @@},"approval-flow": {"self": "审批流",- "approval-flows": "审批流",- "approval-nodes": "审批节点",- "delete": "删除审批流",- "select": "选择审批流","create-approval-flow": "创建审批流",- "edit-approval-flow": "编辑审批流",- "built-in": "内置审批流",- "built-in-description": "内置审批流是只读的,不能删除。",- "custom": "自定义审批流",- "no-custom-flows": "尚未创建自定义审批流。点击\"创建审批流\"添加。","node": {"nodes": "审批节点","description": "当一个节点上有多个审批人时,只需要一次审批通过。",@@ -2687,22 +2678,20 @@"add": "增加节点","delete": "删除审批节点"},- "view-approval-flow": "查看审批流","skip": "跳过人工审批",- "risk-not-configured-tips": "确保你已经定义了{link}。",- "the-related-risk-rules": "相关的风险规则","issue-review": {"sent-back": "被退回","review-sent-back-by": "审批被 {user} 退回"- }+ },+ "add-rule": "添加规则",+ "edit-rule": "编辑规则"},"risk": {- "self": "风险","risks": "风险","description": "风险中心定义了不同数据库操作在不同条件下的风险等级。而风险等级则会决定工单的自定义审批流程。"},"rule": {- "rules": "规则"+ "first-match-wins": "规则按顺序评估,第一个匹配的规则将被应用。"},"issue-review": {"approve-issue": "批准工单?",diff --git a/frontend/src/store/modules/workspaceApprovalSetting.ts b/frontend/src/store/modules/workspaceApprovalSetting.tsindex c325ab3156..aaa1ab7494 100644--- a/frontend/src/store/modules/workspaceApprovalSetting.ts+++ b/frontend/src/store/modules/workspaceApprovalSetting.ts@@ -4,18 +4,7 @@ import { defineStore } from "pinia";import { v4 as uuidv4 } from "uuid";import { ref } from "vue";import { settingServiceClientConnect } from "@/grpcweb";-import {- getBuiltinFlow,- isBuiltinFlowId,- type LocalApprovalConfig,- type LocalApprovalRule,-} from "@/types";-import type { ApprovalTemplate } from "@/types/proto-es/v1/issue_service_pb";-import {- ApprovalFlowSchema,- ApprovalTemplateSchema,-} from "@/types/proto-es/v1/issue_service_pb";-import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";+import type { LocalApprovalConfig, LocalApprovalRule } from "@/types";import type { Setting } from "@/types/proto-es/v1/setting_service_pb";import {GetSettingRequestSchema,@@ -23,6 +12,7 @@ import {SettingSchema,ValueSchema as SettingValueSchema,UpdateSettingRequestSchema,+ WorkspaceApprovalSetting_Rule_Source,} from "@/types/proto-es/v1/setting_service_pb";import {buildWorkspaceApprovalSetting,@@ -37,8 +27,6 @@ export const useWorkspaceApprovalSettingStore = defineStore(() => {const config = ref<LocalApprovalConfig>({rules: [],- parsed: [],- unrecognized: [],});const setConfigSetting = async (setting: Setting) => {@@ -80,7 +68,7 @@ export const useWorkspaceApprovalSettingStore = defineStore(await settingServiceClientConnect.updateSetting(request);};- const useBackupAndUpdateConfig = async (update: () => Promise<any>) => {+ const useBackupAndUpdateConfig = async (update: () => Promise<void>) => {const backup = cloneDeep(config.value);try {await useGracefulRequest(update);@@ -90,141 +78,74 @@ export const useWorkspaceApprovalSettingStore = defineStore(}};- const upsertRule = async (- newRule: LocalApprovalRule,- oldRule: LocalApprovalRule | undefined- ) => {- await useBackupAndUpdateConfig(async () => {- const { rules } = config.value;-- // Ensure new rule has an id (for custom rules, generate UUID if not provided)- if (!newRule.template.id) {- newRule.template.id = uuidv4();- }-- if (oldRule) {- const index = rules.indexOf(oldRule);- if (index >= 0) {- rules[index] = newRule;- }- } else {- rules.unshift(newRule);- }+ // Get rules for a specific source+ const getRulesBySource = (+ source: WorkspaceApprovalSetting_Rule_Source+ ): LocalApprovalRule[] => {+ return config.value.rules.filter((r) => r.source === source);+ };- // Note: No explicit cleanup needed here.- // buildWorkspaceApprovalSetting will save:- // - All custom templates (even if unused)- // - Only used built-in templates+ // Add a new rule+ const addRule = async (rule: Omit<LocalApprovalRule, "uid">) => {+ await useBackupAndUpdateConfig(async () => {+ const newRule: LocalApprovalRule = {+ ...rule,+ uid: uuidv4(),+ };+ config.value.rules.push(newRule);await updateConfig();});};- const deleteRule = async (rule: LocalApprovalRule) => {+ // Update an existing rule+ const updateRule = async (+ uid: string,+ updates: Partial<LocalApprovalRule>+ ) => {await useBackupAndUpdateConfig(async () => {- const { rules, parsed, unrecognized } = config.value;-- // Remove this template from parsed and unrecognized- config.value.parsed = parsed.filter(- (item) => item.rule !== rule.template.id- );- config.value.unrecognized = unrecognized.filter(- (item) => item.rule !== rule.template.id- );-- // Remove the template from rules- const index = rules.indexOf(rule);+ const index = config.value.rules.findIndex((r) => r.uid === uid);if (index >= 0) {- rules.splice(index, 1);+ config.value.rules[index] = {+ ...config.value.rules[index],+ ...updates,+ };+ await updateConfig();}-- // Note: No explicit cleanup needed here.- // buildWorkspaceApprovalSetting will save:- // - All custom templates (even if unused)- // - Only used built-in templates- await updateConfig();});};- // Helper: Ensure a template exists in the local cache for a given flow ID- // This is used for UI display and editing. The actual save is handled by buildWorkspaceApprovalSetting.- const getOrCreateTemplate = (flowId: string): LocalApprovalRule => {- const { rules } = config.value;-- // Check if template already exists- const existingRule = rules.find((rule) => rule.template.id === flowId);- if (existingRule) {- return existingRule;- }-- // Template doesn't exist, create it- let template: ApprovalTemplate;-- if (isBuiltinFlowId(flowId)) {- // Built-in flow: get from constants- const builtinFlow = getBuiltinFlow(flowId);- if (!builtinFlow) {- throw new Error(`Unknown built-in flow: ${flowId}`);+ // Delete a rule+ const deleteRule = async (uid: string) => {+ await useBackupAndUpdateConfig(async () => {+ const index = config.value.rules.findIndex((r) => r.uid === uid);+ if (index >= 0) {+ config.value.rules.splice(index, 1);+ await updateConfig();}- template = create(ApprovalTemplateSchema, {- id: builtinFlow.id,- title: builtinFlow.title,- description: builtinFlow.description,- flow: create(ApprovalFlowSchema, {- roles: [...builtinFlow.roles],- }),- });- } else {- // Custom flow: should already exist, but create a placeholder if not- template = create(ApprovalTemplateSchema, {- id: flowId,- title: "Custom Flow",- description: "",- flow: create(ApprovalFlowSchema, { roles: [] }),- });- }-- const newRule: LocalApprovalRule = { template };- rules.push(newRule);- return newRule;+ });};- const updateRuleFlow = async (- source: Risk_Source,- level: number,- rule: string | undefined+ // Reorder rules (for drag-and-drop within a source)+ const reorderRules = async (+ source: WorkspaceApprovalSetting_Rule_Source,+ fromIndex: number,+ toIndex: number) => {await useBackupAndUpdateConfig(async () => {- const { parsed } = config.value;- const index = parsed.findIndex(- (item) => item.source == source && item.level === level+ // Get all rules for this source+ const sourceRules = config.value.rules.filter(+ (r) => r.source === source+ );+ const otherRules = config.value.rules.filter(+ (r) => r.source !== source);- // Ensure template exists in local cache (for UI display)- if (rule) {- getOrCreateTemplate(rule);- }-- // Update or remove the parsed rule- if (index >= 0) {- if (rule) {- parsed[index].rule = rule;- } else {- parsed.splice(index, 1);- }- } else {- if (rule) {- parsed.push({- source,- level,- rule,- });- }- }+ // Reorder within source rules+ const [moved] = sourceRules.splice(fromIndex, 1);+ sourceRules.splice(toIndex, 0, moved);- // Note: No explicit cleanup needed here.- // buildWorkspaceApprovalSetting will save:- // - All custom templates (even if unused)- // - Only used built-in templates+ // Rebuild config with reordered rules+ config.value.rules = [...otherRules, ...sourceRules];await updateConfig();});};@@ -232,9 +153,11 @@ export const useWorkspaceApprovalSettingStore = defineStore(return {config,fetchConfig,- upsertRule,+ getRulesBySource,+ addRule,+ updateRule,deleteRule,- updateRuleFlow,+ reorderRules,};});diff --git a/frontend/src/types/proto-es/v1/issue_service_pb.d.ts b/frontend/src/types/proto-es/v1/issue_service_pb.d.tsindex b09465c332..c10eb33eaa 100644--- a/frontend/src/types/proto-es/v1/issue_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/issue_service_pb.d.ts@@ -783,15 +783,6 @@ export declare const GrantRequestSchema: GenMessage<GrantRequest>;* @generated from message bytebase.v1.ApprovalTemplate*/export declare type ApprovalTemplate = Message<"bytebase.v1.ApprovalTemplate"> & {- /**- * The unique identifier for the approval template.- * For built-in templates, use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").- * For custom templates, use a UUID or other unique identifier.- *- * @generated from field: string id = 4;- */- id: string;-/*** The approval flow definition.*diff --git a/frontend/src/types/proto-es/v1/issue_service_pb.js b/frontend/src/types/proto-es/v1/issue_service_pb.jsindex 9e49b48675..7aec0210f8 100644--- a/frontend/src/types/proto-es/v1/issue_service_pb.js+++ b/frontend/src/types/proto-es/v1/issue_service_pb.js@@ -17,7 +17,7 @@ import { file_v1_common } from "./common_pb";* Describes the file v1/issue_service.proto.*/export const file_v1_issue_service = /*@__PURE__*/- fileDesc("ChZ2MS9pc3N1ZV9zZXJ2aWNlLnByb3RvEgtieXRlYmFzZS52MSJKCg9HZXRJc3N1ZVJlcXVlc3QSKAoEbmFtZRgBIAEoCUIa4EEC+kEUChJieXRlYmFzZS5jb20vSXNzdWUSDQoFZm9yY2UYAiABKAgiagoSQ3JlYXRlSXNzdWVSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBImCgVpc3N1ZRgCIAEoCzISLmJ5dGViYXNlLnYxLklzc3VlQgPgQQIihwEKEUxpc3RJc3N1ZXNSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBIRCglwYWdlX3NpemUYAiABKAUSEgoKcGFnZV90b2tlbhgDIAEoCRIOCgZmaWx0ZXIYBCABKAkSDQoFcXVlcnkYBSABKAkiUQoSTGlzdElzc3Vlc1Jlc3BvbnNlEiIKBmlzc3VlcxgBIAMoCzISLmJ5dGViYXNlLnYxLklzc3VlEhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSJwChNTZWFyY2hJc3N1ZXNSZXF1ZXN0EhMKBnBhcmVudBgBIAEoCUID4EECEhEKCXBhZ2Vfc2l6ZRgCIAEoBRISCgpwYWdlX3Rva2VuGAMgASgJEg4KBmZpbHRlchgEIAEoCRINCgVxdWVyeRgFIAEoCSJTChRTZWFyY2hJc3N1ZXNSZXNwb25zZRIiCgZ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lzc3Vlcy8qfTpyZXF1ZXN0QqcBCg9jb20uYnl0ZWJhc2UudjFCEUlzc3VlU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_protobuf_timestamp, file_google_type_expr, file_v1_annotation, file_v1_common]);+ fileDesc("ChZ2MS9pc3N1ZV9zZXJ2aWNlLnByb3RvEgtieXRlYmFzZS52MSJKCg9HZXRJc3N1ZVJlcXVlc3QSKAoEbmFtZRgBIAEoCUIa4EEC+kEUChJieXRlYmFzZS5jb20vSXNzdWUSDQoFZm9yY2UYAiABKAgiagoSQ3JlYXRlSXNzdWVSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBImCgVpc3N1ZRgCIAEoCzISLmJ5dGViYXNlLnYxLklzc3VlQgPgQQIihwEKEUxpc3RJc3N1ZXNSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBIRCglwYWdlX3NpemUYAiABKAUSEgoKcGFnZV90b2tlbhgDIAEoCRIOCgZmaWx0ZXIYBCABKAkSDQoFcXVlcnkYBSABKAkiUQoSTGlzdElzc3Vlc1Jlc3BvbnNlEiIKBmlzc3VlcxgBIAMoCzISLmJ5dGViYXNlLnYxLklzc3VlEhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSJwChNTZWFyY2hJc3N1ZXNSZXF1ZXN0EhMKBnBhcmVudBgBIAEoCUID4EECEhEKCXBhZ2Vfc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lc3RJc3N1ZVJlcXVlc3QaEi5ieXRlYmFzZS52MS5Jc3N1ZSI5kOowApjqMAGC0+STAis6ASoiJi92MS97bmFtZT1wcm9qZWN0cy8qL2lzc3Vlcy8qfTpyZXF1ZXN0QqcBCg9jb20uYnl0ZWJhc2UudjFCEUlzc3VlU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_protobuf_timestamp, file_google_type_expr, file_v1_annotation, file_v1_common]);/*** Describes the message bytebase.v1.GetIssueRequest.diff --git a/frontend/src/types/proto-es/v1/setting_service_pb.d.ts b/frontend/src/types/proto-es/v1/setting_service_pb.d.tsindex af655674bf..57778bd713 100644--- a/frontend/src/types/proto-es/v1/setting_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/setting_service_pb.d.ts@@ -711,16 +711,41 @@ export declare type WorkspaceApprovalSetting_Rule = Message<"bytebase.v1.Workspa* The condition that is associated with the rule.* The syntax and semantics of CEL are documented at https://github.com/google/cel-spec*- * Support variables:- * source: the risk source, check the Source enum in the Risk message for the values, support "==" operator.- * level: the risk level, support 100 (low), 200 (moderate) and 300 (high), support "==" operator.+ * The `source` field filters which rules apply. The `condition` field then evaluates with full context.+ *+ * All supported variables:+ * statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.+ * statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.+ * resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.+ * resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ * resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for values.+ * statement.sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.+ * resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ * resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ * resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ * statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.+ * request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.+ * request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ *+ * When source is DDL/DML, support: statement.*, resource.* (excluding request.*)+ * When source is CREATE_DATABASE, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name+ * When source is EXPORT_DATA, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name, resource.schema_name, resource.table_name+ * When source is REQUEST_ROLE, support: resource.project_id, request.expiration_days, request.role** For examples:- * (source == "DML" && level == 200) || (source == "DDL" && level == 300)+ * resource.environment_id == "prod" && statement.affected_rows >= 100+ * resource.table_name.matches("sensitive_.*") && resource.db_engine == "MYSQL"+ *+ * Legacy format (deprecated): source == "DDL" && level == "HIGH"** @generated from field: google.type.Expr condition = 2;*/condition?: Expr;++ /**+ * @generated from field: bytebase.v1.WorkspaceApprovalSetting.Rule.Source source = 3;+ */+ source: WorkspaceApprovalSetting_Rule_Source;};/**@@ -729,6 +754,46 @@ export declare type WorkspaceApprovalSetting_Rule = Message<"bytebase.v1.Workspa*/export declare const WorkspaceApprovalSetting_RuleSchema: GenMessage<WorkspaceApprovalSetting_Rule>;+/**+ * @generated from enum bytebase.v1.WorkspaceApprovalSetting.Rule.Source+ */+export enum WorkspaceApprovalSetting_Rule_Source {+ /**+ * @generated from enum value: SOURCE_UNSPECIFIED = 0;+ */+ SOURCE_UNSPECIFIED = 0,++ /**+ * @generated from enum value: DDL = 1;+ */+ DDL = 1,++ /**+ * @generated from enum value: DML = 2;+ */+ DML = 2,++ /**+ * @generated from enum value: CREATE_DATABASE = 3;+ */+ CREATE_DATABASE = 3,++ /**+ * @generated from enum value: EXPORT_DATA = 4;+ */+ EXPORT_DATA = 4,++ /**+ * @generated from enum value: REQUEST_ROLE = 5;+ */+ REQUEST_ROLE = 5,+}++/**+ * Describes the enum bytebase.v1.WorkspaceApprovalSetting.Rule.Source.+ */+export declare const WorkspaceApprovalSetting_Rule_SourceSchema: GenEnum<WorkspaceApprovalSetting_Rule_Source>;+/*** @generated from message bytebase.v1.SchemaTemplateSetting*/diff --git a/frontend/src/types/proto-es/v1/setting_service_pb.js b/frontend/src/types/proto-es/v1/setting_service_pb.jsindex 10b0afc1c1..19d34bc4e7 100644--- a/frontend/src/types/proto-es/v1/setting_service_pb.js+++ b/frontend/src/types/proto-es/v1/setting_service_pb.js@@ -20,7 +20,7 @@ import { file_v1_project_service } from "./project_service_pb";* Describes the file v1/setting_service.proto.*/export const file_v1_setting_service = /*@__PURE__*/- fileDesc("Chh2MS9zZXR0aW5nX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIhUKE0xpc3RTZXR0aW5nc1JlcXVlc3QiPgoUTGlzdFNldHRpbmdzUmVzcG9uc2USJgoIc2V0dGluZ3MYASADKAsyFC5ieXRlYmFzZS52MS5TZXR0aW5nIj8KEUdldFNldHRpbmdSZXF1ZXN0EioKBG5hbWUYASABKAlCHOBBAvpBFgoUYnl0ZWJhc2UuY29tL1NldHRpbmciOwoSR2V0U2V0dGluZ1Jlc3BvbnNlEiUKB3NldHRpbmcYASABKAsyFC5ieXRlYmFzZS52MS5TZXR0aW5nIqEBChRVcGRhdGV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NlLnYxLlNldHRpbmciSYrqMA9iYi5zZXR0aW5ncy5zZXSQ6jABmOowAYLT5JMCKDoHc2V0dGluZzIdL3YxL3tzZXR0aW5nLm5hbWU9c2V0dGluZ3MvKn1CqQEKD2NvbS5ieXRlYmFzZS52MUITU2V0dGluZ1NlcnZpY2VQcm90b1ABWjRnaXRodWIuY29tL2J5dGViYXNlL2J5dGViYXNlL2JhY2tlbmQvZ2VuZXJhdGVkLWdvL3YxogIDQlhYqgILQnl0ZWJhc2UuVjHKAgtCeXRlYmFzZVxWMeICF0J5dGViYXNlXFYxXEdQQk1ldGFkYXRh6gIMQnl0ZWJhc2U6OlYxYgZwcm90bzM", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_type_expr, file_v1_annotation, file_v1_common, file_v1_database_catalog_service, file_v1_database_service, file_v1_issue_service, file_v1_project_service]);+ fileDesc("Chh2MS9zZXR0aW5nX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIhUKE0xpc3RTZXR0aW5nc1JlcXVlc3QiPgoUTGlzdFNldHRpbmdzUmVzcG9uc2USJgoIc2V0dGluZ3MYASADKAsyFC5ieXRlYmFzZS52MS5TZXR0aW5nIj8KEUdldFNldHRpbmdSZXF1ZXN0EioKBG5hbWUYASABKAlCHOBBAvpBFgoUYnl0ZWJhc2UuY29tL1NldHRpbmciOwoSR2V0U2V0dGluZ1Jlc3BvbnNlEiUKB3NldHRpbmcYASABKAsyFC5ieXRlYmFzZS52MS5TZXR0aW5nIqEBChRVcGRhdGVTZXR0aW5nUmVxdWVzdBIqCgdzZXR0aW5nGAEgASgLMhQuYnl0ZWJhc2UudjEuU2V0dGluZ0ID4EECEhUKDXZhbGlkYXRlX29ubHkYAiABKAgSFQoNYWxsb3dfbWlzc2luZxgDIAEoCBIvCgt1cGRhdGVfbWFzaxgEIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE1hc2si1QMKB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ldHRpbmdSZXF1ZXN0GhQuYnl0ZWJhc2UudjEuU2V0dGluZyJJiuowD2JiLnNldHRpbmdzLnNldJDqMAGY6jABgtPkkwIoOgdzZXR0aW5nMh0vdjEve3NldHRpbmcubmFtZT1zZXR0aW5ncy8qfUKpAQoPY29tLmJ5dGViYXNlLnYxQhNTZXR0aW5nU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_type_expr, file_v1_annotation, file_v1_common, file_v1_database_catalog_service, file_v1_database_service, file_v1_issue_service, file_v1_project_service]);/*** Describes the message bytebase.v1.ListSettingsRequest.@@ -174,6 +174,18 @@ export const WorkspaceApprovalSettingSchema = /*@__PURE__*/export const WorkspaceApprovalSetting_RuleSchema = /*@__PURE__*/messageDesc(file_v1_setting_service, 10, 0);+/**+ * Describes the enum bytebase.v1.WorkspaceApprovalSetting.Rule.Source.+ */+export const WorkspaceApprovalSetting_Rule_SourceSchema = /*@__PURE__*/+ enumDesc(file_v1_setting_service, 10, 0, 0);++/**+ * @generated from enum bytebase.v1.WorkspaceApprovalSetting.Rule.Source+ */+export const WorkspaceApprovalSetting_Rule_Source = /*@__PURE__*/+ tsEnum(WorkspaceApprovalSetting_Rule_SourceSchema);+/*** Describes the message bytebase.v1.SchemaTemplateSetting.* Use `create(SchemaTemplateSettingSchema)` to create a new message.diff --git a/frontend/src/types/workspaceApprovalSetting.ts b/frontend/src/types/workspaceApprovalSetting.tsindex e8cd9b67d6..7a0cda8407 100644--- a/frontend/src/types/workspaceApprovalSetting.ts+++ b/frontend/src/types/workspaceApprovalSetting.ts@@ -1,28 +1,17 @@-import type { SimpleExpr } from "@/plugins/cel";-import type { RiskLevel } from "@/types/proto-es/v1/common_pb";-import type { ApprovalTemplate } from "@/types/proto-es/v1/issue_service_pb";-import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";+import type { ConditionGroupExpr } from "@/plugins/cel";+import type { ApprovalFlow } from "@/types/proto-es/v1/issue_service_pb";+import type { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";+// A single approval rule with inline flow definitionexport type LocalApprovalRule = {- // Use template.id as the identifier instead of generating ephemeral uid- // This allows proper identification of built-in vs custom flows- expr?: SimpleExpr;- template: ApprovalTemplate;-};--export type ParsedApprovalRule = {- source: Risk_Source;- level: RiskLevel;- rule: string; // ApprovalTemplate.id-};--export type UnrecognizedApprovalRule = {- expr?: SimpleExpr;- rule: string; // ApprovalTemplate.id+ uid: string; // Local unique identifier for UI tracking+ source: WorkspaceApprovalSetting_Rule_Source;+ condition: string; // CEL expression string+ conditionExpr?: ConditionGroupExpr; // Parsed CEL for editor+ flow: ApprovalFlow; // Inline approval flow (roles array)};+// The local config is just a list of rules per sourceexport type LocalApprovalConfig = {rules: LocalApprovalRule[];- parsed: ParsedApprovalRule[];- unrecognized: UnrecognizedApprovalRule[];};diff --git a/frontend/src/utils/workspaceApprovalSetting.ts b/frontend/src/utils/workspaceApprovalSetting.tsindex bbc26854a9..4aacc0fc60 100644--- a/frontend/src/utils/workspaceApprovalSetting.ts+++ b/frontend/src/utils/workspaceApprovalSetting.ts@@ -1,369 +1,104 @@-import { create as createProto } from "@bufbuild/protobuf";-import { cloneDeep } from "lodash-es";+import { create } from "@bufbuild/protobuf";import { v4 as uuidv4 } from "uuid";-import type { EqualityExpr, LogicalExpr, SimpleExpr } from "@/plugins/cel";-import {- buildCELExpr,- ExprType,- isConditionExpr,- isConditionGroupExpr,- resolveCELExpr,-} from "@/plugins/cel";-import type {- LocalApprovalConfig,- LocalApprovalRule,- ParsedApprovalRule,- UnrecognizedApprovalRule,-} from "@/types";-import {- DEFAULT_RISK_LEVEL,- getBuiltinFlow,- isBuiltinFlowId,- PresetRiskLevelList,- useSupportedSourceList,-} from "@/types";-import type { Expr as CELExpr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";-import { ExprSchema as CELExprSchema } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";-import type { Expr as _Expr } from "@/types/proto-es/google/type/expr_pb";+import type { ConditionGroupExpr } from "@/plugins/cel";+import { resolveCELExpr, wrapAsGroup } from "@/plugins/cel";+import type { LocalApprovalConfig, LocalApprovalRule } from "@/types";import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";-import { RiskLevel } from "@/types/proto-es/v1/common_pb";-import type {- ApprovalFlow as _ProtoEsApprovalFlow,- ApprovalTemplate as _ProtoEsApprovalTemplate,-} from "@/types/proto-es/v1/issue_service_pb";+import type { ApprovalFlow } from "@/types/proto-es/v1/issue_service_pb";+import { ApprovalFlowSchema } from "@/types/proto-es/v1/issue_service_pb";+import type { WorkspaceApprovalSetting } from "@/types/proto-es/v1/setting_service_pb";import {- ApprovalFlowSchema as _ProtoEsApprovalFlowSchema,- ApprovalTemplateSchema as _ProtoEsApprovalTemplateSchema,-} from "@/types/proto-es/v1/issue_service_pb";-import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";-import type {- WorkspaceApprovalSetting_Rule as ApprovalRule,- WorkspaceApprovalSetting,-} from "@/types/proto-es/v1/setting_service_pb";-import {- WorkspaceApprovalSetting_RuleSchema as ApprovalRuleSchema,+ WorkspaceApprovalSetting_Rule_Source,+ WorkspaceApprovalSetting_RuleSchema,WorkspaceApprovalSettingSchema,} from "@/types/proto-es/v1/setting_service_pb";-import {- batchConvertCELStringToParsedExpr,- batchConvertParsedExprToCELString,-} from "@/utils";+import { batchConvertCELStringToParsedExpr } from "@/utils";import { displayRoleTitle } from "./role";export const approvalNodeRoleText = (role: string) => {return displayRoleTitle(role);};-/*- A WorkspaceApprovalSetting is a list of ApprovalRule = {- expr,- approval_template- }- Currently, every ApprovalRule.expr is a list of "OR" expr.- And every "OR" expr has a fixed "source==xx && level=yy" form.-- So we walk through the list of ApprovalRule and find all combinations of- ParsedApprovalRule = {- source,- level,- rule,- }-*/+// Convert proto WorkspaceApprovalSetting to local formatexport const resolveLocalApprovalConfig = async (config: WorkspaceApprovalSetting): Promise<LocalApprovalConfig> => {- const ruleMap: Map<string, LocalApprovalRule> = new Map();+ const rules: LocalApprovalRule[] = [];const expressions: string[] = [];- const ruleIdList: string[] = [];+ const ruleIndices: number[] = [];for (let i = 0; i < config.rules.length; i++) {- const rule = config.rules[i];- const template = cloneDeep(rule.template!);-- // Ensure template has an id, generate UUID if missing (for legacy data)- if (!template.id) {- template.id = uuidv4();- }-- const localRule: LocalApprovalRule = {- expr: resolveCELExpr(createProto(CELExprSchema, {})),- template,+ const protoRule = config.rules[i];+ const condition = protoRule.condition?.expression || "";++ const rule: LocalApprovalRule = {+ uid: uuidv4(),+ source:+ protoRule.source ||+ WorkspaceApprovalSetting_Rule_Source.SOURCE_UNSPECIFIED,+ condition,+ flow:+ protoRule.template?.flow || create(ApprovalFlowSchema, { roles: [] }),};- ruleMap.set(template.id, localRule);- if (rule.condition?.expression) {- expressions.push(rule.condition.expression);- ruleIdList.push(template.id);- }- }+ rules.push(rule);- const exprList = await batchConvertCELStringToParsedExpr(expressions);- for (let i = 0; i < exprList.length; i++) {- const ruleId = ruleIdList[i];- ruleMap.get(ruleId)!.expr = resolveCELExpr(- exprList[i] ?? createProto(CELExprSchema, {})- );+ if (condition) {+ expressions.push(condition);+ ruleIndices.push(i);+ }}- const rules = [...ruleMap.values()];- const { parsed, unrecognized } = resolveApprovalConfigRules(rules);- return {- rules,- parsed,- unrecognized,- };-};--const resolveApprovalConfigRules = (rules: LocalApprovalRule[]) => {- const parsed: ParsedApprovalRule[] = [];- const unrecognized: UnrecognizedApprovalRule[] = [];-- const fail = (expr: SimpleExpr | undefined, rule: LocalApprovalRule) => {- unrecognized.push({ expr, rule: rule.template.id });- };-- const resolveLogicAndExpr = (expr: SimpleExpr, rule: LocalApprovalRule) => {- if (!isConditionGroupExpr(expr)) return fail(expr, rule);- const { operator, args } = expr;- if (operator !== "_&&_") return fail(expr, rule);- if (!args || args.length !== 2) return fail(expr, rule);- const source = resolveSourceExpr(args[0]);- if (source === Risk_Source.SOURCE_UNSPECIFIED) return fail(expr, rule);- const level = resolveLevelExpr(args[1]);-- // Found a correct (source, level) combination- parsed.push({- source,- level,- rule: rule.template.id,- });- };-- const resolveLogicOrExpr = (expr: SimpleExpr, rule: LocalApprovalRule) => {- if (!isConditionGroupExpr(expr)) return fail(expr, rule);- const { operator, args } = expr;- if (operator !== "_||_") return fail(expr, rule);- if (!args || args.length === 0) return fail(expr, rule);-- for (const subExpr of args) {- if (!isConditionGroupExpr(subExpr)) {- continue;- }- if (subExpr.operator === "_&&_") {- resolveLogicAndExpr(subExpr, rule);+ // Parse CEL expressions in batch+ if (expressions.length > 0) {+ const parsedExprs = await batchConvertCELStringToParsedExpr(expressions);+ for (let i = 0; i < parsedExprs.length; i++) {+ const ruleIndex = ruleIndices[i];+ const parsed = parsedExprs[i];+ if (parsed) {+ rules[ruleIndex].conditionExpr = wrapAsGroup(+ resolveCELExpr(parsed)+ ) as ConditionGroupExpr;}- if (subExpr.operator === "_||_") {- resolveLogicOrExpr(subExpr, rule);- }- }- };-- for (const rule of rules) {- const expr = rule.expr;- if (!expr || !isConditionGroupExpr(expr)) {- fail(expr, rule);- continue;- }- if (expr.operator === "_&&_") {- // A single "AND" expr maybe.- resolveLogicAndExpr(expr, rule);- } else {- // A huge "OR" expr combined with several "AND" exprs.- resolveLogicOrExpr(expr, rule);}}- return { parsed, unrecognized };+ return { rules };};+// Convert local format back to proto WorkspaceApprovalSettingexport const buildWorkspaceApprovalSetting = async (config: LocalApprovalConfig-) => {- const { rules, parsed } = config;-- const parsedMap = toMap(parsed);-- // Get unique template IDs that are actually used (have parsed rules)- const usedTemplateIds = new Set(parsed.map((p) => p.rule));-- // Build a map of template ID -> template for quick lookup- const templateMap = new Map<string, _ProtoEsApprovalTemplate>();- for (const rule of rules) {- if (rule.template.id) {- templateMap.set(rule.template.id, rule.template);- }- }-- // Determine which templates to save:- // 1. All custom templates (even if unused - they are user-created)- // 2. Only used built-in templates (just-in-time materialization)- const templatesToSave = new Set<string>();-- // Add all custom templates- for (const rule of rules) {- if (rule.template.id && !isBuiltinFlowId(rule.template.id)) {- templatesToSave.add(rule.template.id);- }- }-- // Add used built-in templates- for (const templateId of usedTemplateIds) {- templatesToSave.add(templateId);- }-- const approvalRuleMap: Map<string, ApprovalRule> = new Map();- const exprList: CELExpr[] = [];- const templateIdList: string[] = [];-- // Process each template to save- for (const templateId of templatesToSave) {- // Get template from cache, or materialize built-in template- let template = templateMap.get(templateId);-- if (!template && isBuiltinFlowId(templateId)) {- // Built-in template not in cache - materialize it- const builtinFlow = getBuiltinFlow(templateId);- if (builtinFlow) {- template = createProto(_ProtoEsApprovalTemplateSchema, {- id: builtinFlow.id,- title: builtinFlow.title,- description: builtinFlow.description,- flow: createProto(_ProtoEsApprovalFlowSchema, {- roles: [...builtinFlow.roles],- }),- });- }- }-- if (!template) {- console.warn(`Template ${templateId} not found, skipping`);- continue;- }-- const approvalRule = createProto(ApprovalRuleSchema, {- template: template,- condition: createProto(ExprSchema, { expression: "" }),+): Promise<WorkspaceApprovalSetting> => {+ const protoRules = [];++ for (const rule of config.rules) {+ const protoRule = create(WorkspaceApprovalSetting_RuleSchema, {+ source: rule.source,+ condition: create(ExprSchema, { expression: rule.condition }),+ template: {+ flow: rule.flow,+ },});- approvalRuleMap.set(templateId, approvalRule);-- const parsed = parsedMap.get(templateId) ?? [];- const parsedExpr = await buildParsedExpression(parsed);- if (parsedExpr) {- exprList.push(parsedExpr);- templateIdList.push(templateId);- }+ protoRules.push(protoRule);}- const expressionList = await batchConvertParsedExprToCELString(exprList);- for (let i = 0; i < expressionList.length; i++) {- const templateId = templateIdList[i];- approvalRuleMap.get(templateId)!.condition = createProto(ExprSchema, {- expression: expressionList[i],- });- }-- return createProto(WorkspaceApprovalSettingSchema, {- rules: [...approvalRuleMap.values()],+ return create(WorkspaceApprovalSettingSchema, {+ rules: protoRules,});};-const resolveSourceExpr = (expr: SimpleExpr): Risk_Source => {- if (!isConditionExpr(expr)) {- return Risk_Source.SOURCE_UNSPECIFIED;- }- const { operator, args } = expr;- if (operator !== "_==_") {- return Risk_Source.SOURCE_UNSPECIFIED;- }- if (!args || args.length !== 2) {- return Risk_Source.SOURCE_UNSPECIFIED;- }- const factor = args[0];- if (factor !== "source") {- return Risk_Source.SOURCE_UNSPECIFIED;- }- const sourceValue = args[1];- const source =- typeof sourceValue === "string"- ? (Risk_Source[sourceValue as keyof typeof Risk_Source] ??- Risk_Source.SOURCE_UNSPECIFIED)- : (sourceValue as Risk_Source);- if (!useSupportedSourceList().value.includes(source)) {- return Risk_Source.SOURCE_UNSPECIFIED;- }- return source;+// Helper: Get rules filtered by source+export const getRulesBySource = (+ config: LocalApprovalConfig,+ source: WorkspaceApprovalSetting_Rule_Source+): LocalApprovalRule[] => {+ return config.rules.filter((r) => r.source === source);};-const resolveLevelExpr = (expr: SimpleExpr): RiskLevel => {- if (!isConditionExpr(expr)) return RiskLevel.RISK_LEVEL_UNSPECIFIED;- const { operator, args } = expr;- if (operator !== "_==_") return RiskLevel.RISK_LEVEL_UNSPECIFIED;- if (!args || args.length !== 2) return RiskLevel.RISK_LEVEL_UNSPECIFIED;- const factor = args[0];- if (factor !== "level") return RiskLevel.RISK_LEVEL_UNSPECIFIED;- const level = args[1];-- // Handle string values (new format: "LOW", "MODERATE", "HIGH", "RISK_LEVEL_UNSPECIFIED")- if (typeof level === "string") {- const enumValue = RiskLevel[level as keyof typeof RiskLevel];- if (enumValue !== undefined) {- return enumValue;- }- return RiskLevel.RISK_LEVEL_UNSPECIFIED;+// Helper: Format approval flow for display+export const formatApprovalFlow = (flow: ApprovalFlow): string => {+ if (!flow.roles || flow.roles.length === 0) {+ return "-";}-- // Handle numeric values (legacy format or enum values)- if (typeof level === "number") {- const supportedRiskLevelList = [- ...PresetRiskLevelList.map((item) => item.level),- DEFAULT_RISK_LEVEL,- ];- if (supportedRiskLevelList.includes(level)) {- return level;- }- }-- return RiskLevel.RISK_LEVEL_UNSPECIFIED;-};--const toMap = <T extends { rule: string }>(items: T[]): Map<string, T[]> => {- return items.reduce((map, item) => {- const { rule } = item;- const array = map.get(rule) ?? [];- array.push(item);- map.set(rule, array);- return map;- }, new Map());-};--const buildParsedExpression = async (parsed: ParsedApprovalRule[]) => {- if (parsed.length === 0) {- return undefined;- }- const args = parsed.map(({ source, level }) => {- const sourceExpr: EqualityExpr = {- type: ExprType.Condition,- operator: "_==_",- args: ["source", Risk_Source[source]],- };- // Convert RiskLevel enum to string name for CEL expression- // This generates: level == "LOW", level == "MODERATE", level == "HIGH"- const levelExpr: EqualityExpr = {- type: ExprType.Condition,- operator: "_==_",- args: ["level", RiskLevel[level]],- };- return {- type: ExprType.ConditionGroup,- operator: "_&&_",- args: [sourceExpr, levelExpr],- };- });- const listedOrExpr: LogicalExpr = {- type: ExprType.ConditionGroup,- operator: "_||_",- args: args as SimpleExpr[],- };- // expr will be unwrapped to an "&&" expr if listedOrExpr.length === 0- const expr = await buildCELExpr(listedOrExpr);- return expr;+ return flow.roles.map((r) => displayRoleTitle(r)).join(" → ");};diff --git a/frontend/src/views/SettingWorkspaceCustomApproval.vue b/frontend/src/views/SettingWorkspaceCustomApproval.vueindex 7da7de6280..08cd788738 100644--- a/frontend/src/views/SettingWorkspaceCustomApproval.vue+++ b/frontend/src/views/SettingWorkspaceCustomApproval.vue@@ -8,8 +8,6 @@</div></div>- <ApprovalRuleDialog />-<FeatureModal:feature="PlanFeature.FEATURE_APPROVAL_WORKFLOW":open="state.showFeatureModal"@@ -18,21 +16,14 @@</template><script lang="ts" setup>-import { onMounted, reactive, ref, toRef } from "vue";+import { onMounted, reactive, toRef } from "vue";import { BBSpin } from "@/bbkit";import {- ApprovalRuleDialog,CustomApproval,provideCustomApprovalContext,- TabValueList,} from "@/components/CustomApproval/Settings/components/CustomApproval/";import { FeatureAttention, FeatureModal } from "@/components/FeatureGuard";-import { useRouteHash } from "@/composables/useRouteHash";-import {- featureToRef,- useRiskStore,- useWorkspaceApprovalSettingStore,-} from "@/store";+import { featureToRef, useWorkspaceApprovalSettingStore } from "@/store";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";interface LocalState {@@ -48,7 +39,6 @@ const state = reactive<LocalState>({ready: false,showFeatureModal: false,});-const tab = useRouteHash("rules", TabValueList, "replace");const hasCustomApprovalFeature = featureToRef(PlanFeature.FEATURE_APPROVAL_WORKFLOW);@@ -58,16 +48,11 @@ provideCustomApprovalContext({showFeatureModal: toRef(state, "showFeatureModal"),allowAdmin: toRef(props, "allowEdit"),ready: toRef(state, "ready"),- tab,- dialog: ref(),});onMounted(async () => {try {- await Promise.all([- useWorkspaceApprovalSettingStore().fetchConfig(),- useRiskStore().fetchRiskList(),- ]);+ await useWorkspaceApprovalSettingStore().fetchConfig();state.ready = true;} catch {// nothingdiff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex fc090036ba..0ff01250fa 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -8374,12 +8374,6 @@ components:ApprovalTemplate:type: objectproperties:- id:- type: string- description: |-- The unique identifier for the approval template.- Built-in templates use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").- Custom templates use a UUID or other unique identifier.flow:allOf:- $ref: '#/components/schemas/ApprovalFlow'@@ -14846,6 +14840,16 @@ components:$ref: '#/components/schemas/ApprovalTemplate'condition:$ref: '#/components/schemas/Expr'+ source:+ enum:+ - SOURCE_UNSPECIFIED+ - DDL+ - DML+ - CREATE_DATABASE+ - EXPORT_DATA+ - REQUEST_ROLE+ type: string+ format: enumWorkspaceProfileSetting:type: objectproperties:diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.mdindex e1d4cf0bb1..798e2037a8 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -295,6 +295,7 @@- [Announcement.AlertLevel](#bytebase-store-Announcement-AlertLevel)- [DatabaseChangeMode](#bytebase-store-DatabaseChangeMode)- [SettingName](#bytebase-store-SettingName)+ - [WorkspaceApprovalSetting.Rule.Source](#bytebase-store-WorkspaceApprovalSetting-Rule-Source)- [store/sheet.proto](#store_sheet-proto)- [SheetPayload](#bytebase-store-SheetPayload)@@ -618,7 +619,6 @@ ApprovalTemplate defines the approval workflow and requirements for an issue.| Field | Type | Label | Description || ----- | ---- | ----- | ----------- |-| id | [string](#string) | | The unique identifier for the approval template. Built-in templates use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba"). Custom templates use a UUID or other unique identifier. || flow | [ApprovalFlow](#bytebase-store-ApprovalFlow) | | The approval workflow specification. || title | [string](#string) | | Human-readable title of the approval template. || description | [string](#string) | | Detailed description of when this template applies. |@@ -4674,6 +4674,7 @@ ISSUE_CREATE represents creating an issue. || ----- | ---- | ----- | ----------- || template | [ApprovalTemplate](#bytebase-store-ApprovalTemplate) | | || condition | [google.type.Expr](#google-type-Expr) | | |+| source | [WorkspaceApprovalSetting.Rule.Source](#bytebase-store-WorkspaceApprovalSetting-Rule-Source) | | |@@ -4790,6 +4791,22 @@ We support three levels of AlertLevel: INFO, WARNING, and ERROR.| ENVIRONMENT | 19 | |++<a name="bytebase-store-WorkspaceApprovalSetting-Rule-Source"></a>++### WorkspaceApprovalSetting.Rule.Source+++| Name | Number | Description |+| ---- | ------ | ----------- |+| SOURCE_UNSPECIFIED | 0 | |+| DDL | 1 | |+| DML | 2 | |+| CREATE_DATABASE | 3 | |+| EXPORT_DATA | 4 | |+| REQUEST_ROLE | 5 | |++diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.htmlindex ba67818a40..28be4b5a76 100644--- a/proto/gen/grpc-doc/store/index.html+++ b/proto/gen/grpc-doc/store/index.html@@ -1351,6 +1351,10 @@<a href="#bytebase.store.SettingName"><span class="badge">E</span>SettingName</a></li>+ <li>+ <a href="#bytebase.store.WorkspaceApprovalSetting.Rule.Source"><span class="badge">E</span>WorkspaceApprovalSetting.Rule.Source</a>+ </li>+</ul>@@ -2170,15 +2174,6 @@ TODO: use range instead. </p></td></thead><tbody>- <tr>- <td>id</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The unique identifier for the approval template.-Built-in templates use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").-Custom templates use a UUID or other unique identifier. </p></td>- </tr>-<tr><td>flow</td><td><a href="#bytebase.store.ApprovalFlow">ApprovalFlow</a></td>@@ -12258,6 +12253,13 @@ are /[a-z][0-9]-/. </p></td><td><p> </p></td></tr>+ <tr>+ <td>source</td>+ <td><a href="#bytebase.store.WorkspaceApprovalSetting.Rule.Source">WorkspaceApprovalSetting.Rule.Source</a></td>+ <td></td>+ <td><p> </p></td>+ </tr>+</tbody></table>@@ -12624,6 +12626,53 @@ Default to this mode.</p></td></tbody></table>+ <h3 id="bytebase.store.WorkspaceApprovalSetting.Rule.Source">WorkspaceApprovalSetting.Rule.Source</h3>+ <p></p>+ <table class="enum-table">+ <thead>+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>+ </thead>+ <tbody>++ <tr>+ <td>SOURCE_UNSPECIFIED</td>+ <td>0</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>DDL</td>+ <td>1</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>DML</td>+ <td>2</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>CREATE_DATABASE</td>+ <td>3</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>EXPORT_DATA</td>+ <td>4</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>REQUEST_ROLE</td>+ <td>5</td>+ <td><p></p></td>+ </tr>++ </tbody>+ </table>+diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex a02ed8104d..5cb210f97e 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -303,6 +303,7 @@- [Announcement.AlertLevel](#bytebase-v1-Announcement-AlertLevel)- [DatabaseChangeMode](#bytebase-v1-DatabaseChangeMode)- [Setting.SettingName](#bytebase-v1-Setting-SettingName)+ - [WorkspaceApprovalSetting.Rule.Source](#bytebase-v1-WorkspaceApprovalSetting-Rule-Source)- [SettingService](#bytebase-v1-SettingService)@@ -3473,7 +3474,6 @@ DatabaseService manages databases and their schemas.| Field | Type | Label | Description || ----- | ---- | ----- | ----------- |-| id | [string](#string) | | The unique identifier for the approval template. For built-in templates, use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba"). For custom templates, use a UUID or other unique identifier. || flow | [ApprovalFlow](#bytebase-v1-ApprovalFlow) | | The approval flow definition. || title | [string](#string) | | The title of the approval template. || description | [string](#string) | | The description of the approval template. |@@ -5394,9 +5394,16 @@ The data in setting value.| template | [ApprovalTemplate](#bytebase-v1-ApprovalTemplate) | | || condition | [google.type.Expr](#google-type-Expr) | | The condition that is associated with the rule. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec-Support variables: source: the risk source, check the Source enum in the Risk message for the values, support "==" operator. level: the risk level, support 100 (low), 200 (moderate) and 300 (high), support "==" operator.+The `source` field filters which rules apply. The `condition` field then evaluates with full context.-For examples: (source == "DML" && level == 200) || (source == "DDL" && level == 300) |+All supported variables: statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations. statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations. resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations. resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations. resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for values. statement.sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations. resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations. resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations. resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations. statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations. request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations. request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.++When source is DDL/DML, support: statement.*, resource.* (excluding request.*) When source is CREATE_DATABASE, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name When source is EXPORT_DATA, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name, resource.schema_name, resource.table_name When source is REQUEST_ROLE, support: resource.project_id, request.expiration_days, request.role++For examples: resource.environment_id == "prod" && statement.affected_rows >= 100 resource.table_name.matches("sensitive_.*") && resource.db_engine == "MYSQL"++Legacy format (deprecated): source == "DDL" && level == "HIGH" |+| source | [WorkspaceApprovalSetting.Rule.Source](#bytebase-v1-WorkspaceApprovalSetting-Rule-Source) | | |@@ -5513,6 +5520,22 @@ We support three levels of AlertLevel: INFO, WARNING, and ERROR.| ENVIRONMENT | 19 | |++<a name="bytebase-v1-WorkspaceApprovalSetting-Rule-Source"></a>++### WorkspaceApprovalSetting.Rule.Source+++| Name | Number | Description |+| ---- | ------ | ----------- |+| SOURCE_UNSPECIFIED | 0 | |+| DDL | 1 | |+| DML | 2 | |+| CREATE_DATABASE | 3 | |+| EXPORT_DATA | 4 | |+| REQUEST_ROLE | 5 | |++diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 6f1dc8693c..57826ec9b8 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -1342,6 +1342,10 @@<a href="#bytebase.v1.Setting.SettingName"><span class="badge">E</span>Setting.SettingName</a></li>+ <li>+ <a href="#bytebase.v1.WorkspaceApprovalSetting.Rule.Source"><span class="badge">E</span>WorkspaceApprovalSetting.Rule.Source</a>+ </li>+<li>@@ -10627,15 +10631,6 @@ Permissions required: bb.databases.getSchema</p></td></thead><tbody>- <tr>- <td>id</td>- <td><a href="#string">string</a></td>- <td></td>- <td><p>The unique identifier for the approval template.-For built-in templates, use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").-For custom templates, use a UUID or other unique identifier. </p></td>- </tr>-<tr><td>flow</td><td><a href="#bytebase.v1.ApprovalFlow">ApprovalFlow</a></td>@@ -15597,12 +15592,39 @@ server would not persist the setting value if it is true. </p></td><td><p>The condition that is associated with the rule.The syntax and semantics of CEL are documented at https://github.com/google/cel-spec-Support variables:-source: the risk source, check the Source enum in the Risk message for the values, support "==" operator.-level: the risk level, support 100 (low), 200 (moderate) and 300 (high), support "==" operator.+The `source` field filters which rules apply. The `condition` field then evaluates with full context.++All supported variables:+statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.+statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.+resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.+resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for values.+statement.sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.+resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.+request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.+request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.++When source is DDL/DML, support: statement.*, resource.* (excluding request.*)+When source is CREATE_DATABASE, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name+When source is EXPORT_DATA, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name, resource.schema_name, resource.table_name+When source is REQUEST_ROLE, support: resource.project_id, request.expiration_days, request.roleFor examples:-(source == "DML" && level == 200) || (source == "DDL" && level == 300) </p></td>+resource.environment_id == "prod" && statement.affected_rows >= 100+resource.table_name.matches("sensitive_.*") && resource.db_engine == "MYSQL"++Legacy format (deprecated): source == "DDL" && level == "HIGH" </p></td>+ </tr>++ <tr>+ <td>source</td>+ <td><a href="#bytebase.v1.WorkspaceApprovalSetting.Rule.Source">WorkspaceApprovalSetting.Rule.Source</a></td>+ <td></td>+ <td><p> </p></td></tr></tbody>@@ -15971,6 +15993,53 @@ Default to this mode.</p></td></tbody></table>+ <h3 id="bytebase.v1.WorkspaceApprovalSetting.Rule.Source">WorkspaceApprovalSetting.Rule.Source</h3>+ <p></p>+ <table class="enum-table">+ <thead>+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>+ </thead>+ <tbody>++ <tr>+ <td>SOURCE_UNSPECIFIED</td>+ <td>0</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>DDL</td>+ <td>1</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>DML</td>+ <td>2</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>CREATE_DATABASE</td>+ <td>3</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>EXPORT_DATA</td>+ <td>4</td>+ <td><p></p></td>+ </tr>++ <tr>+ <td>REQUEST_ROLE</td>+ <td>5</td>+ <td><p></p></td>+ </tr>++ </tbody>+ </table>+diff --git a/proto/store/store/approval.proto b/proto/store/store/approval.protoindex 3473575815..30675fb11a 100644--- a/proto/store/store/approval.proto+++ b/proto/store/store/approval.proto@@ -45,10 +45,6 @@ message IssuePayloadApproval {// ApprovalTemplate defines the approval workflow and requirements for an issue.message ApprovalTemplate {- // The unique identifier for the approval template.- // Built-in templates use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").- // Custom templates use a UUID or other unique identifier.- string id = 4;// The approval workflow specification.ApprovalFlow flow = 1;// Human-readable title of the approval template.diff --git a/proto/store/store/setting.proto b/proto/store/store/setting.protoindex 8591d24906..8ce8c312d3 100644--- a/proto/store/store/setting.proto+++ b/proto/store/store/setting.proto@@ -98,6 +98,15 @@ message WorkspaceApprovalSetting {message Rule {ApprovalTemplate template = 1;google.type.Expr condition = 2;+ Source source = 3;+ enum Source {+ SOURCE_UNSPECIFIED = 0;+ DDL = 1;+ DML = 2;+ CREATE_DATABASE = 3;+ EXPORT_DATA = 4;+ REQUEST_ROLE = 5;+ }}repeated Rule rules = 1;}diff --git a/proto/v1/v1/issue_service.proto b/proto/v1/v1/issue_service.protoindex 8026cb8ce4..366ee93a6e 100644--- a/proto/v1/v1/issue_service.proto+++ b/proto/v1/v1/issue_service.proto@@ -501,10 +501,6 @@ enum IssueStatus {}message ApprovalTemplate {- // The unique identifier for the approval template.- // For built-in templates, use "bb." prefix (e.g., "bb.project-owner", "bb.workspace-dba").- // For custom templates, use a UUID or other unique identifier.- string id = 4;// The approval flow definition.ApprovalFlow flow = 1;// The title of the approval template.diff --git a/proto/v1/v1/setting_service.proto b/proto/v1/v1/setting_service.protoindex 0346643b8a..a947693a4e 100644--- a/proto/v1/v1/setting_service.proto+++ b/proto/v1/v1/setting_service.proto@@ -251,13 +251,42 @@ message WorkspaceApprovalSetting {// The condition that is associated with the rule.// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec//- // Support variables:- // source: the risk source, check the Source enum in the Risk message for the values, support "==" operator.- // level: the risk level, support 100 (low), 200 (moderate) and 300 (high), support "==" operator.+ // The `source` field filters which rules apply. The `condition` field then evaluates with full context.+ //+ // All supported variables:+ // statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.+ // statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.+ // resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.+ // resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for values.+ // statement.sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.+ // resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.+ // request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.+ // request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.+ //+ // When source is DDL/DML, support: statement.*, resource.* (excluding request.*)+ // When source is CREATE_DATABASE, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name+ // When source is EXPORT_DATA, support: resource.environment_id, resource.project_id, resource.db_engine, resource.database_name, resource.schema_name, resource.table_name+ // When source is REQUEST_ROLE, support: resource.project_id, request.expiration_days, request.role//// For examples:- // (source == "DML" && level == 200) || (source == "DDL" && level == 300)+ // resource.environment_id == "prod" && statement.affected_rows >= 100+ // resource.table_name.matches("sensitive_.*") && resource.db_engine == "MYSQL"+ //+ // Legacy format (deprecated): source == "DDL" && level == "HIGH"google.type.Expr condition = 2;+ Source source = 3;+ enum Source {+ SOURCE_UNSPECIFIED = 0;+ DDL = 1;+ DML = 2;+ CREATE_DATABASE = 3;+ EXPORT_DATA = 4;+ REQUEST_ROLE = 5;+ }}repeated Rule rules = 1;}