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: unify the DataSourceQueryPolicy and QueryDataPolicy (#18937)
ecmadao69aac665667e
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yamlindex 1aecd09b90..4f5272fd53 100644--- a/backend/api/mcp/gen/openapi.yaml+++ b/backend/api/mcp/gen/openapi.yaml@@ -8567,32 +8567,6 @@ components:- AWS_SECRETS_MANAGER- GCP_SECRET_MANAGER- AZURE_KEY_VAULT- bytebase.v1.DataSourceQueryPolicy:- type: object- properties:- adminDataSourceRestriction:- title: admin_data_source_restriction- description: Restriction for admin data source queries.- $ref: '#/components/schemas/bytebase.v1.DataSourceQueryPolicy.Restriction'- disallowDdl:- type: boolean- title: disallow_ddl- description: Disallow running DDL statements in the SQL editor.- disallowDml:- type: boolean- title: disallow_dml- description: Disallow running DML statements in the SQL editor.- title: DataSourceQueryPolicy- additionalProperties: false- description: Policy for controlling which data sources can be queried in the SQL editor.- bytebase.v1.DataSourceQueryPolicy.Restriction:- type: string- title: Restriction- enum:- - RESTRICTION_UNSPECIFIED- - FALLBACK- - DISALLOW- description: Restriction level for admin data source access.bytebase.v1.DataSourceType:type: stringtitle: DataSourceType@@ -12942,13 +12916,6 @@ components:description: The resource type for the policy.$ref: '#/components/schemas/bytebase.v1.PolicyResourceType'- oneOf:- - properties:- dataSourceQueryPolicy:- title: data_source_query_policy- $ref: '#/components/schemas/bytebase.v1.DataSourceQueryPolicy'- title: data_source_query_policy- required:- - dataSourceQueryPolicy- properties:maskingExemptionPolicy:title: masking_exemption_policy@@ -13016,7 +12983,6 @@ components:- MASKING_EXEMPTION- ROLLOUT_POLICY- TAG- - DATA_SOURCE_QUERY- DATA_QUERYdescription: The type of organizational policy.bytebase.v1.Position:@@ -13266,9 +13232,29 @@ components:type: booleantitle: disable_copy_datadescription: Disable copying query results.+ adminDataSourceRestriction:+ title: admin_data_source_restriction+ description: Restriction for admin data source queries.+ $ref: '#/components/schemas/bytebase.v1.QueryDataPolicy.Restriction'+ disallowDdl:+ type: boolean+ title: disallow_ddl+ description: Disallow running DDL statements in the SQL editor.+ disallowDml:+ type: boolean+ title: disallow_dml+ description: Disallow running DML statements in the SQL editor.title: QueryDataPolicyadditionalProperties: falsedescription: QueryDataPolicy is the policy configuration for querying data.+ bytebase.v1.QueryDataPolicy.Restriction:+ type: string+ title: Restriction+ enum:+ - RESTRICTION_UNSPECIFIED+ - FALLBACK+ - DISALLOW+ description: Restriction level for admin data source access.bytebase.v1.QueryHistory:type: objectproperties:diff --git a/backend/api/v1/org_policy_service.go b/backend/api/v1/org_policy_service.goindex 679b455315..793ac8f9bb 100644--- a/backend/api/v1/org_policy_service.go+++ b/backend/api/v1/org_policy_service.go@@ -3,6 +3,7 @@ package v1import ("context""fmt"+ "slices""strings""connectrpc.com/connect"@@ -28,8 +29,6 @@ var (storepb.Policy_QUERY_DATA: {storepb.Policy_WORKSPACE, storepb.Policy_ENVIRONMENT, storepb.Policy_PROJECT},storepb.Policy_MASKING_RULE: {storepb.Policy_WORKSPACE},storepb.Policy_MASKING_EXEMPTION: {storepb.Policy_PROJECT},- storepb.Policy_IAM: {storepb.Policy_WORKSPACE},- storepb.Policy_DATA_SOURCE_QUERY: {storepb.Policy_ENVIRONMENT, storepb.Policy_PROJECT},})@@ -260,8 +259,6 @@ func pathMatchType(path string, policyType storepb.Policy_Type) bool {return path == "masking_exemption_policy"case storepb.Policy_TAG:return path == "tag_policy"- case storepb.Policy_DATA_SOURCE_QUERY:- return path == "data_source_query_policy"case storepb.Policy_QUERY_DATA:return path == "query_data_policy"default:@@ -484,16 +481,14 @@ func validatePolicyType(policyType storepb.Policy_Type, policyResourceType storeif !ok {return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unknown policy type %v", policyType))}- for _, rt := range allowedTypes {- if rt == policyResourceType {- return nil- }+ if slices.Contains(allowedTypes, policyResourceType) {+ return nil}return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("policy %v is not allowed in resource %v", policyType, policyResourceType))}func (s *OrgPolicyService) checkPolicyFeatureGuard(policyType v1pb.PolicyType) error {- if policyType == v1pb.PolicyType_DATA_QUERY || policyType == v1pb.PolicyType_DATA_SOURCE_QUERY {+ if policyType == v1pb.PolicyType_DATA_QUERY {if err := s.licenseService.IsFeatureEnabled(v1pb.PlanFeature_FEATURE_QUERY_POLICY); err != nil {return connect.NewError(connect.CodePermissionDenied, err)}@@ -599,13 +594,6 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(policy *v1pb.Policy) (streturn "", errors.Wrap(err, "failed to marshal masking exemption policy")}return string(payloadBytes), nil- case v1pb.PolicyType_DATA_SOURCE_QUERY:- payload := convertToDataSourceQueryPayload(policy.GetDataSourceQueryPolicy())- payloadBytes, err := protojson.Marshal(payload)- if err != nil {- return "", errors.Wrap(err, "failed to marshal data source query policy")- }- return string(payloadBytes), nildefault:}@@ -669,12 +657,6 @@ func convertToPolicy(policyMessage *store.PolicyMessage) (*v1pb.Policy, error) {policy.Policy = &v1pb.Policy_MaskingExemptionPolicy{MaskingExemptionPolicy: payload,}- case storepb.Policy_DATA_SOURCE_QUERY:- payload, err := convertToV1PBDataSourceQueryPolicy(policyMessage.Payload)- if err != nil {- return nil, err- }- policy.Policy = payloaddefault:}diff --git a/backend/api/v1/org_policy_service_converter.go b/backend/api/v1/org_policy_service_converter.goindex 305ab37e0e..cd86625f92 100644--- a/backend/api/v1/org_policy_service_converter.go+++ b/backend/api/v1/org_policy_service_converter.go@@ -168,22 +168,28 @@ func convertToV1PBQueryDataPolicy(payloadStr string) (*v1pb.Policy_QueryDataPoli}return &v1pb.Policy_QueryDataPolicy{QueryDataPolicy: &v1pb.QueryDataPolicy{- Timeout: payload.Timeout,- DisableExport: payload.DisableExport,- MaximumResultSize: payload.MaximumResultSize,- MaximumResultRows: payload.MaximumResultRows,- DisableCopyData: payload.DisableCopyData,+ Timeout: payload.Timeout,+ DisableExport: payload.DisableExport,+ MaximumResultSize: payload.MaximumResultSize,+ MaximumResultRows: payload.MaximumResultRows,+ DisableCopyData: payload.DisableCopyData,+ AdminDataSourceRestriction: v1pb.QueryDataPolicy_Restriction(payload.AdminDataSourceRestriction),+ DisallowDdl: payload.DisallowDdl,+ DisallowDml: payload.DisallowDml,},}, nil}func convertToQueryDataPolicyPayload(policy *v1pb.QueryDataPolicy) *storepb.QueryDataPolicy {return &storepb.QueryDataPolicy{- Timeout: policy.Timeout,- DisableExport: policy.DisableExport,- MaximumResultSize: policy.MaximumResultSize,- MaximumResultRows: policy.MaximumResultRows,- DisableCopyData: policy.DisableCopyData,+ Timeout: policy.Timeout,+ DisableExport: policy.DisableExport,+ MaximumResultSize: policy.MaximumResultSize,+ MaximumResultRows: policy.MaximumResultRows,+ DisableCopyData: policy.DisableCopyData,+ AdminDataSourceRestriction: storepb.QueryDataPolicy_Restriction(policy.AdminDataSourceRestriction),+ DisallowDdl: policy.DisallowDdl,+ DisallowDml: policy.DisallowDml,}}@@ -286,29 +292,6 @@ func convertToV1PBMaskingExemptionPolicyPayload(policy *storepb.MaskingExemption}}-func convertToV1PBDataSourceQueryPolicy(payloadStr string) (*v1pb.Policy_DataSourceQueryPolicy, error) {- payload := &storepb.DataSourceQueryPolicy{}- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(payloadStr), payload); err != nil {- return nil, err- }-- return &v1pb.Policy_DataSourceQueryPolicy{- DataSourceQueryPolicy: &v1pb.DataSourceQueryPolicy{- AdminDataSourceRestriction: v1pb.DataSourceQueryPolicy_Restriction(payload.AdminDataSourceRestriction),- DisallowDdl: payload.DisallowDdl,- DisallowDml: payload.DisallowDml,- },- }, nil-}--func convertToDataSourceQueryPayload(policy *v1pb.DataSourceQueryPolicy) *storepb.DataSourceQueryPolicy {- return &storepb.DataSourceQueryPolicy{- AdminDataSourceRestriction: storepb.DataSourceQueryPolicy_Restriction(policy.AdminDataSourceRestriction),- DisallowDdl: policy.DisallowDdl,- DisallowDml: policy.DisallowDml,- }-}-func convertV1PBToStorePBPolicyType(pType v1pb.PolicyType) (storepb.Policy_Type, error) {switch pType {case v1pb.PolicyType_ROLLOUT_POLICY:@@ -321,8 +304,6 @@ func convertV1PBToStorePBPolicyType(pType v1pb.PolicyType) (storepb.Policy_Type,return storepb.Policy_MASKING_EXEMPTION, nilcase v1pb.PolicyType_DATA_QUERY:return storepb.Policy_QUERY_DATA, nil- case v1pb.PolicyType_DATA_SOURCE_QUERY:- return storepb.Policy_DATA_SOURCE_QUERY, nildefault:}return storepb.Policy_TYPE_UNSPECIFIED, errors.Errorf("invalid policy type %v", pType)@@ -340,8 +321,6 @@ func convertStorePBToV1PBPolicyType(pType storepb.Policy_Type) v1pb.PolicyType {return v1pb.PolicyType_MASKING_EXEMPTIONcase storepb.Policy_QUERY_DATA:return v1pb.PolicyType_DATA_QUERY- case storepb.Policy_DATA_SOURCE_QUERY:- return v1pb.PolicyType_DATA_SOURCE_QUERYdefault:}return v1pb.PolicyType_POLICY_TYPE_UNSPECIFIEDdiff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex d4f4a258e9..883022c3bd 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -1772,10 +1772,10 @@ func checkAndGetDataSourceQueriable(return dataSource, nil}- dataSourceQueryPolicyType := storepb.Policy_DATA_SOURCE_QUERY+ queryDataPolicyType := storepb.Policy_QUERY_DATA// get data source restriction policy for environment- var envAdminDataSourceRestriction v1pb.DataSourceQueryPolicy_Restriction+ var envAdminDataSourceRestriction v1pb.QueryDataPolicy_RestrictioneffectiveEnvironmentID := ""if database.EffectiveEnvironmentID != nil {effectiveEnvironmentID = *database.EffectiveEnvironmentID@@ -1794,44 +1794,44 @@ func checkAndGetDataSourceQueriable(environmentPolicy, err := storeInstance.GetPolicy(ctx, &store.FindPolicyMessage{ResourceType: &environmentResourceType,Resource: &environmentResource,- Type: &dataSourceQueryPolicyType,+ Type: &queryDataPolicyType,})if err != nil {- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get environment data source policy with error: %v", err.Error()))+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get environment query data policy with error: %v", err.Error()))}if environmentPolicy != nil {- envPayload, err := convertToV1PBDataSourceQueryPolicy(environmentPolicy.Payload)+ envPayload, err := convertToV1PBQueryDataPolicy(environmentPolicy.Payload)if err != nil {- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert environment data source policy payload with error: %v", err.Error()))+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert environment query data policy payload with error: %v", err.Error()))}- envAdminDataSourceRestriction = envPayload.DataSourceQueryPolicy.GetAdminDataSourceRestriction()+ envAdminDataSourceRestriction = envPayload.QueryDataPolicy.GetAdminDataSourceRestriction()}}// get data source restriction policy for project- var projectAdminDataSourceRestriction v1pb.DataSourceQueryPolicy_Restriction+ var projectAdminDataSourceRestriction v1pb.QueryDataPolicy_RestrictionprojectResourceType := storepb.Policy_PROJECTprojectResource := common.FormatProject(database.ProjectID)projectPolicy, err := storeInstance.GetPolicy(ctx, &store.FindPolicyMessage{ResourceType: &projectResourceType,Resource: &projectResource,- Type: &dataSourceQueryPolicyType,+ Type: &queryDataPolicyType,})if err != nil {- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get project data source policy with error: %v", err.Error()))+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get project query data policy with error: %v", err.Error()))}if projectPolicy != nil {- projectPayload, err := convertToV1PBDataSourceQueryPolicy(projectPolicy.Payload)+ projectPayload, err := convertToV1PBQueryDataPolicy(projectPolicy.Payload)if err != nil {- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert project data source policy payload with error: %v", err.Error()))+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert project query data policy payload with error: %v", err.Error()))}- projectAdminDataSourceRestriction = projectPayload.DataSourceQueryPolicy.GetAdminDataSourceRestriction()+ projectAdminDataSourceRestriction = projectPayload.QueryDataPolicy.GetAdminDataSourceRestriction()}// If any of the policy is DISALLOW, then return false.- if envAdminDataSourceRestriction == v1pb.DataSourceQueryPolicy_DISALLOW || projectAdminDataSourceRestriction == v1pb.DataSourceQueryPolicy_DISALLOW {+ if envAdminDataSourceRestriction == v1pb.QueryDataPolicy_DISALLOW || projectAdminDataSourceRestriction == v1pb.QueryDataPolicy_DISALLOW {return nil, connect.NewError(connect.CodePermissionDenied, errors.Errorf("data source %q is not queryable", dataSourceID))- } else if envAdminDataSourceRestriction == v1pb.DataSourceQueryPolicy_FALLBACK || projectAdminDataSourceRestriction == v1pb.DataSourceQueryPolicy_FALLBACK {+ } else if envAdminDataSourceRestriction == v1pb.QueryDataPolicy_FALLBACK || projectAdminDataSourceRestriction == v1pb.QueryDataPolicy_FALLBACK {// If there is any read-only data source, then return false.if ds := GetQueriableDataSource(instance); ds != nil && ds.Type == storepb.DataSourceType_READ_ONLY {return nil, connect.NewError(connect.CodePermissionDenied, errors.Errorf("data source %q is not queryable", dataSourceID))@@ -1864,8 +1864,8 @@ func checkDataSourceQueryPolicy(ctx context.Context, storeInstance *store.Store,}resourceType := storepb.Policy_ENVIRONMENTenvironmentResource := common.FormatEnvironment(environment.Id)- policyType := storepb.Policy_DATA_SOURCE_QUERY- dataSourceQueryPolicy, err := storeInstance.GetPolicy(ctx, &store.FindPolicyMessage{+ policyType := storepb.Policy_QUERY_DATA+ queryDataPolicy, err := storeInstance.GetPolicy(ctx, &store.FindPolicyMessage{ResourceType: &resourceType,Resource: &environmentResource,Type: &policyType,@@ -1873,10 +1873,10 @@ func checkDataSourceQueryPolicy(ctx context.Context, storeInstance *store.Store,if err != nil {return err}- if dataSourceQueryPolicy != nil {- policy := &v1pb.DataSourceQueryPolicy{}- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(dataSourceQueryPolicy.Payload), policy); err != nil {- return connect.NewError(connect.CodeInternal, errors.Errorf("failed to unmarshal data source query policy payload"))+ if queryDataPolicy != nil {+ policy := &v1pb.QueryDataPolicy{}+ if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(queryDataPolicy.Payload), policy); err != nil {+ return connect.NewError(connect.CodeInternal, errors.Errorf("failed to unmarshal query data policy payload"))}switch statementTp {case parserbase.DDL:diff --git a/backend/generated-go/store/policy.pb.go b/backend/generated-go/store/policy.pb.goindex 6337a14d50..68f918c3d8 100644--- a/backend/generated-go/store/policy.pb.go+++ b/backend/generated-go/store/policy.pb.go@@ -33,7 +33,6 @@ const (Policy_MASKING_RULE Policy_Type = 4Policy_IAM Policy_Type = 5Policy_TAG Policy_Type = 6- Policy_DATA_SOURCE_QUERY Policy_Type = 7)// Enum value maps for Policy_Type.@@ -46,7 +45,6 @@ var (4: "MASKING_RULE",5: "IAM",6: "TAG",- 7: "DATA_SOURCE_QUERY",}Policy_Type_value = map[string]int32{"TYPE_UNSPECIFIED": 0,@@ -56,7 +54,6 @@ var ("MASKING_RULE": 4,"IAM": 5,"TAG": 6,- "DATA_SOURCE_QUERY": 7,})@@ -139,55 +136,55 @@ func (Policy_Resource) EnumDescriptor() ([]byte, []int) {return file_store_policy_proto_rawDescGZIP(), []int{0, 1}}-type DataSourceQueryPolicy_Restriction int32+type QueryDataPolicy_Restriction int32const (- DataSourceQueryPolicy_RESTRICTION_UNSPECIFIED DataSourceQueryPolicy_Restriction = 0+ QueryDataPolicy_RESTRICTION_UNSPECIFIED QueryDataPolicy_Restriction = 0// Allow to query admin data sources when there is no read-only data source.- DataSourceQueryPolicy_FALLBACK DataSourceQueryPolicy_Restriction = 1+ QueryDataPolicy_FALLBACK QueryDataPolicy_Restriction = 1// Disallow to query admin data sources.- DataSourceQueryPolicy_DISALLOW DataSourceQueryPolicy_Restriction = 2+ QueryDataPolicy_DISALLOW QueryDataPolicy_Restriction = 2)-// Enum value maps for DataSourceQueryPolicy_Restriction.+// Enum value maps for QueryDataPolicy_Restriction.var (- DataSourceQueryPolicy_Restriction_name = map[int32]string{+ QueryDataPolicy_Restriction_name = map[int32]string{0: "RESTRICTION_UNSPECIFIED",1: "FALLBACK",2: "DISALLOW",}- DataSourceQueryPolicy_Restriction_value = map[string]int32{+ QueryDataPolicy_Restriction_value = map[string]int32{"RESTRICTION_UNSPECIFIED": 0,"FALLBACK": 1,"DISALLOW": 2,})-func (x DataSourceQueryPolicy_Restriction) Enum() *DataSourceQueryPolicy_Restriction {- p := new(DataSourceQueryPolicy_Restriction)+func (x QueryDataPolicy_Restriction) Enum() *QueryDataPolicy_Restriction {+ p := new(QueryDataPolicy_Restriction)*p = xreturn p}-func (x DataSourceQueryPolicy_Restriction) String() string {+func (x QueryDataPolicy_Restriction) String() string {return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))}-func (DataSourceQueryPolicy_Restriction) Descriptor() protoreflect.EnumDescriptor {+func (QueryDataPolicy_Restriction) Descriptor() protoreflect.EnumDescriptor {return file_store_policy_proto_enumTypes[2].Descriptor()}-func (DataSourceQueryPolicy_Restriction) Type() protoreflect.EnumType {+func (QueryDataPolicy_Restriction) Type() protoreflect.EnumType {return &file_store_policy_proto_enumTypes[2]}-func (x DataSourceQueryPolicy_Restriction) Number() protoreflect.EnumNumber {+func (x QueryDataPolicy_Restriction) Number() protoreflect.EnumNumber {return protoreflect.EnumNumber(x)}-// Deprecated: Use DataSourceQueryPolicy_Restriction.Descriptor instead.-func (DataSourceQueryPolicy_Restriction) EnumDescriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{8, 0}+// Deprecated: Use QueryDataPolicy_Restriction.Descriptor instead.+func (QueryDataPolicy_Restriction) EnumDescriptor() ([]byte, []int) {+ return file_store_policy_proto_rawDescGZIP(), []int{7, 0}}type Policy struct {@@ -542,8 +539,14 @@ type QueryDataPolicy struct {MaximumResultRows int32 `protobuf:"varint,4,opt,name=maximum_result_rows,json=maximumResultRows,proto3" json:"maximum_result_rows,omitempty"`// Disable copying data.DisableCopyData bool `protobuf:"varint,5,opt,name=disable_copy_data,json=disableCopyData,proto3" json:"disable_copy_data,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache+ // Restriction for admin data source queries.+ AdminDataSourceRestriction QueryDataPolicy_Restriction `protobuf:"varint,6,opt,name=admin_data_source_restriction,json=adminDataSourceRestriction,proto3,enum=bytebase.store.QueryDataPolicy_Restriction" json:"admin_data_source_restriction,omitempty"`+ // Disallow running DDL statements in the SQL editor.+ DisallowDdl bool `protobuf:"varint,7,opt,name=disallow_ddl,json=disallowDdl,proto3" json:"disallow_ddl,omitempty"`+ // Disallow running DML statements in the SQL editor.+ DisallowDml bool `protobuf:"varint,8,opt,name=disallow_dml,json=disallowDml,proto3" json:"disallow_dml,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *QueryDataPolicy) Reset() {@@ -611,63 +614,21 @@ func (x *QueryDataPolicy) GetDisableCopyData() bool {return false}-// DataSourceQueryPolicy is the policy configuration for running statements in the SQL editor.-type DataSourceQueryPolicy struct {- state protoimpl.MessageState `protogen:"open.v1"`- AdminDataSourceRestriction DataSourceQueryPolicy_Restriction `protobuf:"varint,1,opt,name=admin_data_source_restriction,json=adminDataSourceRestriction,proto3,enum=bytebase.store.DataSourceQueryPolicy_Restriction" json:"admin_data_source_restriction,omitempty"`- // Disallow running DDL statements in the SQL editor.- DisallowDdl bool `protobuf:"varint,2,opt,name=disallow_ddl,json=disallowDdl,proto3" json:"disallow_ddl,omitempty"`- // Disallow running DML statements in the SQL editor.- DisallowDml bool `protobuf:"varint,3,opt,name=disallow_dml,json=disallowDml,proto3" json:"disallow_dml,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *DataSourceQueryPolicy) Reset() {- *x = DataSourceQueryPolicy{}- mi := &file_store_policy_proto_msgTypes[8]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *DataSourceQueryPolicy) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DataSourceQueryPolicy) ProtoMessage() {}--func (x *DataSourceQueryPolicy) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[8]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DataSourceQueryPolicy.ProtoReflect.Descriptor instead.-func (*DataSourceQueryPolicy) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{8}-}--func (x *DataSourceQueryPolicy) GetAdminDataSourceRestriction() DataSourceQueryPolicy_Restriction {+func (x *QueryDataPolicy) GetAdminDataSourceRestriction() QueryDataPolicy_Restriction {if x != nil {return x.AdminDataSourceRestriction}- return DataSourceQueryPolicy_RESTRICTION_UNSPECIFIED+ return QueryDataPolicy_RESTRICTION_UNSPECIFIED}-func (x *DataSourceQueryPolicy) GetDisallowDdl() bool {+func (x *QueryDataPolicy) GetDisallowDdl() bool {if x != nil {return x.DisallowDdl}return false}-func (x *DataSourceQueryPolicy) GetDisallowDml() bool {+func (x *QueryDataPolicy) GetDisallowDml() bool {if x != nil {return x.DisallowDml}@@ -703,7 +664,7 @@ type MaskingExemptionPolicy_Exemption struct {func (x *MaskingExemptionPolicy_Exemption) Reset() {*x = MaskingExemptionPolicy_Exemption{}- mi := &file_store_policy_proto_msgTypes[9]+ mi := &file_store_policy_proto_msgTypes[8]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -715,7 +676,7 @@ func (x *MaskingExemptionPolicy_Exemption) String() string {func (*MaskingExemptionPolicy_Exemption) ProtoMessage() {}func (x *MaskingExemptionPolicy_Exemption) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[9]+ mi := &file_store_policy_proto_msgTypes[8]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -757,7 +718,7 @@ type MaskingRulePolicy_MaskingRule struct {func (x *MaskingRulePolicy_MaskingRule) Reset() {*x = MaskingRulePolicy_MaskingRule{}- mi := &file_store_policy_proto_msgTypes[10]+ mi := &file_store_policy_proto_msgTypes[9]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -769,7 +730,7 @@ func (x *MaskingRulePolicy_MaskingRule) String() string {func (*MaskingRulePolicy_MaskingRule) ProtoMessage() {}func (x *MaskingRulePolicy_MaskingRule) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[10]+ mi := &file_store_policy_proto_msgTypes[9]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -810,8 +771,8 @@ var File_store_policy_proto protoreflect.FileDescriptorconst file_store_policy_proto_rawDesc = "" +"\n" +- "\x12store/policy.proto\x12\x0ebytebase.store\x1a\x1egoogle/protobuf/duration.proto\x1a\x16google/type/expr.proto\"\xe9\x01\n" +- "\x06Policy\"\x8b\x01\n" ++ "\x12store/policy.proto\x12\x0ebytebase.store\x1a\x1egoogle/protobuf/duration.proto\x1a\x16google/type/expr.proto\"\xd1\x01\n" ++ "\x06Policy\"t\n" +"\x04Type\x12\x14\n" +"\x10TYPE_UNSPECIFIED\x10\x00\x12\v\n" +"\aROLLOUT\x10\x01\x12\x15\n" +@@ -820,8 +781,7 @@ const file_store_policy_proto_rawDesc = "" +"QUERY_DATA\x10\x03\x12\x10\n" +"\fMASKING_RULE\x10\x04\x12\a\n" +"\x03IAM\x10\x05\x12\a\n" +- "\x03TAG\x10\x06\x12\x15\n" +- "\x11DATA_SOURCE_QUERY\x10\a\"Q\n" ++ "\x03TAG\x10\x06\"Q\n" +"\bResource\x12\x18\n" +"\x14RESOURCE_UNSPECIFIED\x10\x00\x12\r\n" +"\tWORKSPACE\x10\x01\x12\x0f\n" +@@ -853,17 +813,16 @@ const file_store_policy_proto_rawDesc = "" +"\amembers\x18\x02 \x03(\tR\amembers\x12/\n" +"\tcondition\x18\x03 \x01(\v2\x11.google.type.ExprR\tcondition\"@\n" +"\tIamPolicy\x123\n" +- "\bbindings\x18\x01 \x03(\v2\x17.bytebase.store.BindingR\bbindings\"\xf9\x01\n" ++ "\bbindings\x18\x01 \x03(\v2\x17.bytebase.store.BindingR\bbindings\"\xf7\x03\n" +"\x0fQueryDataPolicy\x123\n" +"\atimeout\x18\x01 \x01(\v2\x19.google.protobuf.DurationR\atimeout\x12%\n" +"\x0edisable_export\x18\x02 \x01(\bR\rdisableExport\x12.\n" +"\x13maximum_result_size\x18\x03 \x01(\x03R\x11maximumResultSize\x12.\n" +"\x13maximum_result_rows\x18\x04 \x01(\x05R\x11maximumResultRows\x12*\n" +- "\x11disable_copy_data\x18\x05 \x01(\bR\x0fdisableCopyData\"\x9b\x02\n" +- "\x15DataSourceQueryPolicy\x12t\n" +- "\x1dadmin_data_source_restriction\x18\x01 \x01(\x0e21.bytebase.store.DataSourceQueryPolicy.RestrictionR\x1aadminDataSourceRestriction\x12!\n" +- "\fdisallow_ddl\x18\x02 \x01(\bR\vdisallowDdl\x12!\n" +- "\fdisallow_dml\x18\x03 \x01(\bR\vdisallowDml\"F\n" ++ "\x11disable_copy_data\x18\x05 \x01(\bR\x0fdisableCopyData\x12n\n" ++ "\x1dadmin_data_source_restriction\x18\x06 \x01(\x0e2+.bytebase.store.QueryDataPolicy.RestrictionR\x1aadminDataSourceRestriction\x12!\n" ++ "\fdisallow_ddl\x18\a \x01(\bR\vdisallowDdl\x12!\n" ++ "\fdisallow_dml\x18\b \x01(\bR\vdisallowDml\"F\n" +"\vRestriction\x12\x1b\n" +"\x17RESTRICTION_UNSPECIFIED\x10\x00\x12\f\n" +"\bFALLBACK\x10\x01\x12\f\n" +@@ -883,11 +842,11 @@ func file_store_policy_proto_rawDescGZIP() []byte {}var file_store_policy_proto_enumTypes = make([]protoimpl.EnumInfo, 3)-var file_store_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 12)+var file_store_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 11)var file_store_policy_proto_goTypes = []any{(Policy_Type)(0), // 0: bytebase.store.Policy.Type(Policy_Resource)(0), // 1: bytebase.store.Policy.Resource- (DataSourceQueryPolicy_Restriction)(0), // 2: bytebase.store.DataSourceQueryPolicy.Restriction+ (QueryDataPolicy_Restriction)(0), // 2: bytebase.store.QueryDataPolicy.Restriction(*Policy)(nil), // 3: bytebase.store.Policy(*RolloutPolicy)(nil), // 4: bytebase.store.RolloutPolicy(*MaskingExemptionPolicy)(nil), // 5: bytebase.store.MaskingExemptionPolicy@@ -896,23 +855,22 @@ var file_store_policy_proto_goTypes = []any{(*Binding)(nil), // 8: bytebase.store.Binding(*IamPolicy)(nil), // 9: bytebase.store.IamPolicy(*QueryDataPolicy)(nil), // 10: bytebase.store.QueryDataPolicy- (*DataSourceQueryPolicy)(nil), // 11: bytebase.store.DataSourceQueryPolicy- (*MaskingExemptionPolicy_Exemption)(nil), // 12: bytebase.store.MaskingExemptionPolicy.Exemption- (*MaskingRulePolicy_MaskingRule)(nil), // 13: bytebase.store.MaskingRulePolicy.MaskingRule- nil, // 14: bytebase.store.TagPolicy.TagsEntry- (*expr.Expr)(nil), // 15: google.type.Expr- (*durationpb.Duration)(nil), // 16: google.protobuf.Duration+ (*MaskingExemptionPolicy_Exemption)(nil), // 11: bytebase.store.MaskingExemptionPolicy.Exemption+ (*MaskingRulePolicy_MaskingRule)(nil), // 12: bytebase.store.MaskingRulePolicy.MaskingRule+ nil, // 13: bytebase.store.TagPolicy.TagsEntry+ (*expr.Expr)(nil), // 14: google.type.Expr+ (*durationpb.Duration)(nil), // 15: google.protobuf.Duration}var file_store_policy_proto_depIdxs = []int32{- 12, // 0: bytebase.store.MaskingExemptionPolicy.exemptions:type_name -> bytebase.store.MaskingExemptionPolicy.Exemption- 13, // 1: bytebase.store.MaskingRulePolicy.rules:type_name -> bytebase.store.MaskingRulePolicy.MaskingRule- 14, // 2: bytebase.store.TagPolicy.tags:type_name -> bytebase.store.TagPolicy.TagsEntry- 15, // 3: bytebase.store.Binding.condition:type_name -> google.type.Expr+ 11, // 0: bytebase.store.MaskingExemptionPolicy.exemptions:type_name -> bytebase.store.MaskingExemptionPolicy.Exemption+ 12, // 1: bytebase.store.MaskingRulePolicy.rules:type_name -> bytebase.store.MaskingRulePolicy.MaskingRule+ 13, // 2: bytebase.store.TagPolicy.tags:type_name -> bytebase.store.TagPolicy.TagsEntry+ 14, // 3: bytebase.store.Binding.condition:type_name -> google.type.Expr8, // 4: bytebase.store.IamPolicy.bindings:type_name -> bytebase.store.Binding- 16, // 5: bytebase.store.QueryDataPolicy.timeout:type_name -> google.protobuf.Duration- 2, // 6: bytebase.store.DataSourceQueryPolicy.admin_data_source_restriction:type_name -> bytebase.store.DataSourceQueryPolicy.Restriction- 15, // 7: bytebase.store.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr- 15, // 8: bytebase.store.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr+ 15, // 5: bytebase.store.QueryDataPolicy.timeout:type_name -> google.protobuf.Duration+ 2, // 6: bytebase.store.QueryDataPolicy.admin_data_source_restriction:type_name -> bytebase.store.QueryDataPolicy.Restriction+ 14, // 7: bytebase.store.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr+ 14, // 8: bytebase.store.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr9, // [9:9] is the sub-list for method output_type9, // [9:9] is the sub-list for method input_type9, // [9:9] is the sub-list for extension type_name@@ -931,7 +889,7 @@ func file_store_policy_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_policy_proto_rawDesc), len(file_store_policy_proto_rawDesc)),NumEnums: 3,- NumMessages: 12,+ NumMessages: 11,NumExtensions: 0,NumServices: 0,},diff --git a/backend/generated-go/store/policy_equal.pb.go b/backend/generated-go/store/policy_equal.pb.goindex 25166c1312..03e4016f4e 100644--- a/backend/generated-go/store/policy_equal.pb.go+++ b/backend/generated-go/store/policy_equal.pb.go@@ -207,16 +207,6 @@ func (x *QueryDataPolicy) Equal(y *QueryDataPolicy) bool {if x.DisableCopyData != y.DisableCopyData {return false}- return true-}--func (x *DataSourceQueryPolicy) Equal(y *DataSourceQueryPolicy) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }if x.AdminDataSourceRestriction != y.AdminDataSourceRestriction {return false}diff --git a/backend/generated-go/v1/org_policy_service.pb.go b/backend/generated-go/v1/org_policy_service.pb.goindex 5d4e477fb5..c2f16a4346 100644--- a/backend/generated-go/v1/org_policy_service.pb.go+++ b/backend/generated-go/v1/org_policy_service.pb.go@@ -40,8 +40,6 @@ const (PolicyType_ROLLOUT_POLICY PolicyType = 3// Resource tag policy.PolicyType_TAG PolicyType = 4- // Data source query restrictions policy.- PolicyType_DATA_SOURCE_QUERY PolicyType = 5// Query data access policy.PolicyType_DATA_QUERY PolicyType = 6)@@ -54,7 +52,6 @@ var (2: "MASKING_EXEMPTION",3: "ROLLOUT_POLICY",4: "TAG",- 5: "DATA_SOURCE_QUERY",6: "DATA_QUERY",}PolicyType_value = map[string]int32{@@ -63,7 +60,6 @@ var ("MASKING_EXEMPTION": 2,"ROLLOUT_POLICY": 3,"TAG": 4,- "DATA_SOURCE_QUERY": 5,"DATA_QUERY": 6,})@@ -153,56 +149,56 @@ func (PolicyResourceType) EnumDescriptor() ([]byte, []int) {}// Restriction level for admin data source access.-type DataSourceQueryPolicy_Restriction int32+type QueryDataPolicy_Restriction int32const (// Unspecified restriction.- DataSourceQueryPolicy_RESTRICTION_UNSPECIFIED DataSourceQueryPolicy_Restriction = 0+ QueryDataPolicy_RESTRICTION_UNSPECIFIED QueryDataPolicy_Restriction = 0// Allow querying admin data sources when there is no read-only data source.- DataSourceQueryPolicy_FALLBACK DataSourceQueryPolicy_Restriction = 1+ QueryDataPolicy_FALLBACK QueryDataPolicy_Restriction = 1// Disallow querying admin data sources.- DataSourceQueryPolicy_DISALLOW DataSourceQueryPolicy_Restriction = 2+ QueryDataPolicy_DISALLOW QueryDataPolicy_Restriction = 2)-// Enum value maps for DataSourceQueryPolicy_Restriction.+// Enum value maps for QueryDataPolicy_Restriction.var (- DataSourceQueryPolicy_Restriction_name = map[int32]string{+ QueryDataPolicy_Restriction_name = map[int32]string{0: "RESTRICTION_UNSPECIFIED",1: "FALLBACK",2: "DISALLOW",}- DataSourceQueryPolicy_Restriction_value = map[string]int32{+ QueryDataPolicy_Restriction_value = map[string]int32{"RESTRICTION_UNSPECIFIED": 0,"FALLBACK": 1,"DISALLOW": 2,})-func (x DataSourceQueryPolicy_Restriction) Enum() *DataSourceQueryPolicy_Restriction {- p := new(DataSourceQueryPolicy_Restriction)+func (x QueryDataPolicy_Restriction) Enum() *QueryDataPolicy_Restriction {+ p := new(QueryDataPolicy_Restriction)*p = xreturn p}-func (x DataSourceQueryPolicy_Restriction) String() string {+func (x QueryDataPolicy_Restriction) String() string {return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))}-func (DataSourceQueryPolicy_Restriction) Descriptor() protoreflect.EnumDescriptor {+func (QueryDataPolicy_Restriction) Descriptor() protoreflect.EnumDescriptor {return file_v1_org_policy_service_proto_enumTypes[2].Descriptor()}-func (DataSourceQueryPolicy_Restriction) Type() protoreflect.EnumType {+func (QueryDataPolicy_Restriction) Type() protoreflect.EnumType {return &file_v1_org_policy_service_proto_enumTypes[2]}-func (x DataSourceQueryPolicy_Restriction) Number() protoreflect.EnumNumber {+func (x QueryDataPolicy_Restriction) Number() protoreflect.EnumNumber {return protoreflect.EnumNumber(x)}-// Deprecated: Use DataSourceQueryPolicy_Restriction.Descriptor instead.-func (DataSourceQueryPolicy_Restriction) EnumDescriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{12, 0}+// Deprecated: Use QueryDataPolicy_Restriction.Descriptor instead.+func (QueryDataPolicy_Restriction) EnumDescriptor() ([]byte, []int) {+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{8, 0}}type CreatePolicyRequest struct {@@ -569,7 +565,6 @@ type Policy struct {// *Policy_MaskingRulePolicy// *Policy_MaskingExemptionPolicy// *Policy_TagPolicy- // *Policy_DataSourceQueryPolicy// *Policy_QueryDataPolicyPolicy isPolicy_Policy `protobuf_oneof:"policy"`// Whether the policy is enforced.@@ -674,15 +669,6 @@ func (x *Policy) GetTagPolicy() *TagPolicy {return nil}-func (x *Policy) GetDataSourceQueryPolicy() *DataSourceQueryPolicy {- if x != nil {- if x, ok := x.Policy.(*Policy_DataSourceQueryPolicy); ok {- return x.DataSourceQueryPolicy- }- }- return nil-}-func (x *Policy) GetQueryDataPolicy() *QueryDataPolicy {if x != nil {if x, ok := x.Policy.(*Policy_QueryDataPolicy); ok {@@ -726,10 +712,6 @@ type Policy_TagPolicy struct {TagPolicy *TagPolicy `protobuf:"bytes,7,opt,name=tag_policy,json=tagPolicy,proto3,oneof"`}-type Policy_DataSourceQueryPolicy struct {- DataSourceQueryPolicy *DataSourceQueryPolicy `protobuf:"bytes,8,opt,name=data_source_query_policy,json=dataSourceQueryPolicy,proto3,oneof"`-}-type Policy_QueryDataPolicy struct {QueryDataPolicy *QueryDataPolicy `protobuf:"bytes,9,opt,name=query_data_policy,json=queryDataPolicy,proto3,oneof"`}@@ -742,8 +724,6 @@ func (*Policy_MaskingExemptionPolicy) isPolicy_Policy() {}func (*Policy_TagPolicy) isPolicy_Policy() {}-func (*Policy_DataSourceQueryPolicy) isPolicy_Policy() {}-func (*Policy_QueryDataPolicy) isPolicy_Policy() {}// Rollout policy configuration.@@ -816,8 +796,14 @@ type QueryDataPolicy struct {MaximumResultRows int32 `protobuf:"varint,4,opt,name=maximum_result_rows,json=maximumResultRows,proto3" json:"maximum_result_rows,omitempty"`// Disable copying query results.DisableCopyData bool `protobuf:"varint,5,opt,name=disable_copy_data,json=disableCopyData,proto3" json:"disable_copy_data,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache+ // Restriction for admin data source queries.+ AdminDataSourceRestriction QueryDataPolicy_Restriction `protobuf:"varint,6,opt,name=admin_data_source_restriction,json=adminDataSourceRestriction,proto3,enum=bytebase.v1.QueryDataPolicy_Restriction" json:"admin_data_source_restriction,omitempty"`+ // Disallow running DDL statements in the SQL editor.+ DisallowDdl bool `protobuf:"varint,7,opt,name=disallow_ddl,json=disallowDdl,proto3" json:"disallow_ddl,omitempty"`+ // Disallow running DML statements in the SQL editor.+ DisallowDml bool `protobuf:"varint,8,opt,name=disallow_dml,json=disallowDml,proto3" json:"disallow_dml,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *QueryDataPolicy) Reset() {@@ -885,6 +871,27 @@ func (x *QueryDataPolicy) GetDisableCopyData() bool {return false}+func (x *QueryDataPolicy) GetAdminDataSourceRestriction() QueryDataPolicy_Restriction {+ if x != nil {+ return x.AdminDataSourceRestriction+ }+ return QueryDataPolicy_RESTRICTION_UNSPECIFIED+}++func (x *QueryDataPolicy) GetDisallowDdl() bool {+ if x != nil {+ return x.DisallowDdl+ }+ return false+}++func (x *QueryDataPolicy) GetDisallowDml() bool {+ if x != nil {+ return x.DisallowDml+ }+ return false+}+// MaskingExemptionPolicy is the allowlist of users who can access sensitive data.type MaskingExemptionPolicy struct {state protoimpl.MessageState `protogen:"open.v1"`@@ -1023,70 +1030,6 @@ func (x *TagPolicy) GetTags() map[string]string {return nil}-// Policy for controlling which data sources can be queried in the SQL editor.-type DataSourceQueryPolicy struct {- state protoimpl.MessageState `protogen:"open.v1"`- // Restriction for admin data source queries.- AdminDataSourceRestriction DataSourceQueryPolicy_Restriction `protobuf:"varint,1,opt,name=admin_data_source_restriction,json=adminDataSourceRestriction,proto3,enum=bytebase.v1.DataSourceQueryPolicy_Restriction" json:"admin_data_source_restriction,omitempty"`- // Disallow running DDL statements in the SQL editor.- DisallowDdl bool `protobuf:"varint,2,opt,name=disallow_ddl,json=disallowDdl,proto3" json:"disallow_ddl,omitempty"`- // Disallow running DML statements in the SQL editor.- DisallowDml bool `protobuf:"varint,3,opt,name=disallow_dml,json=disallowDml,proto3" json:"disallow_dml,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache-}--func (x *DataSourceQueryPolicy) Reset() {- *x = DataSourceQueryPolicy{}- mi := &file_v1_org_policy_service_proto_msgTypes[12]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *DataSourceQueryPolicy) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DataSourceQueryPolicy) ProtoMessage() {}--func (x *DataSourceQueryPolicy) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[12]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DataSourceQueryPolicy.ProtoReflect.Descriptor instead.-func (*DataSourceQueryPolicy) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{12}-}--func (x *DataSourceQueryPolicy) GetAdminDataSourceRestriction() DataSourceQueryPolicy_Restriction {- if x != nil {- return x.AdminDataSourceRestriction- }- return DataSourceQueryPolicy_RESTRICTION_UNSPECIFIED-}--func (x *DataSourceQueryPolicy) GetDisallowDdl() bool {- if x != nil {- return x.DisallowDdl- }- return false-}--func (x *DataSourceQueryPolicy) GetDisallowDml() bool {- if x != nil {- return x.DisallowDml- }- return false-}-type MaskingExemptionPolicy_Exemption struct {state protoimpl.MessageState `protogen:"open.v1"`// Specifies the principals who are exempt from masking.@@ -1116,7 +1059,7 @@ type MaskingExemptionPolicy_Exemption struct {func (x *MaskingExemptionPolicy_Exemption) Reset() {*x = MaskingExemptionPolicy_Exemption{}- mi := &file_v1_org_policy_service_proto_msgTypes[13]+ mi := &file_v1_org_policy_service_proto_msgTypes[12]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1128,7 +1071,7 @@ func (x *MaskingExemptionPolicy_Exemption) String() string {func (*MaskingExemptionPolicy_Exemption) ProtoMessage() {}func (x *MaskingExemptionPolicy_Exemption) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[13]+ mi := &file_v1_org_policy_service_proto_msgTypes[12]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1195,7 +1138,7 @@ type MaskingRulePolicy_MaskingRule struct {func (x *MaskingRulePolicy_MaskingRule) Reset() {*x = MaskingRulePolicy_MaskingRule{}- mi := &file_v1_org_policy_service_proto_msgTypes[14]+ mi := &file_v1_org_policy_service_proto_msgTypes[13]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1207,7 +1150,7 @@ func (x *MaskingRulePolicy_MaskingRule) String() string {func (*MaskingRulePolicy_MaskingRule) ProtoMessage() {}func (x *MaskingRulePolicy_MaskingRule) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[14]+ mi := &file_v1_org_policy_service_proto_msgTypes[13]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1271,7 +1214,7 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\fshow_deleted\x18\x03 \x01(\bR\vshowDeletedB\x0e\n" +"\f_policy_type\"G\n" +"\x14ListPoliciesResponse\x12/\n" +- "\bpolicies\x18\x01 \x03(\v2\x13.bytebase.v1.PolicyR\bpolicies\"\xac\a\n" ++ "\bpolicies\x18\x01 \x03(\v2\x13.bytebase.v1.PolicyR\bpolicies\"\xcd\x06\n" +"\x06Policy\x12\x12\n" +"\x04name\x18\x01 \x01(\tR\x04name\x12.\n" +"\x13inherit_from_parent\x18\x02 \x01(\bR\x11inheritFromParent\x12+\n" +@@ -1280,8 +1223,7 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\x13masking_rule_policy\x18\x05 \x01(\v2\x1e.bytebase.v1.MaskingRulePolicyH\x00R\x11maskingRulePolicy\x12_\n" +"\x18masking_exemption_policy\x18\x06 \x01(\v2#.bytebase.v1.MaskingExemptionPolicyH\x00R\x16maskingExemptionPolicy\x127\n" +"\n" +- "tag_policy\x18\a \x01(\v2\x16.bytebase.v1.TagPolicyH\x00R\ttagPolicy\x12]\n" +- "\x18data_source_query_policy\x18\b \x01(\v2\".bytebase.v1.DataSourceQueryPolicyH\x00R\x15dataSourceQueryPolicy\x12J\n" ++ "tag_policy\x18\a \x01(\v2\x16.bytebase.v1.TagPolicyH\x00R\ttagPolicy\x12J\n" +"\x11query_data_policy\x18\t \x01(\v2\x1c.bytebase.v1.QueryDataPolicyH\x00R\x0fqueryDataPolicy\x12\x18\n" +"\aenforce\x18\n" +" \x01(\bR\aenforce\x12I\n" +@@ -1290,13 +1232,20 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\x06policy\"C\n" +"\rRolloutPolicy\x12\x1c\n" +"\tautomatic\x18\x01 \x01(\bR\tautomatic\x12\x14\n" +- "\x05roles\x18\x02 \x03(\tR\x05roles\"\xf9\x01\n" ++ "\x05roles\x18\x02 \x03(\tR\x05roles\"\xf4\x03\n" +"\x0fQueryDataPolicy\x123\n" +"\atimeout\x18\x01 \x01(\v2\x19.google.protobuf.DurationR\atimeout\x12%\n" +"\x0edisable_export\x18\x02 \x01(\bR\rdisableExport\x12.\n" +"\x13maximum_result_size\x18\x03 \x01(\x03R\x11maximumResultSize\x12.\n" +"\x13maximum_result_rows\x18\x04 \x01(\x05R\x11maximumResultRows\x12*\n" +- "\x11disable_copy_data\x18\x05 \x01(\bR\x0fdisableCopyData\"\xbf\x01\n" ++ "\x11disable_copy_data\x18\x05 \x01(\bR\x0fdisableCopyData\x12k\n" ++ "\x1dadmin_data_source_restriction\x18\x06 \x01(\x0e2(.bytebase.v1.QueryDataPolicy.RestrictionR\x1aadminDataSourceRestriction\x12!\n" ++ "\fdisallow_ddl\x18\a \x01(\bR\vdisallowDdl\x12!\n" ++ "\fdisallow_dml\x18\b \x01(\bR\vdisallowDml\"F\n" ++ "\vRestriction\x12\x1b\n" ++ "\x17RESTRICTION_UNSPECIFIED\x10\x00\x12\f\n" ++ "\bFALLBACK\x10\x01\x12\f\n" ++ "\bDISALLOW\x10\x02\"\xbf\x01\n" +"\x16MaskingExemptionPolicy\x12M\n" +"\n" +"exemptions\x18\x01 \x03(\v2-.bytebase.v1.MaskingExemptionPolicy.ExemptionR\n" +@@ -1314,23 +1263,14 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\x04tags\x18\x01 \x03(\v2 .bytebase.v1.TagPolicy.TagsEntryR\x04tags\x1a7\n" +"\tTagsEntry\x12\x10\n" +"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +- "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x98\x02\n" +- "\x15DataSourceQueryPolicy\x12q\n" +- "\x1dadmin_data_source_restriction\x18\x01 \x01(\x0e2..bytebase.v1.DataSourceQueryPolicy.RestrictionR\x1aadminDataSourceRestriction\x12!\n" +- "\fdisallow_ddl\x18\x02 \x01(\bR\vdisallowDdl\x12!\n" +- "\fdisallow_dml\x18\x03 \x01(\bR\vdisallowDml\"F\n" +- "\vRestriction\x12\x1b\n" +- "\x17RESTRICTION_UNSPECIFIED\x10\x00\x12\f\n" +- "\bFALLBACK\x10\x01\x12\f\n" +- "\bDISALLOW\x10\x02*\x96\x01\n" ++ "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01*\x7f\n" +"\n" +"PolicyType\x12\x1b\n" +"\x17POLICY_TYPE_UNSPECIFIED\x10\x00\x12\x10\n" +"\fMASKING_RULE\x10\x01\x12\x15\n" +"\x11MASKING_EXEMPTION\x10\x02\x12\x12\n" +"\x0eROLLOUT_POLICY\x10\x03\x12\a\n" +- "\x03TAG\x10\x04\x12\x15\n" +- "\x11DATA_SOURCE_QUERY\x10\x05\x12\x0e\n" ++ "\x03TAG\x10\x04\x12\x0e\n" +"\n" +"DATA_QUERY\x10\x06*`\n" +"\x12PolicyResourceType\x12\x1d\n" +@@ -1359,11 +1299,11 @@ func file_v1_org_policy_service_proto_rawDescGZIP() []byte {}var file_v1_org_policy_service_proto_enumTypes = make([]protoimpl.EnumInfo, 3)-var file_v1_org_policy_service_proto_msgTypes = make([]protoimpl.MessageInfo, 16)+var file_v1_org_policy_service_proto_msgTypes = make([]protoimpl.MessageInfo, 15)var file_v1_org_policy_service_proto_goTypes = []any{(PolicyType)(0), // 0: bytebase.v1.PolicyType(PolicyResourceType)(0), // 1: bytebase.v1.PolicyResourceType- (DataSourceQueryPolicy_Restriction)(0), // 2: bytebase.v1.DataSourceQueryPolicy.Restriction+ (QueryDataPolicy_Restriction)(0), // 2: bytebase.v1.QueryDataPolicy.Restriction(*CreatePolicyRequest)(nil), // 3: bytebase.v1.CreatePolicyRequest(*UpdatePolicyRequest)(nil), // 4: bytebase.v1.UpdatePolicyRequest(*DeletePolicyRequest)(nil), // 5: bytebase.v1.DeletePolicyRequest@@ -1376,20 +1316,19 @@ var file_v1_org_policy_service_proto_goTypes = []any{(*MaskingExemptionPolicy)(nil), // 12: bytebase.v1.MaskingExemptionPolicy(*MaskingRulePolicy)(nil), // 13: bytebase.v1.MaskingRulePolicy(*TagPolicy)(nil), // 14: bytebase.v1.TagPolicy- (*DataSourceQueryPolicy)(nil), // 15: bytebase.v1.DataSourceQueryPolicy- (*MaskingExemptionPolicy_Exemption)(nil), // 16: bytebase.v1.MaskingExemptionPolicy.Exemption- (*MaskingRulePolicy_MaskingRule)(nil), // 17: bytebase.v1.MaskingRulePolicy.MaskingRule- nil, // 18: bytebase.v1.TagPolicy.TagsEntry- (*fieldmaskpb.FieldMask)(nil), // 19: google.protobuf.FieldMask- (*durationpb.Duration)(nil), // 20: google.protobuf.Duration- (*expr.Expr)(nil), // 21: google.type.Expr- (*emptypb.Empty)(nil), // 22: google.protobuf.Empty+ (*MaskingExemptionPolicy_Exemption)(nil), // 15: bytebase.v1.MaskingExemptionPolicy.Exemption+ (*MaskingRulePolicy_MaskingRule)(nil), // 16: bytebase.v1.MaskingRulePolicy.MaskingRule+ nil, // 17: bytebase.v1.TagPolicy.TagsEntry+ (*fieldmaskpb.FieldMask)(nil), // 18: google.protobuf.FieldMask+ (*durationpb.Duration)(nil), // 19: google.protobuf.Duration+ (*expr.Expr)(nil), // 20: google.type.Expr+ (*emptypb.Empty)(nil), // 21: google.protobuf.Empty}var file_v1_org_policy_service_proto_depIdxs = []int32{9, // 0: bytebase.v1.CreatePolicyRequest.policy:type_name -> bytebase.v1.Policy0, // 1: bytebase.v1.CreatePolicyRequest.type:type_name -> bytebase.v1.PolicyType9, // 2: bytebase.v1.UpdatePolicyRequest.policy:type_name -> bytebase.v1.Policy- 19, // 3: bytebase.v1.UpdatePolicyRequest.update_mask:type_name -> google.protobuf.FieldMask+ 18, // 3: bytebase.v1.UpdatePolicyRequest.update_mask:type_name -> google.protobuf.FieldMask0, // 4: bytebase.v1.ListPoliciesRequest.policy_type:type_name -> bytebase.v1.PolicyType9, // 5: bytebase.v1.ListPoliciesResponse.policies:type_name -> bytebase.v1.Policy0, // 6: bytebase.v1.Policy.type:type_name -> bytebase.v1.PolicyType@@ -1397,31 +1336,30 @@ var file_v1_org_policy_service_proto_depIdxs = []int32{13, // 8: bytebase.v1.Policy.masking_rule_policy:type_name -> bytebase.v1.MaskingRulePolicy12, // 9: bytebase.v1.Policy.masking_exemption_policy:type_name -> bytebase.v1.MaskingExemptionPolicy14, // 10: bytebase.v1.Policy.tag_policy:type_name -> bytebase.v1.TagPolicy- 15, // 11: bytebase.v1.Policy.data_source_query_policy:type_name -> bytebase.v1.DataSourceQueryPolicy- 11, // 12: bytebase.v1.Policy.query_data_policy:type_name -> bytebase.v1.QueryDataPolicy- 1, // 13: bytebase.v1.Policy.resource_type:type_name -> bytebase.v1.PolicyResourceType- 20, // 14: bytebase.v1.QueryDataPolicy.timeout:type_name -> google.protobuf.Duration- 16, // 15: bytebase.v1.MaskingExemptionPolicy.exemptions:type_name -> bytebase.v1.MaskingExemptionPolicy.Exemption- 17, // 16: bytebase.v1.MaskingRulePolicy.rules:type_name -> bytebase.v1.MaskingRulePolicy.MaskingRule- 18, // 17: bytebase.v1.TagPolicy.tags:type_name -> bytebase.v1.TagPolicy.TagsEntry- 2, // 18: bytebase.v1.DataSourceQueryPolicy.admin_data_source_restriction:type_name -> bytebase.v1.DataSourceQueryPolicy.Restriction- 21, // 19: bytebase.v1.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr- 21, // 20: bytebase.v1.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr- 6, // 21: bytebase.v1.OrgPolicyService.GetPolicy:input_type -> bytebase.v1.GetPolicyRequest- 7, // 22: bytebase.v1.OrgPolicyService.ListPolicies:input_type -> bytebase.v1.ListPoliciesRequest- 3, // 23: bytebase.v1.OrgPolicyService.CreatePolicy:input_type -> bytebase.v1.CreatePolicyRequest- 4, // 24: bytebase.v1.OrgPolicyService.UpdatePolicy:input_type -> bytebase.v1.UpdatePolicyRequest- 5, // 25: bytebase.v1.OrgPolicyService.DeletePolicy:input_type -> bytebase.v1.DeletePolicyRequest- 9, // 26: bytebase.v1.OrgPolicyService.GetPolicy:output_type -> bytebase.v1.Policy- 8, // 27: bytebase.v1.OrgPolicyService.ListPolicies:output_type -> bytebase.v1.ListPoliciesResponse- 9, // 28: bytebase.v1.OrgPolicyService.CreatePolicy:output_type -> bytebase.v1.Policy- 9, // 29: bytebase.v1.OrgPolicyService.UpdatePolicy:output_type -> bytebase.v1.Policy- 22, // 30: bytebase.v1.OrgPolicyService.DeletePolicy:output_type -> google.protobuf.Empty- 26, // [26:31] is the sub-list for method output_type- 21, // [21:26] is the sub-list for method input_type- 21, // [21:21] is the sub-list for extension type_name- 21, // [21:21] is the sub-list for extension extendee- 0, // [0:21] is the sub-list for field type_name+ 11, // 11: bytebase.v1.Policy.query_data_policy:type_name -> bytebase.v1.QueryDataPolicy+ 1, // 12: bytebase.v1.Policy.resource_type:type_name -> bytebase.v1.PolicyResourceType+ 19, // 13: bytebase.v1.QueryDataPolicy.timeout:type_name -> google.protobuf.Duration+ 2, // 14: bytebase.v1.QueryDataPolicy.admin_data_source_restriction:type_name -> bytebase.v1.QueryDataPolicy.Restriction+ 15, // 15: bytebase.v1.MaskingExemptionPolicy.exemptions:type_name -> bytebase.v1.MaskingExemptionPolicy.Exemption+ 16, // 16: bytebase.v1.MaskingRulePolicy.rules:type_name -> bytebase.v1.MaskingRulePolicy.MaskingRule+ 17, // 17: bytebase.v1.TagPolicy.tags:type_name -> bytebase.v1.TagPolicy.TagsEntry+ 20, // 18: bytebase.v1.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr+ 20, // 19: bytebase.v1.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr+ 6, // 20: bytebase.v1.OrgPolicyService.GetPolicy:input_type -> bytebase.v1.GetPolicyRequest+ 7, // 21: bytebase.v1.OrgPolicyService.ListPolicies:input_type -> bytebase.v1.ListPoliciesRequest+ 3, // 22: bytebase.v1.OrgPolicyService.CreatePolicy:input_type -> bytebase.v1.CreatePolicyRequest+ 4, // 23: bytebase.v1.OrgPolicyService.UpdatePolicy:input_type -> bytebase.v1.UpdatePolicyRequest+ 5, // 24: bytebase.v1.OrgPolicyService.DeletePolicy:input_type -> bytebase.v1.DeletePolicyRequest+ 9, // 25: bytebase.v1.OrgPolicyService.GetPolicy:output_type -> bytebase.v1.Policy+ 8, // 26: bytebase.v1.OrgPolicyService.ListPolicies:output_type -> bytebase.v1.ListPoliciesResponse+ 9, // 27: bytebase.v1.OrgPolicyService.CreatePolicy:output_type -> bytebase.v1.Policy+ 9, // 28: bytebase.v1.OrgPolicyService.UpdatePolicy:output_type -> bytebase.v1.Policy+ 21, // 29: bytebase.v1.OrgPolicyService.DeletePolicy:output_type -> google.protobuf.Empty+ 25, // [25:30] is the sub-list for method output_type+ 20, // [20:25] is the sub-list for method input_type+ 20, // [20:20] is the sub-list for extension type_name+ 20, // [20:20] is the sub-list for extension extendee+ 0, // [0:20] is the sub-list for field type_name}func init() { file_v1_org_policy_service_proto_init() }@@ -1436,7 +1374,6 @@ func file_v1_org_policy_service_proto_init() {(*Policy_MaskingRulePolicy)(nil),(*Policy_MaskingExemptionPolicy)(nil),(*Policy_TagPolicy)(nil),- (*Policy_DataSourceQueryPolicy)(nil),(*Policy_QueryDataPolicy)(nil),}type x struct{}@@ -1445,7 +1382,7 @@ func file_v1_org_policy_service_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_org_policy_service_proto_rawDesc), len(file_v1_org_policy_service_proto_rawDesc)),NumEnums: 3,- NumMessages: 16,+ NumMessages: 15,NumExtensions: 0,NumServices: 1,},diff --git a/backend/generated-go/v1/org_policy_service_equal.pb.go b/backend/generated-go/v1/org_policy_service_equal.pb.goindex b420bc15b8..9e1ba29468 100644--- a/backend/generated-go/v1/org_policy_service_equal.pb.go+++ b/backend/generated-go/v1/org_policy_service_equal.pb.go@@ -142,9 +142,6 @@ func (x *Policy) Equal(y *Policy) bool {if !x.GetTagPolicy().Equal(y.GetTagPolicy()) {return false}- if !x.GetDataSourceQueryPolicy().Equal(y.GetDataSourceQueryPolicy()) {- return false- }if !x.GetQueryDataPolicy().Equal(y.GetQueryDataPolicy()) {return false}@@ -200,6 +197,15 @@ func (x *QueryDataPolicy) Equal(y *QueryDataPolicy) bool {if x.DisableCopyData != y.DisableCopyData {return false}+ if x.AdminDataSourceRestriction != y.AdminDataSourceRestriction {+ return false+ }+ if x.DisallowDdl != y.DisallowDdl {+ return false+ }+ if x.DisallowDml != y.DisallowDml {+ return false+ }return true}@@ -304,22 +310,3 @@ func (x *TagPolicy) Equal(y *TagPolicy) bool {}return true}--func (x *DataSourceQueryPolicy) Equal(y *DataSourceQueryPolicy) bool {- if x == y {- return true- }- if x == nil || y == nil {- return x == nil && y == nil- }- if x.AdminDataSourceRestriction != y.AdminDataSourceRestriction {- return false- }- if x.DisallowDdl != y.DisallowDdl {- return false- }- if x.DisallowDml != y.DisallowDml {- return false- }- return true-}diff --git a/backend/migrator/migration/3.15/0000##merge_data_source_query_policy.sql b/backend/migrator/migration/3.15/0000##merge_data_source_query_policy.sqlnew file mode 100644index 0000000000..d16a6a18c4--- /dev/null+++ b/backend/migrator/migration/3.15/0000##merge_data_source_query_policy.sql@@ -0,0 +1,40 @@+-- Merge DATA_SOURCE_QUERY policies into QUERY_DATA policies+-- This migration consolidates the two separate policy types into a single unified QUERY_DATA policy++-- Step 1: Merge all DATA_SOURCE_QUERY policies into QUERY_DATA+-- For resources with existing QUERY_DATA: merge fields into existing policy+-- For resources without QUERY_DATA: create new QUERY_DATA policy with DATA_SOURCE_QUERY fields+INSERT INTO policy (resource_type, resource, type, payload, inherit_from_parent, enforce, updated_at)+SELECT+ p.resource_type,+ p.resource,+ 'QUERY_DATA',+ jsonb_build_object(+ 'adminDataSourceRestriction',+ COALESCE(p.payload->'adminDataSourceRestriction', '"RESTRICTION_UNSPECIFIED."'::jsonb),+ 'disallowDdl',+ COALESCE(p.payload->'disallowDdl', 'false'::jsonb),+ 'disallowDml',+ COALESCE(p.payload->'disallowDml', 'false'::jsonb)+ ),+ p.inherit_from_parent,+ p.enforce,+ NOW()+FROM policy p+WHERE p.type = 'DATA_SOURCE_QUERY'+ON CONFLICT (resource_type, resource, type)+DO UPDATE SET+ payload = policy.payload ||+ jsonb_build_object(+ 'adminDataSourceRestriction',+ COALESCE(EXCLUDED.payload->'adminDataSourceRestriction', '"RESTRICTION_UNSPECIFIED."'::jsonb),+ 'disallowDdl',+ COALESCE(EXCLUDED.payload->'disallowDdl', 'false'::jsonb),+ 'disallowDml',+ COALESCE(EXCLUDED.payload->'disallowDml', 'false'::jsonb)+ ),+ updated_at = NOW();++-- Step 2: Delete all DATA_SOURCE_QUERY policies (now merged into QUERY_DATA)+DELETE FROM policy+WHERE type = 'DATA_SOURCE_QUERY';diff --git a/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sqlindex 49fd699750..5bd23cb8eb 100644--- a/backend/migrator/migration/LATEST.sql+++ b/backend/migrator/migration/LATEST.sql@@ -74,17 +74,16 @@ CREATE TABLE policy (resource_type text NOT NULL,-- resource: resource name in format like "environments/{environment}", "projects/{project}", etc.resource TEXT NOT NULL,- -- type: ROLLOUT, MASKING_EXCEPTION, QUERY_DATA, MASKING_RULE, IAM, TAG, DATA_SOURCE_QUERY+ -- type: ROLLOUT, MASKING_EXCEPTION, QUERY_DATA, MASKING_RULE, IAM, TAG-- Enum: Policy.Type (proto/store/store/policy.proto)type text NOT NULL,-- Stored as different types based on policy type (proto/store/store/policy.proto):-- ROLLOUT: RolloutPolicy-- MASKING_EXCEPTION: MaskingExceptionPolicy- -- QUERY_DATA: QueryDataPolicy+ -- QUERY_DATA: QueryDataPolicy (includes query limits, export/copy restrictions, DDL/DML restrictions, admin data source restrictions)-- MASKING_RULE: MaskingRulePolicy-- IAM: IamPolicy-- TAG: TagPolicy- -- DATA_SOURCE_QUERY: DataSourceQueryPolicypayload jsonb NOT NULL DEFAULT '{}',inherit_from_parent boolean NOT NULL DEFAULT TRUE);diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 570959e41c..6c08bacd7d 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -12,8 +12,8 @@ import (func TestLatestVersion(t *testing.T) {files, err := getSortedVersionedFiles()require.NoError(t, err)- require.Equal(t, semver.MustParse("3.14.33"), *files[len(files)-1].version)- require.Equal(t, "migration/3.14/0033##add_release_id_tracking.sql", files[len(files)-1].path)+ require.Equal(t, semver.MustParse("3.15.0"), *files[len(files)-1].version)+ require.Equal(t, "migration/3.15/0000##merge_data_source_query_policy.sql", files[len(files)-1].path)}func TestVersionUnique(t *testing.T) {diff --git a/backend/store/policy.go b/backend/store/policy.goindex 0961612d5c..903b5f8413 100644--- a/backend/store/policy.go+++ b/backend/store/policy.go@@ -203,11 +203,14 @@ func (s *Store) GetRolloutPolicy(ctx context.Context, environment string) (*stor}type EffectiveQueryDataPolicy struct {- MaximumResultSize int64- MaximumResultRows int32- DisableCopyData bool- DisableExport bool- MaxQueryTimeoutInSeconds int64+ MaximumResultSize int64+ MaximumResultRows int32+ DisableCopyData bool+ DisableExport bool+ MaxQueryTimeoutInSeconds int64+ AdminDataSourceRestriction storepb.QueryDataPolicy_Restriction+ DisallowDDL bool+ DisallowDML bool}func formatEffectiveQueryDataPolicy(policy *storepb.QueryDataPolicy) *EffectiveQueryDataPolicy {@@ -225,11 +228,14 @@ func formatEffectiveQueryDataPolicy(policy *storepb.QueryDataPolicy) *EffectiveQ}return &EffectiveQueryDataPolicy{- MaximumResultSize: maximumResultSize,- MaximumResultRows: maximumResultRows,- MaxQueryTimeoutInSeconds: timeoutInSeconds,- DisableCopyData: policy.GetDisableCopyData(),- DisableExport: policy.GetDisableExport(),+ MaximumResultSize: maximumResultSize,+ MaximumResultRows: maximumResultRows,+ MaxQueryTimeoutInSeconds: timeoutInSeconds,+ DisableCopyData: policy.GetDisableCopyData(),+ DisableExport: policy.GetDisableExport(),+ AdminDataSourceRestriction: policy.GetAdminDataSourceRestriction(),+ DisallowDDL: policy.GetDisallowDdl(),+ DisallowDML: policy.GetDisallowDml(),}}@@ -250,12 +256,21 @@ func (s *Store) GetEffectiveQueryDataPolicy(ctx context.Context, project string)maximumResultRows := min(formatPorjectPolicy.MaximumResultRows, formatWorkspacePolicy.MaximumResultRows)maximumTimeout := min(formatPorjectPolicy.MaxQueryTimeoutInSeconds, formatWorkspacePolicy.MaxQueryTimeoutInSeconds)+ // For AdminDataSourceRestriction, project policy takes precedence over workspace+ adminRestriction := formatPorjectPolicy.AdminDataSourceRestriction+ if adminRestriction == storepb.QueryDataPolicy_RESTRICTION_UNSPECIFIED {+ adminRestriction = formatWorkspacePolicy.AdminDataSourceRestriction+ }+return &EffectiveQueryDataPolicy{- DisableCopyData: formatPorjectPolicy.DisableCopyData || formatWorkspacePolicy.DisableCopyData,- DisableExport: formatPorjectPolicy.DisableExport || formatWorkspacePolicy.DisableExport,- MaximumResultSize: maximumResultSize,- MaximumResultRows: maximumResultRows,- MaxQueryTimeoutInSeconds: maximumTimeout,+ DisableCopyData: formatPorjectPolicy.DisableCopyData || formatWorkspacePolicy.DisableCopyData,+ DisableExport: formatPorjectPolicy.DisableExport || formatWorkspacePolicy.DisableExport,+ MaximumResultSize: maximumResultSize,+ MaximumResultRows: maximumResultRows,+ MaxQueryTimeoutInSeconds: maximumTimeout,+ AdminDataSourceRestriction: adminRestriction,+ DisallowDDL: formatPorjectPolicy.DisallowDDL || formatWorkspacePolicy.DisallowDDL,+ DisallowDML: formatPorjectPolicy.DisallowDML || formatWorkspacePolicy.DisallowDML,}, nil}diff --git a/backend/tests/sql_stop_on_error_test.go b/backend/tests/sql_stop_on_error_test.goindex 08e3d38ca1..eccd34b313 100644--- a/backend/tests/sql_stop_on_error_test.go+++ b/backend/tests/sql_stop_on_error_test.go@@ -191,9 +191,9 @@ func TestSQLQueryStopOnError(t *testing.T) {_, err = ctl.orgPolicyServiceClient.CreatePolicy(ctx, connect.NewRequest(&v1pb.CreatePolicyRequest{Parent: "environments/test",Policy: &v1pb.Policy{- Type: v1pb.PolicyType_DATA_SOURCE_QUERY,- Policy: &v1pb.Policy_DataSourceQueryPolicy{- DataSourceQueryPolicy: &v1pb.DataSourceQueryPolicy{+ Type: v1pb.PolicyType_DATA_QUERY,+ Policy: &v1pb.Policy_QueryDataPolicy{+ QueryDataPolicy: &v1pb.QueryDataPolicy{DisallowDml: true,},},diff --git a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vueindex 967d6bad87..c9f7fbf8ec 100644--- a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue+++ b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue@@ -13,7 +13,7 @@</span></NTooltip></div>- <div>+ <div class="flex flex-col gap-y-2"><div class="w-full inline-flex items-center gap-x-2"><PermissionGuardWrapperv-slot="slotProps"@@ -23,7 +23,7 @@]"><Switch- v-model:value="state.queryDataPolicy.disableCopyData"+ v-model:value="state.disableCopyData":text="true":disabled="slotProps.disabled || !hasRestrictCopyingDataFeature"/>@@ -46,7 +46,7 @@:value="adminDataSourceQueryRestrictionEnabled":text="true":disabled="slotProps.disabled || !hasRestrictQueryDataSourceFeature"- @update:value="switchDataSourceQueryPolicyEnabled"+ @update:value="switchAdminDataSourceRestriction"/></PermissionGuardWrapper><span class="textlabel">{{@@ -64,13 +64,13 @@><NRadioGroupv-model:value="- state.dataSourceQueryPolicy.adminDataSourceRestriction+ state.adminDataSourceRestriction":disabled="slotProps.disabled || !hasRestrictQueryDataSourceFeature"><NRadioclass="w-full"- :value="DataSourceQueryPolicy_Restriction.DISALLOW"+ :value="QueryDataPolicy_Restriction.DISALLOW">{{t(@@ -80,7 +80,7 @@</NRadio><NRadioclass="w-full"- :value="DataSourceQueryPolicy_Restriction.FALLBACK"+ :value="QueryDataPolicy_Restriction.FALLBACK">{{t(@@ -104,7 +104,7 @@</label><FeatureBadge :feature="PlanFeature.FEATURE_QUERY_POLICY" /></div>- <div>+ <div class="flex flex-col gap-y-2"><div class="w-full inline-flex items-center gap-x-2"><PermissionGuardWrapperv-slot="slotProps"@@ -114,7 +114,7 @@]"><Switch- v-model:value="state.dataSourceQueryPolicy.disallowDdl"+ v-model:value="state.disallowDdl":text="true":disabled="slotProps.disabled || !hasRestrictQueryDataSourceFeature"/>@@ -132,7 +132,7 @@]"><Switch- v-model:value="state.dataSourceQueryPolicy.disallowDml"+ v-model:value="state.disallowDml":text="true":disabled="slotProps.disabled || !hasRestrictQueryDataSourceFeature"/>@@ -158,13 +158,10 @@ import {projectNamePrefix,} from "@/store/modules/v1/common";import { isValidProjectName } from "@/types";-import type {- DataSourceQueryPolicy,- QueryDataPolicy,-} from "@/types/proto-es/v1/org_policy_service_pb";+import type { QueryDataPolicy } from "@/types/proto-es/v1/org_policy_service_pb";import {- DataSourceQueryPolicy_Restriction,PolicyType,+ QueryDataPolicy_Restriction,} from "@/types/proto-es/v1/org_policy_service_pb";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import { hasProjectPermissionV2, hasWorkspacePermissionV2 } from "@/utils";@@ -173,11 +170,6 @@ import { Switch } from "../v2";const { t } = useI18n();-interface LocalState {- queryDataPolicy: QueryDataPolicy;- dataSourceQueryPolicy: DataSourceQueryPolicy;-}-const props = defineProps<{resource: string;}>();@@ -217,48 +209,32 @@ const tooltip = computed(() => {const policyStore = usePolicyV1Store();-const getInitialState = (): LocalState => {- return {- queryDataPolicy: (() => {- const policy = policyStore.getQueryDataPolicyByParent(props.resource);- return cloneDeep(policy);- })(),- dataSourceQueryPolicy: (() => {- const policy = policyStore.getDataSourceQueryPolicyByParent(- props.resource- );- return cloneDeep(policy);- })(),- };+const getInitialState = (): QueryDataPolicy => {+ const policy = policyStore.getQueryDataPolicyByParent(props.resource);+ return cloneDeep(policy);};-const state = reactive<LocalState>(getInitialState());+const state = reactive<QueryDataPolicy>(getInitialState());watchEffect(async () => {if (!hasGetPermission.value) {return;}- await Promise.all([- policyStore.getOrFetchPolicyByParentAndType({- parentPath: props.resource,- policyType: PolicyType.DATA_QUERY,- }),- policyStore.getOrFetchPolicyByParentAndType({- parentPath: props.resource,- policyType: PolicyType.DATA_SOURCE_QUERY,- }),- ]);+ await policyStore.getOrFetchPolicyByParentAndType({+ parentPath: props.resource,+ policyType: PolicyType.DATA_QUERY,+ });Object.assign(state, getInitialState());});const adminDataSourceQueryRestrictionEnabled = computed(() => {return (- state.dataSourceQueryPolicy.adminDataSourceRestriction &&+ state.adminDataSourceRestriction &&[- DataSourceQueryPolicy_Restriction.DISALLOW,- DataSourceQueryPolicy_Restriction.FALLBACK,- ].includes(state.dataSourceQueryPolicy.adminDataSourceRestriction)+ QueryDataPolicy_Restriction.DISALLOW,+ QueryDataPolicy_Restriction.FALLBACK,+ ].includes(state.adminDataSourceRestriction));});@@ -278,44 +254,24 @@ const updateQueryDataPolicy = async () => {policy: {case: "queryDataPolicy",value: {- ...state.queryDataPolicy,+ ...state,},},},});};-const switchDataSourceQueryPolicyEnabled = (on: boolean) => {- state.dataSourceQueryPolicy.adminDataSourceRestriction = on- ? DataSourceQueryPolicy_Restriction.DISALLOW- : DataSourceQueryPolicy_Restriction.RESTRICTION_UNSPECIFIED;-};--const updateAdminDataSourceQueryRestrctionPolicy = async () => {- await policyStore.upsertPolicy({- parentPath: props.resource,- policy: {- type: PolicyType.DATA_SOURCE_QUERY,- policy: {- case: "dataSourceQueryPolicy",- value: {- ...state.dataSourceQueryPolicy,- },- },- },- });+const switchAdminDataSourceRestriction = (on: boolean) => {+ state.adminDataSourceRestriction = on+ ? QueryDataPolicy_Restriction.DISALLOW+ : QueryDataPolicy_Restriction.RESTRICTION_UNSPECIFIED;};defineExpose({isDirty: computed(() => !isEqual(state, getInitialState())),update: async () => {const initialState = getInitialState();- if (- !isEqual(state.dataSourceQueryPolicy, initialState.dataSourceQueryPolicy)- ) {- await updateAdminDataSourceQueryRestrctionPolicy();- }- if (!isEqual(state.queryDataPolicy, initialState.queryDataPolicy)) {+ if (!isEqual(state, initialState)) {await updateQueryDataPolicy();}},diff --git a/frontend/src/store/modules/v1/policy.ts b/frontend/src/store/modules/v1/policy.tsindex abd3fddb1d..262c4c85a0 100644--- a/frontend/src/store/modules/v1/policy.ts+++ b/frontend/src/store/modules/v1/policy.ts@@ -9,18 +9,16 @@ import { policyNamePrefix } from "@/store/modules/v1/common";import type { ComposedDatabase, MaybeRef } from "@/types";import { UNKNOWN_USER_NAME } from "@/types";import type {- DataSourceQueryPolicy,Policy,QueryDataPolicy,} from "@/types/proto-es/v1/org_policy_service_pb";import {- DataSourceQueryPolicy_Restriction,- DataSourceQueryPolicySchema,DeletePolicyRequestSchema,GetPolicyRequestSchema,PolicyResourceType,PolicySchema,PolicyType,+ QueryDataPolicy_Restriction,QueryDataPolicySchema,RolloutPolicySchema,UpdatePolicyRequestSchema,@@ -52,19 +50,6 @@ export const usePolicyV1Store = defineStore("policy_v1", () => {policyMapByName: new Map(),});- const getDataSourceQueryPolicyByParent = (- parent: string- ): DataSourceQueryPolicy => {- const policy = getPolicyByParentAndType({- parentPath: parent,- policyType: PolicyType.DATA_SOURCE_QUERY,- });-- return policy?.policy?.case === "dataSourceQueryPolicy"- ? policy.policy.value- : create(DataSourceQueryPolicySchema, {});- };-const getQueryDataPolicyByParent = (parent: string): QueryDataPolicy => {const policy = getPolicyByParentAndType({parentPath: parent,@@ -80,6 +65,10 @@ export const usePolicyV1Store = defineStore("policy_v1", () => {timeout: create(DurationSchema, {seconds: BigInt(0),}),+ adminDataSourceRestriction:+ QueryDataPolicy_Restriction.RESTRICTION_UNSPECIFIED,+ disallowDdl: false,+ disallowDml: false,});};@@ -184,7 +173,6 @@ export const usePolicyV1Store = defineStore("policy_v1", () => {upsertPolicy,deletePolicy,getQueryDataPolicyByParent,- getDataSourceQueryPolicyByParent,};});@@ -222,8 +210,6 @@ const getUpdateMaskFromPolicyType = (policyType: PolicyType) => {return [PolicySchema.field.maskingRulePolicy.name];case PolicyType.DATA_QUERY:return [PolicySchema.field.queryDataPolicy.name];- case PolicyType.DATA_SOURCE_QUERY:- return [PolicySchema.field.dataSourceQueryPolicy.name];case PolicyType.TAG:return [PolicySchema.field.tagPolicy.name];case PolicyType.POLICY_TYPE_UNSPECIFIED:@@ -276,32 +262,31 @@ export const useDataSourceRestrictionPolicy = (watchEffect(async () => {await store.getOrFetchPolicyByParentAndType({parentPath: unref(database).project,- policyType: PolicyType.DATA_SOURCE_QUERY,+ policyType: PolicyType.DATA_QUERY,});const environment = unref(database).effectiveEnvironment;if (environment) {await store.getOrFetchPolicyByParentAndType({parentPath: environment,- policyType: PolicyType.DATA_SOURCE_QUERY,+ policyType: PolicyType.DATA_QUERY,});}ready.value = true;});const dataSourceRestriction = computed(() => {- const projectLevelPolicy = store.getDataSourceQueryPolicyByParent(+ const projectLevelPolicy = store.getQueryDataPolicyByParent(unref(database).project);const projectLevelAdminDSRestriction =projectLevelPolicy.adminDataSourceRestriction;let envLevelAdminDSRestriction =- DataSourceQueryPolicy_Restriction.RESTRICTION_UNSPECIFIED;+ QueryDataPolicy_Restriction.RESTRICTION_UNSPECIFIED;const environment = unref(database).effectiveEnvironment;if (environment) {- const envLevelPolicy =- store.getDataSourceQueryPolicyByParent(environment);+ const envLevelPolicy = store.getQueryDataPolicyByParent(environment);envLevelAdminDSRestriction = envLevelPolicy.adminDataSourceRestriction;}diff --git a/frontend/src/types/proto-es/v1/org_policy_service_pb.d.ts b/frontend/src/types/proto-es/v1/org_policy_service_pb.d.tsindex e0e900f6b3..0f66429547 100644--- a/frontend/src/types/proto-es/v1/org_policy_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/org_policy_service_pb.d.ts@@ -240,12 +240,6 @@ export declare type Policy = Message<"bytebase.v1.Policy"> & {*/value: TagPolicy;case: "tagPolicy";- } | {- /**- * @generated from field: bytebase.v1.DataSourceQueryPolicy data_source_query_policy = 8;- */- value: DataSourceQueryPolicy;- case: "dataSourceQueryPolicy";} | {/*** @generated from field: bytebase.v1.QueryDataPolicy query_data_policy = 9;@@ -344,6 +338,27 @@ export declare type QueryDataPolicy = Message<"bytebase.v1.QueryDataPolicy"> & {* @generated from field: bool disable_copy_data = 5;*/disableCopyData: boolean;++ /**+ * Restriction for admin data source queries.+ *+ * @generated from field: bytebase.v1.QueryDataPolicy.Restriction admin_data_source_restriction = 6;+ */+ adminDataSourceRestriction: QueryDataPolicy_Restriction;++ /**+ * Disallow running DDL statements in the SQL editor.+ *+ * @generated from field: bool disallow_ddl = 7;+ */+ disallowDdl: boolean;++ /**+ * Disallow running DML statements in the SQL editor.+ *+ * @generated from field: bool disallow_dml = 8;+ */+ disallowDml: boolean;};/**@@ -352,6 +367,39 @@ export declare type QueryDataPolicy = Message<"bytebase.v1.QueryDataPolicy"> & {*/export declare const QueryDataPolicySchema: GenMessage<QueryDataPolicy>;+/**+ * Restriction level for admin data source access.+ *+ * @generated from enum bytebase.v1.QueryDataPolicy.Restriction+ */+export enum QueryDataPolicy_Restriction {+ /**+ * Unspecified restriction.+ *+ * @generated from enum value: RESTRICTION_UNSPECIFIED = 0;+ */+ RESTRICTION_UNSPECIFIED = 0,++ /**+ * Allow querying admin data sources when there is no read-only data source.+ *+ * @generated from enum value: FALLBACK = 1;+ */+ FALLBACK = 1,++ /**+ * Disallow querying admin data sources.+ *+ * @generated from enum value: DISALLOW = 2;+ */+ DISALLOW = 2,+}++/**+ * Describes the enum bytebase.v1.QueryDataPolicy.Restriction.+ */+export declare const QueryDataPolicy_RestrictionSchema: GenEnum<QueryDataPolicy_Restriction>;+/*** MaskingExemptionPolicy is the allowlist of users who can access sensitive data.*@@ -509,73 +557,6 @@ export declare type TagPolicy = Message<"bytebase.v1.TagPolicy"> & {*/export declare const TagPolicySchema: GenMessage<TagPolicy>;-/**- * Policy for controlling which data sources can be queried in the SQL editor.- *- * @generated from message bytebase.v1.DataSourceQueryPolicy- */-export declare type DataSourceQueryPolicy = Message<"bytebase.v1.DataSourceQueryPolicy"> & {- /**- * Restriction for admin data source queries.- *- * @generated from field: bytebase.v1.DataSourceQueryPolicy.Restriction admin_data_source_restriction = 1;- */- adminDataSourceRestriction: DataSourceQueryPolicy_Restriction;-- /**- * Disallow running DDL statements in the SQL editor.- *- * @generated from field: bool disallow_ddl = 2;- */- disallowDdl: boolean;-- /**- * Disallow running DML statements in the SQL editor.- *- * @generated from field: bool disallow_dml = 3;- */- disallowDml: boolean;-};--/**- * Describes the message bytebase.v1.DataSourceQueryPolicy.- * Use `create(DataSourceQueryPolicySchema)` to create a new message.- */-export declare const DataSourceQueryPolicySchema: GenMessage<DataSourceQueryPolicy>;--/**- * Restriction level for admin data source access.- *- * @generated from enum bytebase.v1.DataSourceQueryPolicy.Restriction- */-export enum DataSourceQueryPolicy_Restriction {- /**- * Unspecified restriction.- *- * @generated from enum value: RESTRICTION_UNSPECIFIED = 0;- */- RESTRICTION_UNSPECIFIED = 0,-- /**- * Allow querying admin data sources when there is no read-only data source.- *- * @generated from enum value: FALLBACK = 1;- */- FALLBACK = 1,-- /**- * Disallow querying admin data sources.- *- * @generated from enum value: DISALLOW = 2;- */- DISALLOW = 2,-}--/**- * Describes the enum bytebase.v1.DataSourceQueryPolicy.Restriction.- */-export declare const DataSourceQueryPolicy_RestrictionSchema: GenEnum<DataSourceQueryPolicy_Restriction>;-/*** The type of organizational policy.*@@ -617,13 +598,6 @@ export enum PolicyType {*/TAG = 4,- /**- * Data source query restrictions policy.- *- * @generated from enum value: DATA_SOURCE_QUERY = 5;- */- DATA_SOURCE_QUERY = 5,-/*** Query data access policy.*diff --git a/frontend/src/types/proto-es/v1/org_policy_service_pb.js b/frontend/src/types/proto-es/v1/org_policy_service_pb.jsindex 15c056af96..f11b991033 100644--- a/frontend/src/types/proto-es/v1/org_policy_service_pb.js+++ b/frontend/src/types/proto-es/v1/org_policy_service_pb.js@@ -15,7 +15,7 @@ import { file_v1_annotation } from "./annotation_pb";* Describes the file v1/org_policy_service.proto.*/export const file_v1_org_policy_service = /*@__PURE__*/- fileDesc("Cht2MS9vcmdfcG9saWN5X3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIpMBChNDcmVhdGVQb2xpY3lSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EigKBnBvbGljeRgCIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEiUKBHR5cGUYAyABKA4yFy5ieXRlYmFzZS52MS5Qb2xpY3lUeXBlIocBChNVcGRhdGVQb2xpY3lSZXF1ZXN0EigKBnBvbGljeRgBIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEi8KC3V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ZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_type_expr, file_v1_annotation]);+ fileDesc("Cht2MS9vcmdfcG9saWN5X3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIpMBChNDcmVhdGVQb2xpY3lSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EigKBnBvbGljeRgCIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEiUKBHR5cGUYAyABKA4yFy5ieXRlYmFzZS52MS5Qb2xpY3lUeXBlIocBChNVcGRhdGVQb2xpY3lSZXF1ZXN0EigKBnBvbGljeRgBIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIVCg1hbGxvd19taXNzaW5nGAMgASgIIkAKE0RlbGV0ZVBvbGljeVJlcXVlc3QSKQoEbmFtZRgBIAEoCUIb4EEC+kEVChNieXRlYmFzZS5jb20vUG9saWN5Ij0KEEdldFBvbGljeVJlcXVlc3QSKQoEbmFtZRgBIAEoCUIb4EEC+kEVChNieXRlYmFzZS5jb20vUG9saWN5IpsBChNMaXN0UG9saWNpZXNSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EjEKC3BvbGljeV90eXBlGAIgASgOMhcuYnl0ZWJhc2UudjEuUG9saWN5VHlwZUgAiAEBEhQKDHNob3dfZGVsZXRlZBgDIAEoCEIOCgxfcG9saWN5X3R5cGUiPQoUTGl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nbGUucHJvdG9idWYuRW1wdHki5QHaQQRuYW1liuowEmJiLnBvbGljaWVzLmRlbGV0ZZDqMAKY6jABgtPkkwK5AVoiKiAvdjEve25hbWU9cHJvamVjdHMvKi9wb2xpY2llcy8qfVomKiQvdjEve25hbWU9ZW52aXJvbm1lbnRzLyovcG9saWNpZXMvKn1aIyohL3YxL3tuYW1lPWluc3RhbmNlcy8qL3BvbGljaWVzLyp9Wi8qLS92MS97bmFtZT1pbnN0YW5jZXMvKi9kYXRhYmFzZXMvKi9wb2xpY2llcy8qfSoVL3YxL3tuYW1lPXBvbGljaWVzLyp9QqsBCg9jb20uYnl0ZWJhc2UudjFCFU9yZ1BvbGljeVNlcnZpY2VQcm90b1ABWjRnaXRodWIuY29tL2J5dGViYXNlL2J5dGViYXNlL2JhY2tlbmQvZ2VuZXJhdGVkLWdvL3YxogIDQlhYqgILQnl0ZWJhc2UuVjHKAgtCeXRlYmFzZVxWMeICF0J5dGViYXNlXFYxXEdQQk1ldGFkYXRh6gIMQnl0ZWJhc2U6OlYxYgZwcm90bzM", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_type_expr, file_v1_annotation]);/*** Describes the message bytebase.v1.CreatePolicyRequest.@@ -80,6 +80,20 @@ export const RolloutPolicySchema = /*@__PURE__*/export const QueryDataPolicySchema = /*@__PURE__*/messageDesc(file_v1_org_policy_service, 8);+/**+ * Describes the enum bytebase.v1.QueryDataPolicy.Restriction.+ */+export const QueryDataPolicy_RestrictionSchema = /*@__PURE__*/+ enumDesc(file_v1_org_policy_service, 8, 0);++/**+ * Restriction level for admin data source access.+ *+ * @generated from enum bytebase.v1.QueryDataPolicy.Restriction+ */+export const QueryDataPolicy_Restriction = /*@__PURE__*/+ tsEnum(QueryDataPolicy_RestrictionSchema);+/*** Describes the message bytebase.v1.MaskingExemptionPolicy.* Use `create(MaskingExemptionPolicySchema)` to create a new message.@@ -115,27 +129,6 @@ export const MaskingRulePolicy_MaskingRuleSchema = /*@__PURE__*/export const TagPolicySchema = /*@__PURE__*/messageDesc(file_v1_org_policy_service, 11);-/**- * Describes the message bytebase.v1.DataSourceQueryPolicy.- * Use `create(DataSourceQueryPolicySchema)` to create a new message.- */-export const DataSourceQueryPolicySchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 12);--/**- * Describes the enum bytebase.v1.DataSourceQueryPolicy.Restriction.- */-export const DataSourceQueryPolicy_RestrictionSchema = /*@__PURE__*/- enumDesc(file_v1_org_policy_service, 12, 0);--/**- * Restriction level for admin data source access.- *- * @generated from enum bytebase.v1.DataSourceQueryPolicy.Restriction- */-export const DataSourceQueryPolicy_Restriction = /*@__PURE__*/- tsEnum(DataSourceQueryPolicy_RestrictionSchema);-/*** Describes the enum bytebase.v1.PolicyType.*/diff --git a/frontend/src/utils/sqlEditor.ts b/frontend/src/utils/sqlEditor.tsindex ea85c91070..6df71b92f0 100644--- a/frontend/src/utils/sqlEditor.ts+++ b/frontend/src/utils/sqlEditor.ts@@ -19,7 +19,7 @@ import {DataSourceType,type InstanceResource,} from "@/types/proto-es/v1/instance_service_pb";-import { DataSourceQueryPolicy_Restriction } from "@/types/proto-es/v1/org_policy_service_pb";+import { QueryDataPolicy_Restriction } from "@/types/proto-es/v1/org_policy_service_pb";import { wrapRefAsPromise } from "@/utils";import { instanceV1AllowsCrossDatabaseQuery } from "./v1/instance";@@ -135,16 +135,16 @@ const getDataSourceBehavior = async (database: ComposedDatabase) => {let behavior: "RO" | "FALLBACK" | "ALLOW_ADMIN";if (dataSourceRestriction.value.environmentPolicy ===- DataSourceQueryPolicy_Restriction.DISALLOW ||+ QueryDataPolicy_Restriction.DISALLOW ||dataSourceRestriction.value.projectPolicy ===- DataSourceQueryPolicy_Restriction.DISALLOW+ QueryDataPolicy_Restriction.DISALLOW) {behavior = "RO";} else if (dataSourceRestriction.value.environmentPolicy ===- DataSourceQueryPolicy_Restriction.FALLBACK ||+ QueryDataPolicy_Restriction.FALLBACK ||dataSourceRestriction.value.projectPolicy ===- DataSourceQueryPolicy_Restriction.FALLBACK+ QueryDataPolicy_Restriction.FALLBACK) {behavior = "FALLBACK";} else {diff --git a/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue b/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vueindex c1ef3321f5..021dd94d1d 100644--- a/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue+++ b/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue@@ -112,7 +112,6 @@ import {import {useDataSourceRestrictionPolicy,useEffectiveQueryDataPolicyForProject,- usePolicyV1Store,} from "@/store/modules/v1/policy";import { isValidDatabaseName } from "@/types";import { Engine } from "@/types/proto-es/v1/common_pb";@@ -121,10 +120,7 @@ import {DataSource_RedisType,DataSourceType,} from "@/types/proto-es/v1/instance_service_pb";-import {- DataSourceQueryPolicy_Restriction,- PolicyType,-} from "@/types/proto-es/v1/org_policy_service_pb";+import { QueryDataPolicy_Restriction } from "@/types/proto-es/v1/org_policy_service_pb";import { QueryOption_RedisRunCommandsOn } from "@/types/proto-es/v1/sql_service_pb";import { getValidDataSourceByPolicy, readableDataSourceType } from "@/utils";@@ -135,7 +131,6 @@ defineProps<{const { t } = useI18n();const tabStore = useSQLEditorTabStore();const { connection, database } = useConnectionOfCurrentSQLEditorTab();-const policyStore = usePolicyV1Store();const { redisCommandOption, resultRowsLimit, project } = storeToRefs(useSQLEditorStore()@@ -183,9 +178,9 @@ const dataSourceUnaccessibleReason = (if (dataSource.type === DataSourceType.ADMIN) {if (dataSourceRestriction.value.environmentPolicy ===- DataSourceQueryPolicy_Restriction.DISALLOW ||+ QueryDataPolicy_Restriction.DISALLOW ||dataSourceRestriction.value.projectPolicy ===- DataSourceQueryPolicy_Restriction.DISALLOW+ QueryDataPolicy_Restriction.DISALLOW) {return t("sql-editor.query-context.admin-data-source-is-disallowed-to-query"@@ -197,9 +192,9 @@ const dataSourceUnaccessibleReason = (if (readOnlyDataSources.length > 0 &&(dataSourceRestriction.value.environmentPolicy ===- DataSourceQueryPolicy_Restriction.FALLBACK ||+ QueryDataPolicy_Restriction.FALLBACK ||dataSourceRestriction.value.projectPolicy ===- DataSourceQueryPolicy_Restriction.FALLBACK)+ QueryDataPolicy_Restriction.FALLBACK)) {return t("sql-editor.query-context.admin-data-source-is-disallowed-to-query-when-read-only-data-source-is-available"@@ -233,33 +228,6 @@ watch(});-watch(- () => database.value.name,- async () => {- if (!isValidDatabaseName(database.value.name)) {- return;- }- const requests = [- policyStore.getOrFetchPolicyByParentAndType({- parentPath: database.value.project,- policyType: PolicyType.DATA_SOURCE_QUERY,- }),- ];- if (database.value.effectiveEnvironment) {- requests.push(- policyStore.getOrFetchPolicyByParentAndType({- parentPath: database.value.effectiveEnvironment,- policyType: PolicyType.DATA_SOURCE_QUERY,- })- );- }- await Promise.all(requests);- },- {- immediate: true,- }-);-watchEffect(() => {if (resultRowsLimit.value > maximumResultRows.value) {resultRowsLimit.value = maximumResultRows.value;diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 72e90acd12..b7db43678c 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -12329,32 +12329,6 @@ components:- AWS_SECRETS_MANAGER- GCP_SECRET_MANAGER- AZURE_KEY_VAULT- bytebase.v1.DataSourceQueryPolicy:- type: object- properties:- adminDataSourceRestriction:- title: admin_data_source_restriction- description: Restriction for admin data source queries.- $ref: '#/components/schemas/bytebase.v1.DataSourceQueryPolicy.Restriction'- disallowDdl:- type: boolean- title: disallow_ddl- description: Disallow running DDL statements in the SQL editor.- disallowDml:- type: boolean- title: disallow_dml- description: Disallow running DML statements in the SQL editor.- title: DataSourceQueryPolicy- additionalProperties: false- description: Policy for controlling which data sources can be queried in the SQL editor.- bytebase.v1.DataSourceQueryPolicy.Restriction:- type: string- title: Restriction- enum:- - RESTRICTION_UNSPECIFIED- - FALLBACK- - DISALLOW- description: Restriction level for admin data source access.bytebase.v1.DataSourceType:type: stringtitle: DataSourceType@@ -16858,13 +16832,6 @@ components:readOnly: true$ref: '#/components/schemas/bytebase.v1.PolicyResourceType'- oneOf:- - properties:- dataSourceQueryPolicy:- title: data_source_query_policy- $ref: '#/components/schemas/bytebase.v1.DataSourceQueryPolicy'- title: data_source_query_policy- required:- - dataSourceQueryPolicy- properties:maskingExemptionPolicy:title: masking_exemption_policy@@ -16932,7 +16899,6 @@ components:- MASKING_EXEMPTION- ROLLOUT_POLICY- TAG- - DATA_SOURCE_QUERY- DATA_QUERYdescription: The type of organizational policy.bytebase.v1.Position:@@ -17184,9 +17150,29 @@ components:type: booleantitle: disable_copy_datadescription: Disable copying query results.+ adminDataSourceRestriction:+ title: admin_data_source_restriction+ description: Restriction for admin data source queries.+ $ref: '#/components/schemas/bytebase.v1.QueryDataPolicy.Restriction'+ disallowDdl:+ type: boolean+ title: disallow_ddl+ description: Disallow running DDL statements in the SQL editor.+ disallowDml:+ type: boolean+ title: disallow_dml+ description: Disallow running DML statements in the SQL editor.title: QueryDataPolicyadditionalProperties: falsedescription: QueryDataPolicy is the policy configuration for querying data.+ bytebase.v1.QueryDataPolicy.Restriction:+ type: string+ title: Restriction+ enum:+ - RESTRICTION_UNSPECIFIED+ - FALLBACK+ - DISALLOW+ description: Restriction level for admin data source access.bytebase.v1.QueryHistory:type: objectproperties:diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.mdindex 84addfc04f..a0198b2590 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -179,7 +179,6 @@- [store/policy.proto](#store_policy-proto)- [Binding](#bytebase-store-Binding)- - [DataSourceQueryPolicy](#bytebase-store-DataSourceQueryPolicy)- [IamPolicy](#bytebase-store-IamPolicy)- [MaskingExemptionPolicy](#bytebase-store-MaskingExemptionPolicy)- [MaskingExemptionPolicy.Exemption](#bytebase-store-MaskingExemptionPolicy-Exemption)@@ -191,9 +190,9 @@- [TagPolicy](#bytebase-store-TagPolicy)- [TagPolicy.TagsEntry](#bytebase-store-TagPolicy-TagsEntry)- - [DataSourceQueryPolicy.Restriction](#bytebase-store-DataSourceQueryPolicy-Restriction)- [Policy.Resource](#bytebase-store-Policy-Resource)- [Policy.Type](#bytebase-store-Policy-Type)+ - [QueryDataPolicy.Restriction](#bytebase-store-QueryDataPolicy-Restriction)- [store/project.proto](#store_project-proto)- [Label](#bytebase-store-Label)@@ -3125,23 +3124,6 @@ Plan spec update event (tracks sheet changes to plan specs)-<a name="bytebase-store-DataSourceQueryPolicy"></a>--### DataSourceQueryPolicy-DataSourceQueryPolicy is the policy configuration for running statements in the SQL editor.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| admin_data_source_restriction | [DataSourceQueryPolicy.Restriction](#bytebase-store-DataSourceQueryPolicy-Restriction) | | |-| disallow_ddl | [bool](#bool) | | Disallow running DDL statements in the SQL editor. |-| disallow_dml | [bool](#bool) | | Disallow running DML statements in the SQL editor. |------<a name="bytebase-store-IamPolicy"></a>### IamPolicy@@ -3249,6 +3231,9 @@ QueryDataPolicy is the policy configuration for querying data.| maximum_result_size | [int64](#int64) | | The size limit in bytes. The default value is 100MB, we will use the default value if the setting not exists, or the limit <= 0. || maximum_result_rows | [int32](#int32) | | The return rows limit. The default value is -1, means no limit. || disable_copy_data | [bool](#bool) | | Disable copying data. |+| admin_data_source_restriction | [QueryDataPolicy.Restriction](#bytebase-store-QueryDataPolicy-Restriction) | | Restriction for admin data source queries. |+| disallow_ddl | [bool](#bool) | | Disallow running DDL statements in the SQL editor. |+| disallow_dml | [bool](#bool) | | Disallow running DML statements in the SQL editor. |@@ -3304,19 +3289,6 @@ QueryDataPolicy is the policy configuration for querying data.-<a name="bytebase-store-DataSourceQueryPolicy-Restriction"></a>--### DataSourceQueryPolicy.Restriction---| Name | Number | Description |-| ---- | ------ | ----------- |-| RESTRICTION_UNSPECIFIED | 0 | |-| FALLBACK | 1 | Allow to query admin data sources when there is no read-only data source. |-| DISALLOW | 2 | Disallow to query admin data sources. |---<a name="bytebase-store-Policy-Resource"></a>### Policy.Resource@@ -3345,7 +3317,19 @@ QueryDataPolicy is the policy configuration for querying data.| MASKING_RULE | 4 | || IAM | 5 | || TAG | 6 | |-| DATA_SOURCE_QUERY | 7 | |++++<a name="bytebase-store-QueryDataPolicy-Restriction"></a>++### QueryDataPolicy.Restriction+++| Name | Number | Description |+| ---- | ------ | ----------- |+| RESTRICTION_UNSPECIFIED | 0 | |+| FALLBACK | 1 | Allow to query admin data sources when there is no read-only data source. |+| DISALLOW | 2 | Disallow to query admin data sources. |diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.htmlindex e46d4d0083..2dc982dbb3 100644--- a/proto/gen/grpc-doc/store/index.html+++ b/proto/gen/grpc-doc/store/index.html@@ -879,10 +879,6 @@<a href="#bytebase.store.Binding"><span class="badge">M</span>Binding</a></li>- <li>- <a href="#bytebase.store.DataSourceQueryPolicy"><span class="badge">M</span>DataSourceQueryPolicy</a>- </li>-<li><a href="#bytebase.store.IamPolicy"><span class="badge">M</span>IamPolicy</a></li>@@ -925,15 +921,15 @@<li>- <a href="#bytebase.store.DataSourceQueryPolicy.Restriction"><span class="badge">E</span>DataSourceQueryPolicy.Restriction</a>+ <a href="#bytebase.store.Policy.Resource"><span class="badge">E</span>Policy.Resource</a></li><li>- <a href="#bytebase.store.Policy.Resource"><span class="badge">E</span>Policy.Resource</a>+ <a href="#bytebase.store.Policy.Type"><span class="badge">E</span>Policy.Type</a></li><li>- <a href="#bytebase.store.Policy.Type"><span class="badge">E</span>Policy.Type</a>+ <a href="#bytebase.store.QueryDataPolicy.Restriction"><span class="badge">E</span>QueryDataPolicy.Restriction</a></li>@@ -9037,44 +9033,6 @@ If the condition evaluates to false, then this binding does not apply to the cur- <h3 id="bytebase.store.DataSourceQueryPolicy">DataSourceQueryPolicy</h3>- <p>DataSourceQueryPolicy is the policy configuration for running statements in the SQL editor.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>admin_data_source_restriction</td>- <td><a href="#bytebase.store.DataSourceQueryPolicy.Restriction">DataSourceQueryPolicy.Restriction</a></td>- <td></td>- <td><p> </p></td>- </tr>-- <tr>- <td>disallow_ddl</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Disallow running DDL statements in the SQL editor. </p></td>- </tr>-- <tr>- <td>disallow_dml</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Disallow running DML statements in the SQL editor. </p></td>- </tr>-- </tbody>- </table>-----<h3 id="bytebase.store.IamPolicy">IamPolicy</h3><p></p>@@ -9288,6 +9246,27 @@ The default value is -1, means no limit. </p></td><td><p>Disable copying data. </p></td></tr>+ <tr>+ <td>admin_data_source_restriction</td>+ <td><a href="#bytebase.store.QueryDataPolicy.Restriction">QueryDataPolicy.Restriction</a></td>+ <td></td>+ <td><p>Restriction for admin data source queries. </p></td>+ </tr>++ <tr>+ <td>disallow_ddl</td>+ <td><a href="#bool">bool</a></td>+ <td></td>+ <td><p>Disallow running DDL statements in the SQL editor. </p></td>+ </tr>++ <tr>+ <td>disallow_dml</td>+ <td><a href="#bool">bool</a></td>+ <td></td>+ <td><p>Disallow running DML statements in the SQL editor. </p></td>+ </tr>+</tbody></table>@@ -9384,35 +9363,6 @@ For example, the environment resource can have the SQL review config tag, such a- <h3 id="bytebase.store.DataSourceQueryPolicy.Restriction">DataSourceQueryPolicy.Restriction</h3>- <p></p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>RESTRICTION_UNSPECIFIED</td>- <td>0</td>- <td><p></p></td>- </tr>-- <tr>- <td>FALLBACK</td>- <td>1</td>- <td><p>Allow to query admin data sources when there is no read-only data source.</p></td>- </tr>-- <tr>- <td>DISALLOW</td>- <td>2</td>- <td><p>Disallow to query admin data sources.</p></td>- </tr>-- </tbody>- </table>-<h3 id="bytebase.store.Policy.Resource">Policy.Resource</h3><p></p><table class="enum-table">@@ -9498,12 +9448,35 @@ For example, the environment resource can have the SQL review config tag, such a<td><p></p></td></tr>+ </tbody>+ </table>++ <h3 id="bytebase.store.QueryDataPolicy.Restriction">QueryDataPolicy.Restriction</h3>+ <p></p>+ <table class="enum-table">+ <thead>+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>+ </thead>+ <tbody>+<tr>- <td>DATA_SOURCE_QUERY</td>- <td>7</td>+ <td>RESTRICTION_UNSPECIFIED</td>+ <td>0</td><td><p></p></td></tr>+ <tr>+ <td>FALLBACK</td>+ <td>1</td>+ <td><p>Allow to query admin data sources when there is no read-only data source.</p></td>+ </tr>++ <tr>+ <td>DISALLOW</td>+ <td>2</td>+ <td><p>Disallow to query admin data sources.</p></td>+ </tr>+</tbody></table>diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 8473a6bec5..1c8d4b4168 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -334,7 +334,6 @@- [v1/org_policy_service.proto](#v1_org_policy_service-proto)- [CreatePolicyRequest](#bytebase-v1-CreatePolicyRequest)- - [DataSourceQueryPolicy](#bytebase-v1-DataSourceQueryPolicy)- [DeletePolicyRequest](#bytebase-v1-DeletePolicyRequest)- [GetPolicyRequest](#bytebase-v1-GetPolicyRequest)- [ListPoliciesRequest](#bytebase-v1-ListPoliciesRequest)@@ -350,9 +349,9 @@- [TagPolicy.TagsEntry](#bytebase-v1-TagPolicy-TagsEntry)- [UpdatePolicyRequest](#bytebase-v1-UpdatePolicyRequest)- - [DataSourceQueryPolicy.Restriction](#bytebase-v1-DataSourceQueryPolicy-Restriction)- [PolicyResourceType](#bytebase-v1-PolicyResourceType)- [PolicyType](#bytebase-v1-PolicyType)+ - [QueryDataPolicy.Restriction](#bytebase-v1-QueryDataPolicy-Restriction)- [OrgPolicyService](#bytebase-v1-OrgPolicyService)@@ -5672,23 +5671,6 @@ IssueService manages issues for tracking database changes and tasks.-<a name="bytebase-v1-DataSourceQueryPolicy"></a>--### DataSourceQueryPolicy-Policy for controlling which data sources can be queried in the SQL editor.---| Field | Type | Label | Description |-| ----- | ---- | ----- | ----------- |-| admin_data_source_restriction | [DataSourceQueryPolicy.Restriction](#bytebase-v1-DataSourceQueryPolicy-Restriction) | | Restriction for admin data source queries. |-| disallow_ddl | [bool](#bool) | | Disallow running DDL statements in the SQL editor. |-| disallow_dml | [bool](#bool) | | Disallow running DML statements in the SQL editor. |------<a name="bytebase-v1-DeletePolicyRequest"></a>### DeletePolicyRequest@@ -5839,7 +5821,6 @@ For example: resource.environment_id == "test" && resource.proje| masking_rule_policy | [MaskingRulePolicy](#bytebase-v1-MaskingRulePolicy) | | || masking_exemption_policy | [MaskingExemptionPolicy](#bytebase-v1-MaskingExemptionPolicy) | | || tag_policy | [TagPolicy](#bytebase-v1-TagPolicy) | | |-| data_source_query_policy | [DataSourceQueryPolicy](#bytebase-v1-DataSourceQueryPolicy) | | || query_data_policy | [QueryDataPolicy](#bytebase-v1-QueryDataPolicy) | | || enforce | [bool](#bool) | | Whether the policy is enforced. || resource_type | [PolicyResourceType](#bytebase-v1-PolicyResourceType) | | The resource type for the policy. |@@ -5862,6 +5843,9 @@ QueryDataPolicy is the policy configuration for querying data.| maximum_result_size | [int64](#int64) | | The maximum result size limit in bytes. The default value is 100MB, we will use the default value if the setting not exists, or the limit <= 0. || maximum_result_rows | [int32](#int32) | | The maximum number of rows to return. The default value is -1, means no limit. || disable_copy_data | [bool](#bool) | | Disable copying query results. |+| admin_data_source_restriction | [QueryDataPolicy.Restriction](#bytebase-v1-QueryDataPolicy-Restriction) | | Restriction for admin data source queries. |+| disallow_ddl | [bool](#bool) | | Disallow running DDL statements in the SQL editor. |+| disallow_dml | [bool](#bool) | | Disallow running DML statements in the SQL editor. |@@ -5936,19 +5920,6 @@ The policy's `name` field is used to identify the instance to update. Format-<a name="bytebase-v1-DataSourceQueryPolicy-Restriction"></a>--### DataSourceQueryPolicy.Restriction-Restriction level for admin data source access.--| Name | Number | Description |-| ---- | ------ | ----------- |-| RESTRICTION_UNSPECIFIED | 0 | Unspecified restriction. |-| FALLBACK | 1 | Allow querying admin data sources when there is no read-only data source. |-| DISALLOW | 2 | Disallow querying admin data sources. |---<a name="bytebase-v1-PolicyResourceType"></a>### PolicyResourceType@@ -5975,10 +5946,22 @@ The type of organizational policy.| MASKING_EXEMPTION | 2 | Data masking exemption policy. || ROLLOUT_POLICY | 3 | Rollout deployment policy. || TAG | 4 | Resource tag policy. |-| DATA_SOURCE_QUERY | 5 | Data source query restrictions policy. || DATA_QUERY | 6 | Query data access policy. |++<a name="bytebase-v1-QueryDataPolicy-Restriction"></a>++### QueryDataPolicy.Restriction+Restriction level for admin data source access.++| Name | Number | Description |+| ---- | ------ | ----------- |+| RESTRICTION_UNSPECIFIED | 0 | Unspecified restriction. |+| FALLBACK | 1 | Allow querying admin data sources when there is no read-only data source. |+| DISALLOW | 2 | Disallow querying admin data sources. |++diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex f21a7925dd..f550a7cf79 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -1446,10 +1446,6 @@<a href="#bytebase.v1.CreatePolicyRequest"><span class="badge">M</span>CreatePolicyRequest</a></li>- <li>- <a href="#bytebase.v1.DataSourceQueryPolicy"><span class="badge">M</span>DataSourceQueryPolicy</a>- </li>-<li><a href="#bytebase.v1.DeletePolicyRequest"><span class="badge">M</span>DeletePolicyRequest</a></li>@@ -1508,15 +1504,15 @@<li>- <a href="#bytebase.v1.DataSourceQueryPolicy.Restriction"><span class="badge">E</span>DataSourceQueryPolicy.Restriction</a>+ <a href="#bytebase.v1.PolicyResourceType"><span class="badge">E</span>PolicyResourceType</a></li><li>- <a href="#bytebase.v1.PolicyResourceType"><span class="badge">E</span>PolicyResourceType</a>+ <a href="#bytebase.v1.PolicyType"><span class="badge">E</span>PolicyType</a></li><li>- <a href="#bytebase.v1.PolicyType"><span class="badge">E</span>PolicyType</a>+ <a href="#bytebase.v1.QueryDataPolicy.Restriction"><span class="badge">E</span>QueryDataPolicy.Restriction</a></li>@@ -16458,44 +16454,6 @@ Database resource name: instances/instance-id/databases/database-name. </p></td>- <h3 id="bytebase.v1.DataSourceQueryPolicy">DataSourceQueryPolicy</h3>- <p>Policy for controlling which data sources can be queried in the SQL editor.</p>--- <table class="field-table">- <thead>- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>admin_data_source_restriction</td>- <td><a href="#bytebase.v1.DataSourceQueryPolicy.Restriction">DataSourceQueryPolicy.Restriction</a></td>- <td></td>- <td><p>Restriction for admin data source queries. </p></td>- </tr>-- <tr>- <td>disallow_ddl</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Disallow running DDL statements in the SQL editor. </p></td>- </tr>-- <tr>- <td>disallow_dml</td>- <td><a href="#bool">bool</a></td>- <td></td>- <td><p>Disallow running DML statements in the SQL editor. </p></td>- </tr>-- </tbody>- </table>-----<h3 id="bytebase.v1.DeletePolicyRequest">DeletePolicyRequest</h3><p></p>@@ -16833,13 +16791,6 @@ Database resource name: instances/instance-id/databases/database-name. </p></td><td><p> </p></td></tr>- <tr>- <td>data_source_query_policy</td>- <td><a href="#bytebase.v1.DataSourceQueryPolicy">DataSourceQueryPolicy</a></td>- <td></td>- <td><p> </p></td>- </tr>-<tr><td>query_data_policy</td><td><a href="#bytebase.v1.QueryDataPolicy">QueryDataPolicy</a></td>@@ -16915,6 +16866,27 @@ The default value is -1, means no limit. </p></td><td><p>Disable copying query results. </p></td></tr>+ <tr>+ <td>admin_data_source_restriction</td>+ <td><a href="#bytebase.v1.QueryDataPolicy.Restriction">QueryDataPolicy.Restriction</a></td>+ <td></td>+ <td><p>Restriction for admin data source queries. </p></td>+ </tr>++ <tr>+ <td>disallow_ddl</td>+ <td><a href="#bool">bool</a></td>+ <td></td>+ <td><p>Disallow running DDL statements in the SQL editor. </p></td>+ </tr>++ <tr>+ <td>disallow_dml</td>+ <td><a href="#bool">bool</a></td>+ <td></td>+ <td><p>Disallow running DML statements in the SQL editor. </p></td>+ </tr>+</tbody></table>@@ -17057,35 +17029,6 @@ In this situation, `update_mask` is ignored. </p></td>- <h3 id="bytebase.v1.DataSourceQueryPolicy.Restriction">DataSourceQueryPolicy.Restriction</h3>- <p>Restriction level for admin data source access.</p>- <table class="enum-table">- <thead>- <tr><td>Name</td><td>Number</td><td>Description</td></tr>- </thead>- <tbody>-- <tr>- <td>RESTRICTION_UNSPECIFIED</td>- <td>0</td>- <td><p>Unspecified restriction.</p></td>- </tr>-- <tr>- <td>FALLBACK</td>- <td>1</td>- <td><p>Allow querying admin data sources when there is no read-only data source.</p></td>- </tr>-- <tr>- <td>DISALLOW</td>- <td>2</td>- <td><p>Disallow querying admin data sources.</p></td>- </tr>-- </tbody>- </table>-<h3 id="bytebase.v1.PolicyResourceType">PolicyResourceType</h3><p>The resource type that a policy can be attached to.</p><table class="enum-table">@@ -17159,12 +17102,6 @@ In this situation, `update_mask` is ignored. </p></td><td><p>Resource tag policy.</p></td></tr>- <tr>- <td>DATA_SOURCE_QUERY</td>- <td>5</td>- <td><p>Data source query restrictions policy.</p></td>- </tr>-<tr><td>DATA_QUERY</td><td>6</td>@@ -17174,6 +17111,35 @@ In this situation, `update_mask` is ignored. </p></td></tbody></table>+ <h3 id="bytebase.v1.QueryDataPolicy.Restriction">QueryDataPolicy.Restriction</h3>+ <p>Restriction level for admin data source access.</p>+ <table class="enum-table">+ <thead>+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>+ </thead>+ <tbody>++ <tr>+ <td>RESTRICTION_UNSPECIFIED</td>+ <td>0</td>+ <td><p>Unspecified restriction.</p></td>+ </tr>++ <tr>+ <td>FALLBACK</td>+ <td>1</td>+ <td><p>Allow querying admin data sources when there is no read-only data source.</p></td>+ </tr>++ <tr>+ <td>DISALLOW</td>+ <td>2</td>+ <td><p>Disallow querying admin data sources.</p></td>+ </tr>++ </tbody>+ </table>+diff --git a/proto/store/store/policy.proto b/proto/store/store/policy.protoindex 0c41a23ebe..f1c441efeb 100644--- a/proto/store/store/policy.proto+++ b/proto/store/store/policy.proto@@ -16,7 +16,6 @@ message Policy {MASKING_RULE = 4;IAM = 5;TAG = 6;- DATA_SOURCE_QUERY = 7;}enum Resource {@@ -120,10 +119,7 @@ message QueryDataPolicy {// Disable copying data.bool disable_copy_data = 5;-}-// DataSourceQueryPolicy is the policy configuration for running statements in the SQL editor.-message DataSourceQueryPolicy {enum Restriction {RESTRICTION_UNSPECIFIED = 0;// Allow to query admin data sources when there is no read-only data source.@@ -131,10 +127,11 @@ message DataSourceQueryPolicy {// Disallow to query admin data sources.DISALLOW = 2;}- Restriction admin_data_source_restriction = 1;+ // Restriction for admin data source queries.+ Restriction admin_data_source_restriction = 6;// Disallow running DDL statements in the SQL editor.- bool disallow_ddl = 2;+ bool disallow_ddl = 7;// Disallow running DML statements in the SQL editor.- bool disallow_dml = 3;+ bool disallow_dml = 8;}diff --git a/proto/v1/v1/org_policy_service.proto b/proto/v1/v1/org_policy_service.protoindex 089921dd71..331a819f03 100644--- a/proto/v1/v1/org_policy_service.proto+++ b/proto/v1/v1/org_policy_service.proto@@ -235,7 +235,6 @@ message Policy {MaskingRulePolicy masking_rule_policy = 5;MaskingExemptionPolicy masking_exemption_policy = 6;TagPolicy tag_policy = 7;- DataSourceQueryPolicy data_source_query_policy = 8;QueryDataPolicy query_data_policy = 9;}@@ -258,8 +257,6 @@ enum PolicyType {ROLLOUT_POLICY = 3;// Resource tag policy.TAG = 4;- // Data source query restrictions policy.- DATA_SOURCE_QUERY = 5;// Query data access policy.DATA_QUERY = 6;}@@ -302,6 +299,23 @@ message QueryDataPolicy {// Disable copying query results.bool disable_copy_data = 5;++ // Restriction level for admin data source access.+ enum Restriction {+ // Unspecified restriction.+ RESTRICTION_UNSPECIFIED = 0;+ // Allow querying admin data sources when there is no read-only data source.+ FALLBACK = 1;+ // Disallow querying admin data sources.+ DISALLOW = 2;+ }+ // Restriction for admin data source queries.+ Restriction admin_data_source_restriction = 6;++ // Disallow running DDL statements in the SQL editor.+ bool disallow_ddl = 7;+ // Disallow running DML statements in the SQL editor.+ bool disallow_dml = 8;}// MaskingExemptionPolicy is the allowlist of users who can access sensitive data.@@ -379,23 +393,3 @@ message TagPolicy {// for example, the environment resource can have the sql review config tag, like "bb.tag.review_config": "reviewConfigs/{review config resource id}"map<string, string> tags = 1;}--// Policy for controlling which data sources can be queried in the SQL editor.-message DataSourceQueryPolicy {- // Restriction level for admin data source access.- enum Restriction {- // Unspecified restriction.- RESTRICTION_UNSPECIFIED = 0;- // Allow querying admin data sources when there is no read-only data source.- FALLBACK = 1;- // Disallow querying admin data sources.- DISALLOW = 2;- }- // Restriction for admin data source queries.- Restriction admin_data_source_restriction = 1;-- // Disallow running DDL statements in the SQL editor.- bool disallow_ddl = 2;- // Disallow running DML statements in the SQL editor.- bool disallow_dml = 3;-}