Skip to content

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

feat: standardize CEL attribute naming with resource.* prefix (#17660)

Danny Xud0f01a0d04b8
diff --git a/backend/api/v1/masking_evaluator.go b/backend/api/v1/masking_evaluator.go
index c4c1cbd6e5..bdc617d20c 100644
--- a/backend/api/v1/masking_evaluator.go
+++ b/backend/api/v1/masking_evaluator.go
@@ -136,17 +136,17 @@ func (m *maskingLevelEvaluator) evaluateGlobalMaskingLevelOfColumn(
classificationLevel := getClassificationLevelOfColumn(columnConfig.GetClassification(), dataClassificationConfig)
for _, maskingRule := range m.maskingRules {
maskingRuleAttributes := map[string]any{
- "environment_id": "",
- "project_id": databaseMessage.ProjectID,
- "instance_id": databaseMessage.InstanceID,
- "database_name": databaseMessage.DatabaseName,
- "schema_name": schemaName,
- "table_name": tableName,
- "column_name": columnName,
- "classification_level": classificationLevel,
+ "resource.environment_id": "",
+ "resource.project_id": databaseMessage.ProjectID,
+ "resource.instance_id": databaseMessage.InstanceID,
+ "resource.database_name": databaseMessage.DatabaseName,
+ "resource.schema_name": schemaName,
+ "resource.table_name": tableName,
+ "resource.column_name": columnName,
+ "resource.classification_level": classificationLevel,
}
if databaseMessage.EffectiveEnvironmentID != nil {
- maskingRuleAttributes["environment_id"] = *databaseMessage.EffectiveEnvironmentID
+ maskingRuleAttributes["resource.environment_id"] = *databaseMessage.EffectiveEnvironmentID
}
pass, err := evaluateMaskingRulePolicyCondition(maskingRule.Condition.Expression, maskingRuleAttributes)
if err != nil {
diff --git a/backend/api/v1/masking_evaluator_test.go b/backend/api/v1/masking_evaluator_test.go
index aabb17035b..e454e8d563 100644
--- a/backend/api/v1/masking_evaluator_test.go
+++ b/backend/api/v1/masking_evaluator_test.go
@@ -98,7 +98,7 @@ func TestEvalMaskingLevelOfColumn(t *testing.T) {
Rules: []*storepb.MaskingRulePolicy_MaskingRule{
{
// Classification hit.
- Condition: &expr.Expr{Expression: `(table_name == "no_table") || (classification_level == "S2")`},
+ Condition: &expr.Expr{Expression: `(resource.table_name == "no_table") || (resource.classification_level == "S2")`},
SemanticType: "default",
},
},
@@ -124,7 +124,7 @@ func TestEvalMaskingLevelOfColumn(t *testing.T) {
Rules: []*storepb.MaskingRulePolicy_MaskingRule{
{
// Classification hit.
- Condition: &expr.Expr{Expression: `(table_name == "no_table") || (classification_level == "S2")`},
+ Condition: &expr.Expr{Expression: `(resource.table_name == "no_table") || (resource.classification_level == "S2")`},
SemanticType: "default",
},
},
diff --git a/backend/api/v1/release_service_check.go b/backend/api/v1/release_service_check.go
index 7dc9f33852..630a093492 100644
--- a/backend/api/v1/release_service_check.go
+++ b/backend/api/v1/release_service_check.go
@@ -242,16 +242,16 @@ loop:
resp.AffectedRows += summaryReport.AffectedRows
commonArgs := map[string]any{
- "environment_id": "",
- "project_id": database.ProjectID,
- "instance_id": instance.ResourceID,
- "database_name": database.DatabaseName,
+ "resource.environment_id": "",
+ "resource.project_id": database.ProjectID,
+ "resource.instance_id": instance.ResourceID,
+ "resource.database_name": database.DatabaseName,
// convert to string type otherwise cel-go will complain that storepb.Engine is not string type.
- "db_engine": engine.String(),
- "sql_statement": statement,
+ "resource.db_engine": engine.String(),
+ "sql_statement": statement,
}
if database.EffectiveEnvironmentID != nil {
- commonArgs["environment_id"] = *database.EffectiveEnvironmentID
+ commonArgs["resource.environment_id"] = *database.EffectiveEnvironmentID
}
riskLevel, err := CalculateRiskLevelWithOptionalSummaryReport(ctx, risks, commonArgs, getRiskSourceFromChangeType(changeType), summaryReport)
if err != nil {
diff --git a/backend/api/v1/risk_service_calculator.go b/backend/api/v1/risk_service_calculator.go
index 721ee9691a..7869fee44f 100644
--- a/backend/api/v1/risk_service_calculator.go
+++ b/backend/api/v1/risk_service_calculator.go
@@ -96,7 +96,7 @@ func CalculateRiskLevelWithOptionalSummaryReport(
for _, statementType := range summaryReport.StatementTypes {
args["sql_type"] = statementType
for _, tableName := range tableNames {
- args["table_name"] = tableName
+ args["resource.table_name"] = tableName
out, _, err := prg.Eval(args)
if err != nil {
return 0, errors.Wrap(err, "failed to eval expression")
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index 6abd2bccd3..ba22a6e32f 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -1429,11 +1429,11 @@ func (s *SQLService) accessCheck(
if span.Type == parserbase.Select {
for column := range span.SourceColumns {
attributes := map[string]any{
- "request.time": time.Now(),
- "request.row_limit": limit,
- "resource.database": common.FormatDatabase(instance.ResourceID, column.Database),
- "resource.schema": column.Schema,
- "resource.table": column.Table,
+ "request.time": time.Now(),
+ "request.row_limit": limit,
+ "resource.database": common.FormatDatabase(instance.ResourceID, column.Database),
+ "resource.schema_name": column.Schema,
+ "resource.table_name": column.Table,
}
databaseMessage, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{
@@ -1471,10 +1471,10 @@ func (s *SQLService) accessCheck(
}
if !ok {
resource := attributes["resource.database"]
- if schema, ok := attributes["resource.schema"]; ok && schema != "" {
+ if schema, ok := attributes["resource.schema_name"]; ok && schema != "" {
resource = fmt.Sprintf("%s/schemas/%s", resource, schema)
}
- if table, ok := attributes["resource.table"]; ok && table != "" {
+ if table, ok := attributes["resource.table_name"]; ok && table != "" {
resource = fmt.Sprintf("%s/tables/%s", resource, table)
}
return connect.NewError(
diff --git a/backend/common/cel.go b/backend/common/cel.go
index c2c00bb1a5..66d0332d08 100644
--- a/backend/common/cel.go
+++ b/backend/common/cel.go
@@ -16,14 +16,14 @@ const celLimit = 1024 * 1024
// RiskFactors are the variables when evaluating the risk level.
var RiskFactors = []cel.EnvOption{
- cel.Variable("environment_id", cel.StringType), // use environment.resource_id
- cel.Variable("project_id", cel.StringType), // use project.resource_id
- cel.Variable("instance_id", cel.StringType), // use instance.resource_id
- cel.Variable("db_engine", cel.StringType),
+ cel.Variable("resource.environment_id", cel.StringType),
+ cel.Variable("resource.project_id", cel.StringType),
+ cel.Variable("resource.instance_id", cel.StringType),
+ cel.Variable("resource.db_engine", cel.StringType),
- cel.Variable("database_name", cel.StringType),
- cel.Variable("schema_name", cel.StringType),
- cel.Variable("table_name", cel.StringType),
+ cel.Variable("resource.database_name", cel.StringType),
+ cel.Variable("resource.schema_name", cel.StringType),
+ cel.Variable("resource.table_name", cel.StringType),
cel.Variable("affected_rows", cel.IntType),
cel.Variable("table_rows", cel.IntType),
@@ -43,10 +43,10 @@ var ApprovalFactors = []cel.EnvOption{
// IAMPolicyConditionCELAttributes are the variables when evaluating IAM policy condition.
var IAMPolicyConditionCELAttributes = []cel.EnvOption{
- cel.Variable("resource.environment_name", cel.StringType),
+ cel.Variable("resource.environment_id", cel.StringType),
cel.Variable("resource.database", cel.StringType),
- cel.Variable("resource.schema", cel.StringType),
- cel.Variable("resource.table", cel.StringType),
+ cel.Variable("resource.schema_name", cel.StringType),
+ cel.Variable("resource.table_name", cel.StringType),
cel.Variable("request.row_limit", cel.IntType),
cel.Variable("request.time", cel.TimestampType),
cel.ParserExpressionSizeLimit(celLimit),
@@ -54,14 +54,14 @@ var IAMPolicyConditionCELAttributes = []cel.EnvOption{
// MaskingRulePolicyCELAttributes are the variables when evaluating masking rule.
var MaskingRulePolicyCELAttributes = []cel.EnvOption{
- cel.Variable("environment_id", cel.StringType),
- cel.Variable("project_id", cel.StringType),
- cel.Variable("instance_id", cel.StringType),
- cel.Variable("database_name", cel.StringType),
- cel.Variable("schema_name", cel.StringType),
- cel.Variable("table_name", cel.StringType),
- cel.Variable("column_name", cel.StringType),
- cel.Variable("classification_level", cel.StringType),
+ cel.Variable("resource.environment_id", cel.StringType),
+ cel.Variable("resource.project_id", cel.StringType),
+ cel.Variable("resource.instance_id", cel.StringType),
+ cel.Variable("resource.database_name", cel.StringType),
+ cel.Variable("resource.schema_name", cel.StringType),
+ cel.Variable("resource.table_name", cel.StringType),
+ cel.Variable("resource.column_name", cel.StringType),
+ cel.Variable("resource.classification_level", cel.StringType),
cel.ParserExpressionSizeLimit(celLimit),
}
@@ -76,6 +76,15 @@ var MaskingExceptionPolicyCELAttributes = []cel.EnvOption{
cel.ParserExpressionSizeLimit(celLimit),
}
+// DatabaseGroupCELAttributes are the variables when evaluating database group conditions.
+var DatabaseGroupCELAttributes = []cel.EnvOption{
+ cel.Variable("resource.environment_id", cel.StringType),
+ cel.Variable("resource.instance_id", cel.StringType),
+ cel.Variable("resource.database_name", cel.StringType),
+ cel.Variable("resource.database_labels", cel.MapType(cel.StringType, cel.StringType)),
+ cel.ParserExpressionSizeLimit(celLimit),
+}
+
// ConvertUnparsedRisk converts unparsed risk to parsed format.
func ConvertUnparsedRisk(expression *expr.Expr) (*exprproto.ParsedExpr, error) {
if expression == nil || expression.Expression == "" {
@@ -120,9 +129,7 @@ func ConvertUnparsedApproval(expression *expr.Expr) (*exprproto.ParsedExpr, erro
// ValidateGroupCELExpr validates group expr.
func ValidateGroupCELExpr(expr string) (cel.Program, error) {
- e, err := cel.NewEnv(
- cel.Variable("resource", cel.MapType(cel.StringType, cel.AnyType)),
- )
+ e, err := cel.NewEnv(DatabaseGroupCELAttributes...)
if err != nil {
return nil, err
}
diff --git a/backend/common/cel_test.go b/backend/common/cel_test.go
index 3c2b570eee..d558477005 100644
--- a/backend/common/cel_test.go
+++ b/backend/common/cel_test.go
@@ -79,7 +79,7 @@ func TestGetQueryExportFactors(t *testing.T) {
want QueryExportFactors
}{
{
- expression: "request.time < timestamp(\"2023-07-04T06:09:03.384Z\") && request.row_limit == 1000 && (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema == \"public\" && resource.table in [\"dept_manager\"])",
+ expression: "request.time < timestamp(\"2023-07-04T06:09:03.384Z\") && request.row_limit == 1000 && (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema_name == \"public\" && resource.table_name in [\"dept_manager\"])",
want: QueryExportFactors{
Databases: []string{"instances/postgres-sample/databases/employee"},
},
@@ -91,7 +91,7 @@ func TestGetQueryExportFactors(t *testing.T) {
},
},
{
- expression: "request.time < timestamp(\"2023-08-02T07:33:45.686Z\") && (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema == \"public\" && resource.table in [\"dept_emp\",\"department\"])",
+ expression: "request.time < timestamp(\"2023-08-02T07:33:45.686Z\") && (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema_name == \"public\" && resource.table_name in [\"dept_emp\",\"department\"])",
want: QueryExportFactors{
Databases: []string{"instances/postgres-sample/databases/employee"},
},
@@ -101,7 +101,7 @@ func TestGetQueryExportFactors(t *testing.T) {
want: QueryExportFactors{},
},
{
- expression: "request.time < timestamp(\"2023-07-10T08:15:46.773Z\") && ((resource.database in [\"instances/postgres-sample/databases/blog\"]) || (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema in [\"public\"]))",
+ expression: "request.time < timestamp(\"2023-07-10T08:15:46.773Z\") && ((resource.database in [\"instances/postgres-sample/databases/blog\"]) || (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema_name in [\"public\"]))",
want: QueryExportFactors{
Databases: []string{"instances/postgres-sample/databases/blog", "instances/postgres-sample/databases/employee"},
},
diff --git a/backend/generated-go/v1/database_group_service.pb.go b/backend/generated-go/v1/database_group_service.pb.go
index 1db883ac68..fa1724b44c 100644
--- a/backend/generated-go/v1/database_group_service.pb.go
+++ b/backend/generated-go/v1/database_group_service.pb.go
@@ -471,13 +471,15 @@ type DatabaseGroup struct {
// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
//
// Support variables:
- // resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ // resource.environment_id: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
// resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
// resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ // resource.database_labels: the database labels. Support map access operations.
// All variables should join with "&&" condition.
//
// For example:
- // resource.environment_name == "test" && resource.database_name.startsWith("sample_")
+ // resource.environment_id == "test" && resource.database_name.startsWith("sample_")
+ // resource.database_labels["tenant"] == "tenant1"
DatabaseExpr *expr.Expr `protobuf:"bytes,3,opt,name=database_expr,json=databaseExpr,proto3" json:"database_expr,omitempty"`
// The list of databases that match the database group condition.
MatchedDatabases []*DatabaseGroup_Database `protobuf:"bytes,4,rep,name=matched_databases,json=matchedDatabases,proto3" json:"matched_databases,omitempty"`
diff --git a/backend/generated-go/v1/iam_policy.pb.go b/backend/generated-go/v1/iam_policy.pb.go
index 493f0901a8..b52f39b828 100644
--- a/backend/generated-go/v1/iam_policy.pb.go
+++ b/backend/generated-go/v1/iam_policy.pb.go
@@ -258,14 +258,14 @@ type Binding struct {
//
// Support variables:
// resource.database: the database full name in "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" role, support "==" operator.
- // resource.schema: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
- // resource.table: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ // resource.schema_name: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ // resource.table_name: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
// request.time: the expiration. Only support "<" operation in `request.time < timestamp("{ISO datetime string format}")`.
// request.row_limit: the maximum export rows, used by the "roles/sqlEditorUser" role. Only support "<=" operation.
//
// For example:
- // resource.database == "instances/local-pg/databases/postgres" && resource.schema in ["public","another_schema"]
- // resource.database == "instances/local-pg/databases/bytebase" && resource.schema == "public" && resource.table in ["audit_log"]
+ // resource.database == "instances/local-pg/databases/postgres" && resource.schema_name in ["public","another_schema"]
+ // resource.database == "instances/local-pg/databases/bytebase" && resource.schema_name == "public" && resource.table_name in ["audit_log"]
// request.time < timestamp("2025-04-26T11:24:48.655Z") && request.row_limit <= 1000
Condition *expr.Expr `protobuf:"bytes,3,opt,name=condition,proto3" json:"condition,omitempty"`
// The parsed expression of the condition.
diff --git a/backend/generated-go/v1/org_policy_service.pb.go b/backend/generated-go/v1/org_policy_service.pb.go
index 34289035c8..87cd6450be 100644
--- a/backend/generated-go/v1/org_policy_service.pb.go
+++ b/backend/generated-go/v1/org_policy_service.pb.go
@@ -1524,13 +1524,13 @@ type MaskingRulePolicy_MaskingRule struct {
// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
//
// Support variables:
- // environment_id: the environment resource id.
- // project_id: the project resource id.
- // instance_id: the instance resource id.
- // database_name: the database name.
- // table_name: the table name.
- // column_name: the column name.
- // classification_level: the classification level.
+ // resource.environment_id: the environment resource id.
+ // resource.project_id: the project resource id.
+ // resource.instance_id: the instance resource id.
+ // resource.database_name: the database name.
+ // resource.table_name: the table name.
+ // resource.column_name: the column name.
+ // resource.classification_level: the classification level.
//
// Each variable support following operations:
// ==: the value equals the target.
@@ -1539,10 +1539,10 @@ type MaskingRulePolicy_MaskingRule struct {
// !(in): the value not matches any of the targets.
//
// For example:
- // environment_id == "test" && project_id == "sample-project"
- // instance_id == "sample-instance" && database_name == "employee" && table_name in ["table1", "table2"]
- // environment_id != "test" || !(project_id in ["poject1", "prject2"])
- // instance_id == "sample-instance" && (database_name == "db1" || database_name == "db2")
+ // resource.environment_id == "test" && resource.project_id == "sample-project"
+ // resource.instance_id == "sample-instance" && resource.database_name == "employee" && resource.table_name in ["table1", "table2"]
+ // resource.environment_id != "test" || !(resource.project_id in ["poject1", "prject2"])
+ // resource.instance_id == "sample-instance" && (resource.database_name == "db1" || resource.database_name == "db2")
Condition *expr.Expr `protobuf:"bytes,2,opt,name=condition,proto3" json:"condition,omitempty"`
SemanticType string `protobuf:"bytes,3,opt,name=semantic_type,json=semanticType,proto3" json:"semantic_type,omitempty"`
unknownFields protoimpl.UnknownFields
diff --git a/backend/generated-go/v1/risk_service.pb.go b/backend/generated-go/v1/risk_service.pb.go
index 5e102ff3ba..a974e33a4c 100644
--- a/backend/generated-go/v1/risk_service.pb.go
+++ b/backend/generated-go/v1/risk_service.pb.go
@@ -418,17 +418,17 @@ type Risk struct {
// All supported variables:
// affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
// table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
- // environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
- // project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- // db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
+ // resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ // resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
// sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
//
// when the risk source is DDL, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L70 for supported values.
// when the risk source is DML, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L71 for supported values.
//
- // database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- // schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- // table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
// sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
// expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
// role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
@@ -436,31 +436,31 @@ type Risk struct {
// When the risk source is DDL/DML, support following variables:
// affected_rows
// table_rows
- // environment_id
- // project_id
- // db_engine
+ // resource.environment_id
+ // resource.project_id
+ // resource.db_engine
// sql_type
- // database_name
- // schema_name
- // table_name
+ // resource.database_name
+ // resource.schema_name
+ // resource.table_name
// sql_statement
//
// When the risk source is CREATE_DATABASE, support following variables:
- // environment_id
- // project_id
- // db_engine
- // database_name
+ // resource.environment_id
+ // resource.project_id
+ // resource.db_engine
+ // resource.database_name
//
// When the risk source is DATA_EXPORT, support following variables:
- // environment_id
- // project_id
- // db_engine
- // database_name
- // schema_name
- // table_name
+ // resource.environment_id
+ // resource.project_id
+ // resource.db_engine
+ // resource.database_name
+ // resource.schema_name
+ // resource.table_name
//
// When the risk source is REQUEST_ROLE, support following variables:
- // project_id
+ // resource.project_id
// expiration_days
// role
Condition *expr.Expr `protobuf:"bytes,8,opt,name=condition,proto3" json:"condition,omitempty"`
diff --git a/backend/migrator/migration/3.11/0004##migrate_cel_attribute_names.sql b/backend/migrator/migration/3.11/0004##migrate_cel_attribute_names.sql
new file mode 100644
index 0000000000..ba8e3e67c3
--- /dev/null
+++ b/backend/migrator/migration/3.11/0004##migrate_cel_attribute_names.sql
@@ -0,0 +1,219 @@
+-- Migrate CEL attribute names to use consistent resource.* prefix pattern
+--
+-- This migration updates all CEL expressions stored in the database to use the new naming convention
+-- following Google AIP-140 standards for consistent snake_case field naming.
+--
+-- Attribute name changes (adding resource.* prefix):
+-- 1. environment_id -> resource.environment_id
+-- 2. project_id -> resource.project_id
+-- 3. instance_id -> resource.instance_id
+-- 4. db_engine -> resource.db_engine
+-- 5. database_name -> resource.database_name
+-- 6. schema_name -> resource.schema_name
+-- 7. table_name -> resource.table_name
+--
+-- Attribute name changes (renaming for consistency):
+-- 8. resource.environment_name -> resource.environment_id (in IAM policies)
+-- 9. resource.schema -> resource.schema_name (in IAM policies)
+-- 10. resource.table -> resource.table_name (in IAM policies)
+-- 11. resource.labels -> resource.database_labels (in database groups)
+--
+-- Affected tables:
+-- - risk: Risk evaluation CEL expressions
+-- - db_group: Database group matching CEL expressions
+-- - policy (type='IAM'): IAM policy condition expressions
+-- - policy (type='MASKING_RULE'): Masking rule CEL expressions
+
+-- Update risk table expressions
+-- The risk.expression column stores CEL expressions in jsonb format with an "expression" field
+-- We need to add resource.* prefix to attributes that didn't have it
+-- Using regexp_replace to match whole identifiers (not partial matches)
+UPDATE risk
+SET expression = jsonb_set(
+ expression,
+ '{expression}',
+ to_jsonb(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ expression->>'expression',
+ '\m(environment_id)\M',
+ 'resource.environment_id',
+ 'g'
+ ),
+ '\m(project_id)\M',
+ 'resource.project_id',
+ 'g'
+ ),
+ '\m(instance_id)\M',
+ 'resource.instance_id',
+ 'g'
+ ),
+ '\m(db_engine)\M',
+ 'resource.db_engine',
+ 'g'
+ ),
+ '\m(database_name)\M',
+ 'resource.database_name',
+ 'g'
+ ),
+ '\m(schema_name)\M',
+ 'resource.schema_name',
+ 'g'
+ ),
+ '\m(table_name)\M',
+ 'resource.table_name',
+ 'g'
+ )
+ )
+)
+WHERE expression->>'expression' ~ '\m(environment_id|project_id|instance_id|db_engine|database_name|schema_name|table_name)\M';
+
+-- Update database group expressions
+-- The db_group.expression column stores CEL expressions in jsonb format with an "expression" field
+UPDATE db_group
+SET expression = jsonb_set(
+ expression,
+ '{expression}',
+ to_jsonb(
+ replace(
+ expression->>'expression',
+ 'resource.labels',
+ 'resource.database_labels'
+ )
+ )
+)
+WHERE expression->>'expression' LIKE '%resource.labels%';
+
+-- Update IAM policy conditions in policy table
+-- The policy.payload column stores IAM policies with bindings that may have condition expressions
+-- We need to iterate through the bindings array and update each condition
+-- Changes: resource.environment_name -> resource.environment_id
+-- resource.schema -> resource.schema_name
+-- resource.table -> resource.table_name
+UPDATE policy
+SET payload = (
+ SELECT jsonb_set(
+ payload,
+ '{bindings}',
+ (
+ SELECT jsonb_agg(
+ CASE
+ WHEN binding->>'condition' IS NOT NULL
+ THEN jsonb_set(
+ binding,
+ '{condition}',
+ to_jsonb(
+ replace(
+ replace(
+ replace(
+ binding->>'condition',
+ 'resource.environment_name',
+ 'resource.environment_id'
+ ),
+ 'resource.schema',
+ 'resource.schema_name'
+ ),
+ 'resource.table',
+ 'resource.table_name'
+ )
+ )
+ )
+ ELSE binding
+ END
+ )
+ FROM jsonb_array_elements(payload->'bindings') AS binding
+ )
+ )
+ FROM policy p2
+ WHERE p2.id = policy.id
+)
+WHERE type = 'IAM'
+ AND payload->'bindings' IS NOT NULL
+ AND EXISTS (
+ SELECT 1
+ FROM jsonb_array_elements(payload->'bindings') AS binding
+ WHERE binding->>'condition' LIKE '%resource.environment_name%'
+ OR binding->>'condition' LIKE '%resource.schema%'
+ OR binding->>'condition' LIKE '%resource.table%'
+ );
+
+-- Update masking rule policies in policy table
+-- The policy.payload column for masking rules contains a rules array with condition expressions
+-- Need to add resource.* prefix to attributes
+UPDATE policy
+SET payload = (
+ SELECT jsonb_set(
+ payload,
+ '{rules}',
+ (
+ SELECT jsonb_agg(
+ CASE
+ WHEN rule->'condition'->>'expression' IS NOT NULL
+ THEN jsonb_set(
+ rule,
+ '{condition,expression}',
+ to_jsonb(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ regexp_replace(
+ rule->'condition'->>'expression',
+ '\m(environment_id)\M',
+ 'resource.environment_id',
+ 'g'
+ ),
+ '\m(project_id)\M',
+ 'resource.project_id',
+ 'g'
+ ),
+ '\m(instance_id)\M',
+ 'resource.instance_id',
+ 'g'
+ ),
+ '\m(database_name)\M',
+ 'resource.database_name',
+ 'g'
+ ),
+ '\m(schema_name)\M',
+ 'resource.schema_name',
+ 'g'
+ ),
+ '\m(table_name)\M',
+ 'resource.table_name',
+ 'g'
+ ),
+ '\m(column_name)\M',
+ 'resource.column_name',
+ 'g'
+ ),
+ '\m(classification_level)\M',
+ 'resource.classification_level',
+ 'g'
+ )
+ )
+ )
+ ELSE rule
+ END
+ )
+ FROM jsonb_array_elements(payload->'rules') AS rule
+ )
+ )
+ FROM policy p2
+ WHERE p2.id = policy.id
+)
+WHERE type = 'MASKING_RULE'
+ AND payload->'rules' IS NOT NULL
+ AND EXISTS (
+ SELECT 1
+ FROM jsonb_array_elements(payload->'rules') AS rule
+ WHERE rule->'condition'->>'expression' ~ '\m(environment_id|project_id|instance_id|database_name|schema_name|table_name|column_name|classification_level)\M'
+ );
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index 5e74520494..85c5108402 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -12,7 +12,7 @@ import (
func TestLatestVersion(t *testing.T) {
files, err := getSortedVersionedFiles()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("3.11.3"), *files[len(files)-1].version)
+ require.Equal(t, semver.MustParse("3.11.4"), *files[len(files)-1].version)
}
func TestVersionUnique(t *testing.T) {
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 98aa09e5aa..294cf56459 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -463,13 +463,13 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I
}
commonArgs := map[string]any{
- "environment_id": environmentID,
- "project_id": issue.Project.ResourceID,
- "instance_id": instance.ResourceID,
- "database_name": databaseName,
+ "resource.environment_id": environmentID,
+ "resource.project_id": issue.Project.ResourceID,
+ "resource.instance_id": instance.ResourceID,
+ "resource.database_name": databaseName,
// convert to string type otherwise cel-go will complain that storepb.Engine is not string type.
- "db_engine": instance.Metadata.GetEngine().String(),
- "sql_statement": taskStatement,
+ "resource.db_engine": instance.Metadata.GetEngine().String(),
+ "sql_statement": taskStatement,
}
risk, err := func() (int32, error) {
// The summary report is not always available.
@@ -587,14 +587,14 @@ func (r *Runner) getDatabaseDataExportIssueRisk(ctx context.Context, issue *stor
return 0, err
}
args := map[string]any{
- "environment_id": "",
- "project_id": issue.Project.ResourceID,
- "instance_id": instance.ResourceID,
- "database_name": databaseName,
- "db_engine": instance.Metadata.GetEngine().String(),
+ "resource.environment_id": "",
+ "resource.project_id": issue.Project.ResourceID,
+ "resource.instance_id": instance.ResourceID,
+ "resource.database_name": databaseName,
+ "resource.db_engine": instance.Metadata.GetEngine().String(),
}
if environmentID != nil {
- args["environment_id"] = *environmentID
+ args["resource.environment_id"] = *environmentID
}
vars, err := e.PartialVars(args)
@@ -680,9 +680,9 @@ func (r *Runner) getGrantRequestIssueRisk(ctx context.Context, issue *store.Issu
}
args := map[string]any{
- "project_id": issue.Project.ResourceID,
- "expiration_days": expirationDays,
- "role": payload.GrantRequest.Role,
+ "resource.project_id": issue.Project.ResourceID,
+ "expiration_days": expirationDays,
+ "role": payload.GrantRequest.Role,
}
if len(factors.Databases) == 0 {
environments, err := r.store.GetEnvironmentSetting(ctx)
@@ -690,7 +690,7 @@ func (r *Runner) getGrantRequestIssueRisk(ctx context.Context, issue *store.Issu
return 0, store.RiskSourceUnknown, false, err
}
for _, environment := range environments.GetEnvironments() {
- args["environment_id"] = environment.Id
+ args["resource.environment_id"] = environment.Id
vars, err := e.PartialVars(args)
if err != nil {
return 0, store.RiskSourceUnknown, false, err
@@ -707,9 +707,9 @@ func (r *Runner) getGrantRequestIssueRisk(ctx context.Context, issue *store.Issu
for _, database := range databaseMap {
if database.EffectiveEnvironmentID != nil {
- args["environment_id"] = *database.EffectiveEnvironmentID
+ args["resource.environment_id"] = *database.EffectiveEnvironmentID
} else {
- args["environment_id"] = ""
+ args["resource.environment_id"] = ""
}
vars, err := e.PartialVars(args)
if err != nil {
diff --git a/backend/tests/grouping_change_test.go b/backend/tests/grouping_change_test.go
index 80556a826d..15fff05667 100644
--- a/backend/tests/grouping_change_test.go
+++ b/backend/tests/grouping_change_test.go
@@ -147,7 +147,7 @@ func TestCreateDatabaseGroup(t *testing.T) {
DatabaseGroup: &v1pb.DatabaseGroup{
Title: tc.databaseGroupPlaceholder,
DatabaseExpr: &expr.Expr{
- Expression: fmt.Sprintf(`(resource.environment_name == "environments/prod" && (%s))`, tc.databaseGroupExpr),
+ Expression: fmt.Sprintf(`(resource.environment_id == "environments/prod" && (%s))`, tc.databaseGroupExpr),
},
},
}))
diff --git a/backend/tests/risk_calculation_test.go b/backend/tests/risk_calculation_test.go
index 20d9f79b24..fc7d6d2b3e 100644
--- a/backend/tests/risk_calculation_test.go
+++ b/backend/tests/risk_calculation_test.go
@@ -56,7 +56,7 @@ func TestRiskLevelCalculation(t *testing.T) {
Level: 300, // HIGH risk level
Active: true,
Condition: &expr.Expr{
- Expression: `environment_id == "prod"`,
+ Expression: `resource.environment_id == "prod"`,
},
},
}))
@@ -183,7 +183,7 @@ func TestRiskLevelCalculationWithInvalidSQL(t *testing.T) {
Level: 300, // HIGH risk level
Active: true,
Condition: &expr.Expr{
- Expression: `environment_id == "prod"`,
+ Expression: `resource.environment_id == "prod"`,
},
},
}))
diff --git a/backend/utils/utils.go b/backend/utils/utils.go
index aaf081e429..f0fa229d17 100644
--- a/backend/utils/utils.go
+++ b/backend/utils/utils.go
@@ -201,12 +201,10 @@ func CheckDatabaseGroupMatch(ctx context.Context, expression string, database *s
effectiveEnvironmentID = *database.EffectiveEnvironmentID
}
res, _, err := prog.ContextEval(ctx, map[string]any{
- "resource": map[string]any{
- "database_name": database.DatabaseName,
- "environment_name": common.FormatEnvironment(effectiveEnvironmentID),
- "instance_id": database.InstanceID,
- "labels": database.Metadata.Labels,
- },
+ "resource.database_name": database.DatabaseName,
+ "resource.environment_id": common.FormatEnvironment(effectiveEnvironmentID),
+ "resource.instance_id": database.InstanceID,
+ "resource.database_labels": database.Metadata.Labels,
})
if err != nil {
return false, connect.NewError(connect.CodeInternal, err)
diff --git a/backend/utils/utils_test.go b/backend/utils/utils_test.go
index 8f7b3d8b2e..05b393abd5 100644
--- a/backend/utils/utils_test.go
+++ b/backend/utils/utils_test.go
@@ -18,7 +18,7 @@ func TestCheckDatabaseGroupMatch(t *testing.T) {
match bool
}{
{
- expression: `resource.labels.unit == "gcp"`,
+ expression: `resource.database_labels.unit == "gcp"`,
database: &store.DatabaseMessage{
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -29,7 +29,7 @@ func TestCheckDatabaseGroupMatch(t *testing.T) {
match: true,
},
{
- expression: `resource.labels.unit == "aws"`,
+ expression: `resource.database_labels.unit == "aws"`,
database: &store.DatabaseMessage{
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
@@ -40,7 +40,7 @@ func TestCheckDatabaseGroupMatch(t *testing.T) {
match: false,
},
{
- expression: `has(resource.labels.unit) && resource.labels.unit == "aws"`,
+ expression: `has(resource.database_labels.unit) && resource.database_labels.unit == "aws"`,
database: &store.DatabaseMessage{
Metadata: &storepb.DatabaseMetadata{},
},
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
index ea4b6af103..ea08ac2c17 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
@@ -58,7 +58,7 @@ export const useRuleTemplates = () => {
expr: wrapAsGroup({
type: ExprType.Condition,
operator: "_==_",
- args: ["environment_id", prod.value.id],
+ args: ["resource.environment_id", prod.value.id],
}),
level: PresetRiskLevel.HIGH,
source: Risk_Source.SOURCE_UNSPECIFIED,
@@ -74,7 +74,7 @@ export const useRuleTemplates = () => {
{
type: ExprType.Condition,
operator: "_==_",
- args: ["environment_id", prod.value.id],
+ args: ["resource.environment_id", prod.value.id],
},
{
type: ExprType.Condition,
@@ -99,7 +99,7 @@ export const useRuleTemplates = () => {
expr: wrapAsGroup({
type: ExprType.Condition,
operator: "_==_",
- args: ["environment_id", prod.value.id],
+ args: ["resource.environment_id", prod.value.id],
}),
level: PresetRiskLevel.MODERATE,
source: Risk_Source.CREATE_DATABASE,
@@ -114,7 +114,7 @@ export const useRuleTemplates = () => {
expr: wrapAsGroup({
type: ExprType.Condition,
operator: "_==_",
- args: ["environment_id", dev.value.id],
+ args: ["resource.environment_id", dev.value.id],
}),
level: PresetRiskLevel.LOW,
source: Risk_Source.SOURCE_UNSPECIFIED,
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
index 099cfeff86..7d8e6a3c56 100644
--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
@@ -73,16 +73,16 @@ export const orderByLevelDesc = (a: Risk, b: Risk): number => {
};
const commonFactorList: Factor[] = [
- "environment_id", // use `environment.resource_id` instead.
- "project_id", // use `project.resource_id` instead.
- "instance_id", // use `instance.resource_id` instead.
- "db_engine",
+ "resource.environment_id",
+ "resource.project_id",
+ "resource.instance_id",
+ "resource.db_engine",
] as const;
const schemaObjectNameFactorList: Factor[] = [
- "database_name",
- "schema_name",
- "table_name",
+ "resource.database_name",
+ "resource.schema_name",
+ "resource.table_name",
] as const;
const migrationFactorList: Factor[] = [
@@ -109,7 +109,10 @@ export const RiskSourceFactorMap: Map<Risk_Source, Factor[]> = new Map([
...migrationFactorList,
],
],
- [Risk_Source.CREATE_DATABASE, [...commonFactorList, "database_name"]],
+ [
+ Risk_Source.CREATE_DATABASE,
+ [...commonFactorList, "resource.database_name"],
+ ],
[
Risk_Source.DATA_EXPORT,
[...commonFactorList, ...schemaObjectNameFactorList],
@@ -117,8 +120,8 @@ export const RiskSourceFactorMap: Map<Risk_Source, Factor[]> = new Map([
[
Risk_Source.REQUEST_ROLE,
[
- "environment_id", // use `environment.resource_id` instead.
- "project_id", // use `project.resource_id` instead.
+ "resource.environment_id",
+ "resource.project_id",
"expiration_days",
"role",
],
@@ -239,10 +242,10 @@ export const getOptionConfigMap = (source: Risk_Source) => {
return factorList.reduce((map, factor) => {
let options: SelectOption[] = [];
switch (factor) {
- case "environment_id":
+ case "resource.environment_id":
options = getEnvironmentIdOptions();
break;
- case "project_id":
+ case "resource.project_id":
const projectStore = useProjectV1Store();
map.set(factor, {
remote: true,
@@ -259,7 +262,7 @@ export const getOptionConfigMap = (source: Risk_Source) => {
},
});
return map;
- case "instance_id":
+ case "resource.instance_id":
const store = useInstanceV1Store();
map.set(factor, {
remote: true,
@@ -276,7 +279,7 @@ export const getOptionConfigMap = (source: Risk_Source) => {
},
});
return map;
- case "db_engine":
+ case "resource.db_engine":
options = getDBEndingOptions();
break;
case "level":
@@ -294,23 +297,15 @@ export const getOptionConfigMap = (source: Risk_Source) => {
//
// factors that don't need special handling
//
- case "database_name":
- case "schema_name":
- case "table_name":
- case "sql_statement":
case "resource.database":
- case "resource.schema":
- case "resource.table":
- case "resource.environment_name":
- case "resource.instance_id":
- case "resource.database_name":
+ case "resource.schema_name":
case "resource.table_name":
+ case "resource.database_name":
case "resource.column_name":
- case "resource.schema_name":
- case "classification_level":
- case "column_name":
+ case "resource.classification_level":
case "affected_rows":
case "table_rows":
+ case "sql_statement":
case "request.row_limit":
case "expiration_days":
case "request.time":
@@ -328,10 +323,10 @@ export const getOptionConfigMap = (source: Risk_Source) => {
};
export const factorSupportDropdown: Factor[] = [
- "environment_id",
- "project_id",
- "instance_id",
- "db_engine",
+ "resource.environment_id",
+ "resource.project_id",
+ "resource.instance_id",
+ "resource.db_engine",
"sql_type",
"level",
"source",
diff --git a/frontend/src/components/DatabaseGroup/utils.ts b/frontend/src/components/DatabaseGroup/utils.ts
index 8279dd25b8..42c16cf2fa 100644
--- a/frontend/src/components/DatabaseGroup/utils.ts
+++ b/frontend/src/components/DatabaseGroup/utils.ts
@@ -11,13 +11,13 @@ import {
import { getDefaultPagination } from "@/utils";
export const FactorList: Factor[] = [
- "resource.environment_name",
+ "resource.environment_id",
"resource.database_name",
"resource.instance_id",
];
export const factorSupportDropdown: Factor[] = [
- "resource.environment_name",
+ "resource.environment_id",
"resource.instance_id",
];
@@ -25,7 +25,7 @@ export const getDatabaseGroupOptionConfigMap = () => {
return FactorList.reduce((map, factor) => {
let options: SelectOption[] = [];
switch (factor) {
- case "resource.environment_name":
+ case "resource.environment_id":
options = getEnvironmentOptions();
break;
case "resource.instance_id":
diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
index 824953ab46..0f310ec42e 100644
--- a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
+++ b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
@@ -341,13 +341,13 @@ const onPolicyUpsert = async () => {
const factorList = computed((): Factor[] => {
const list: Factor[] = [
- "environment_id", // using `environment.resource_id`
- "project_id", // using `project.resource_id`
- "instance_id", // using `instance.resource_id`
- "database_name",
- "table_name",
- "column_name",
- "classification_level",
+ "resource.environment_id",
+ "resource.project_id",
+ "resource.instance_id",
+ "resource.database_name",
+ "resource.table_name",
+ "resource.column_name",
+ "resource.classification_level",
];
return list;
@@ -357,10 +357,10 @@ const factorOptionsMap = computed((): Map<Factor, OptionConfig> => {
return factorList.value.reduce((map, factor) => {
let options: SelectOption[] = [];
switch (factor) {
- case "environment_id":
+ case "resource.environment_id":
options = getEnvironmentIdOptions();
break;
- case "instance_id":
+ case "resource.instance_id":
const store = useInstanceV1Store();
map.set(factor, {
remote: true,
@@ -377,7 +377,7 @@ const factorOptionsMap = computed((): Map<Factor, OptionConfig> => {
},
});
return map;
- case "project_id":
+ case "resource.project_id":
const projectStore = useProjectV1Store();
map.set(factor, {
remote: true,
@@ -394,7 +394,7 @@ const factorOptionsMap = computed((): Map<Factor, OptionConfig> => {
},
});
return map;
- case "classification_level":
+ case "resource.classification_level":
options = getClassificationLevelOptions();
break;
}
diff --git a/frontend/src/components/SensitiveData/components/utils.ts b/frontend/src/components/SensitiveData/components/utils.ts
index 9ada6cb633..09723df889 100644
--- a/frontend/src/components/SensitiveData/components/utils.ts
+++ b/frontend/src/components/SensitiveData/components/utils.ts
@@ -48,14 +48,17 @@ export const getInstanceIdOptions = (instanceList: Instance[]) => {
};
export const factorSupportDropdown: Factor[] = [
- "environment_id",
- "instance_id",
- "project_id",
- "classification_level",
+ "resource.environment_id",
+ "resource.instance_id",
+ "resource.project_id",
+ "resource.classification_level",
];
export const factorOperatorOverrideMap = new Map<Factor, Operator[]>([
- ["project_id", uniq([...EqualityOperatorList, ...CollectionOperatorList])],
+ [
+ "resource.project_id",
+ uniq([...EqualityOperatorList, ...CollectionOperatorList]),
+ ],
]);
export type MaskingType =
diff --git a/frontend/src/plugins/cel/types/factor.ts b/frontend/src/plugins/cel/types/factor.ts
index 6a8743c593..896ae47486 100644
--- a/frontend/src/plugins/cel/types/factor.ts
+++ b/frontend/src/plugins/cel/types/factor.ts
@@ -15,33 +15,26 @@ export type NumberFactor = (typeof NumberFactorList)[number];
export const StringFactorList = [
// Risk related factors
"source",
- "environment_id", // using `environment.resource_id`
- "project_id", // using `project.resource_id`
- "database_name",
- "schema_name",
- "table_name",
- "instance_id",
- "db_engine",
+ "resource.environment_id",
+ "resource.project_id",
+ "resource.database_name",
+ "resource.schema_name",
+ "resource.table_name",
+ "resource.instance_id",
+ "resource.db_engine",
"sql_type",
"sql_statement",
"role",
// Grant request issue related factors
"resource.database",
- "resource.schema",
- "resource.table",
-
- // Database/table group related factors
- "resource.environment_name", // using `environment.name`
- "resource.instance_id", // using `instance.resourceId`
- "resource.database_name",
+ "resource.schema_name",
"resource.table_name",
+
// Masking
"resource.column_name",
- "resource.schema_name",
// Masking rule
- "classification_level",
- "column_name",
+ "resource.classification_level",
] as const;
export type StringFactor = (typeof StringFactorList)[number];
diff --git a/frontend/src/plugins/cel/types/operator.ts b/frontend/src/plugins/cel/types/operator.ts
index 696c7d5c0c..efc0ba4ab0 100644
--- a/frontend/src/plugins/cel/types/operator.ts
+++ b/frontend/src/plugins/cel/types/operator.ts
@@ -60,66 +60,52 @@ const OperatorList: Record<Factor, Operator[]> = {
level: uniq([...EqualityOperatorList, ...CollectionOperatorList]),
source: uniq([...EqualityOperatorList, ...CollectionOperatorList]),
- environment_id: uniq([...EqualityOperatorList, ...CollectionOperatorList]),
- instance_id: uniq([...EqualityOperatorList, ...CollectionOperatorList]),
- project_id: uniq([
+ "resource.environment_id": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
- ...StringOperatorList,
]),
- database_name: uniq([
+ "resource.instance_id": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- schema_name: uniq([
+ "resource.project_id": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- table_name: uniq([
+ "resource.database_name": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- column_name: uniq([
+ "resource.schema_name": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- db_engine: uniq([
+ "resource.table_name": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- sql_type: uniq([
+ "resource.column_name": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- sql_statement: uniq([...StringOperatorList]),
- classification_level: uniq([...CollectionOperatorList]),
-
- // Database group related fields.
- "resource.environment_name": uniq([
- ...EqualityOperatorList,
- ...CollectionOperatorList,
- ]),
- "resource.instance_id": uniq([
+ "resource.db_engine": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- "resource.database_name": uniq([
- ...EqualityOperatorList,
- ...CollectionOperatorList,
- ...StringOperatorList,
- ]),
- "resource.table_name": uniq([
+ sql_type: uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
+ sql_statement: uniq([...StringOperatorList]),
+ "resource.classification_level": uniq([...CollectionOperatorList]),
// Request query/export factors
expiration_days: uniq([...EqualityOperatorList, ...CompareOperatorList]),
@@ -132,10 +118,6 @@ const OperatorList: Record<Factor, Operator[]> = {
// These factors don't have operator candidates for user selection.
"request.row_limit": [],
"resource.database": [],
- "resource.schema": [],
- "resource.table": [],
- "resource.column_name": [],
- "resource.schema_name": [],
"request.time": [],
};
diff --git a/frontend/src/types/proto-es/v1/database_group_service_pb.d.ts b/frontend/src/types/proto-es/v1/database_group_service_pb.d.ts
index 93862f13b6..8295fe6b6f 100644
--- a/frontend/src/types/proto-es/v1/database_group_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/database_group_service_pb.d.ts
@@ -236,13 +236,15 @@ export declare type DatabaseGroup = Message<"bytebase.v1.DatabaseGroup"> & {
* The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
*
* Support variables:
- * resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ * resource.environment_id: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
* resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
* resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ * resource.database_labels: the database labels. Support map access operations.
* All variables should join with "&&" condition.
*
* For example:
- * resource.environment_name == "test" && resource.database_name.startsWith("sample_")
+ * resource.environment_id == "test" && resource.database_name.startsWith("sample_")
+ * resource.database_labels["tenant"] == "tenant1"
*
* @generated from field: google.type.Expr database_expr = 3;
*/
diff --git a/frontend/src/types/proto-es/v1/iam_policy_pb.d.ts b/frontend/src/types/proto-es/v1/iam_policy_pb.d.ts
index 340d31bab7..c1023e604e 100644
--- a/frontend/src/types/proto-es/v1/iam_policy_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/iam_policy_pb.d.ts
@@ -121,14 +121,14 @@ export declare type Binding = Message<"bytebase.v1.Binding"> & {
*
* Support variables:
* resource.database: the database full name in "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" role, support "==" operator.
- * resource.schema: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
- * resource.table: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ * resource.schema_name: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ * resource.table_name: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
* request.time: the expiration. Only support "<" operation in `request.time < timestamp("{ISO datetime string format}")`.
* request.row_limit: the maximum export rows, used by the "roles/sqlEditorUser" role. Only support "<=" operation.
*
* For example:
- * resource.database == "instances/local-pg/databases/postgres" && resource.schema in ["public","another_schema"]
- * resource.database == "instances/local-pg/databases/bytebase" && resource.schema == "public" && resource.table in ["audit_log"]
+ * resource.database == "instances/local-pg/databases/postgres" && resource.schema_name in ["public","another_schema"]
+ * resource.database == "instances/local-pg/databases/bytebase" && resource.schema_name == "public" && resource.table_name in ["audit_log"]
* request.time < timestamp("2025-04-26T11:24:48.655Z") && request.row_limit <= 1000
*
* @generated from field: google.type.Expr condition = 3;
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.ts
index 9ec02cd19c..67fca61622 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
@@ -613,13 +613,13 @@ export declare type MaskingRulePolicy_MaskingRule = Message<"bytebase.v1.Masking
* The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
*
* Support variables:
- * environment_id: the environment resource id.
- * project_id: the project resource id.
- * instance_id: the instance resource id.
- * database_name: the database name.
- * table_name: the table name.
- * column_name: the column name.
- * classification_level: the classification level.
+ * resource.environment_id: the environment resource id.
+ * resource.project_id: the project resource id.
+ * resource.instance_id: the instance resource id.
+ * resource.database_name: the database name.
+ * resource.table_name: the table name.
+ * resource.column_name: the column name.
+ * resource.classification_level: the classification level.
*
* Each variable support following operations:
* ==: the value equals the target.
@@ -628,10 +628,10 @@ export declare type MaskingRulePolicy_MaskingRule = Message<"bytebase.v1.Masking
* !(in): the value not matches any of the targets.
*
* For example:
- * environment_id == "test" && project_id == "sample-project"
- * instance_id == "sample-instance" && database_name == "employee" && table_name in ["table1", "table2"]
- * environment_id != "test" || !(project_id in ["poject1", "prject2"])
- * instance_id == "sample-instance" && (database_name == "db1" || database_name == "db2")
+ * resource.environment_id == "test" && resource.project_id == "sample-project"
+ * resource.instance_id == "sample-instance" && resource.database_name == "employee" && resource.table_name in ["table1", "table2"]
+ * resource.environment_id != "test" || !(resource.project_id in ["poject1", "prject2"])
+ * resource.instance_id == "sample-instance" && (resource.database_name == "db1" || resource.database_name == "db2")
*
* @generated from field: google.type.Expr condition = 2;
*/
diff --git a/frontend/src/types/proto-es/v1/risk_service_pb.d.ts b/frontend/src/types/proto-es/v1/risk_service_pb.d.ts
index 3c2e680b8c..20f94d04a6 100644
--- a/frontend/src/types/proto-es/v1/risk_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/risk_service_pb.d.ts
@@ -200,15 +200,15 @@ export declare type Risk = Message<"bytebase.v1.Risk"> & {
* All supported variables:
* affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
* table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
- * environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
- * project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- * db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
+ * resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ * resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ * resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
* sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
* when the risk source is DDL, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L70 for supported values.
* when the risk source is DML, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L71 for supported values.
- * database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- * schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- * table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ * resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ * resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ * resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
* sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
* expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
* role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
@@ -216,31 +216,31 @@ export declare type Risk = Message<"bytebase.v1.Risk"> & {
* When the risk source is DDL/DML, support following variables:
* affected_rows
* table_rows
- * environment_id
- * project_id
- * db_engine
+ * resource.environment_id
+ * resource.project_id
+ * resource.db_engine
* sql_type
- * database_name
- * schema_name
- * table_name
+ * resource.database_name
+ * resource.schema_name
+ * resource.table_name
* sql_statement
*
* When the risk source is CREATE_DATABASE, support following variables:
- * environment_id
- * project_id
- * db_engine
- * database_name
+ * resource.environment_id
+ * resource.project_id
+ * resource.db_engine
+ * resource.database_name
*
* When the risk source is DATA_EXPORT, support following variables:
- * environment_id
- * project_id
- * db_engine
- * database_name
- * schema_name
- * table_name
+ * resource.environment_id
+ * resource.project_id
+ * resource.db_engine
+ * resource.database_name
+ * resource.schema_name
+ * resource.table_name
*
* When the risk source is REQUEST_ROLE, support following variables:
- * project_id
+ * resource.project_id
* expiration_days
* role
*
diff --git a/frontend/src/utils/issue/cel.ts b/frontend/src/utils/issue/cel.ts
index 9b8700450e..c49b57a9a4 100644
--- a/frontend/src/utils/issue/cel.ts
+++ b/frontend/src/utils/issue/cel.ts
@@ -322,7 +322,6 @@ export const convertFromExpr = (expr: Expr): ConditionExpression => {
}
break;
}
- case "resource.schema":
case "resource.schema_name": {
const databaseResource =
conditionExpression.databaseResources?.pop();
@@ -335,7 +334,6 @@ export const convertFromExpr = (expr: Expr): ConditionExpression => {
}
break;
}
- case "resource.table":
case "resource.table_name": {
const databaseResource =
conditionExpression.databaseResources?.pop();
@@ -408,12 +406,10 @@ export const convertFromExpr = (expr: Expr): ConditionExpression => {
databaseResource.databaseFullName = right;
break;
}
- case "resource.schema":
case "resource.schema_name": {
databaseResource.schema = right;
break;
}
- case "resource.table":
case "resource.table_name": {
databaseResource.table = right;
break;
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index d609698ae5..48a957483c 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -8918,14 +8918,14 @@ components:
Support variables:
resource.database: the database full name in "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" role, support "==" operator.
- resource.schema: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
- resource.table: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ resource.schema_name: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ resource.table_name: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
request.time: the expiration. Only support "<" operation in `request.time < timestamp("{ISO datetime string format}")`.
request.row_limit: the maximum export rows, used by the "roles/sqlEditorUser" role. Only support "<=" operation.
For example:
- resource.database == "instances/local-pg/databases/postgres" && resource.schema in ["public","another_schema"]
- resource.database == "instances/local-pg/databases/bytebase" && resource.schema == "public" && resource.table in ["audit_log"]
+ resource.database == "instances/local-pg/databases/postgres" && resource.schema_name in ["public","another_schema"]
+ resource.database == "instances/local-pg/databases/bytebase" && resource.schema_name == "public" && resource.table_name in ["audit_log"]
request.time < timestamp("2025-04-26T11:24:48.655Z") && request.row_limit <= 1000
parsedExpr:
readOnly: true
@@ -9864,13 +9864,15 @@ components:
The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
Support variables:
- resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ resource.environment_id: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ resource.database_labels: the database labels. Support map access operations.
All variables should join with "&&" condition.
For example:
- resource.environment_name == "test" && resource.database_name.startsWith("sample_")
+ resource.environment_id == "test" && resource.database_name.startsWith("sample_")
+ resource.database_labels["tenant"] == "tenant1"
matchedDatabases:
readOnly: true
type: array
@@ -12710,15 +12712,15 @@ components:
All supported variables:
affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
- environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
- project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
+ resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
when the risk source is DDL, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L70 for supported values.
when the risk source is DML, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L71 for supported values.
- database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
@@ -12726,31 +12728,31 @@ components:
When the risk source is DDL/DML, support following variables:
affected_rows
table_rows
- environment_id
- project_id
- db_engine
+ resource.environment_id
+ resource.project_id
+ resource.db_engine
sql_type
- database_name
- schema_name
- table_name
+ resource.database_name
+ resource.schema_name
+ resource.table_name
sql_statement
When the risk source is CREATE_DATABASE, support following variables:
- environment_id
- project_id
- db_engine
- database_name
+ resource.environment_id
+ resource.project_id
+ resource.db_engine
+ resource.database_name
When the risk source is DATA_EXPORT, support following variables:
- environment_id
- project_id
- db_engine
- database_name
- schema_name
- table_name
+ resource.environment_id
+ resource.project_id
+ resource.db_engine
+ resource.database_name
+ resource.schema_name
+ resource.table_name
When the risk source is REQUEST_ROLE, support following variables:
- project_id
+ resource.project_id
expiration_days
role
Role:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 7808748c58..270bed0ed9 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -5330,9 +5330,9 @@ The theme resources.
| members | [string](#string) | repeated | Specifies the principals requesting access for a Bytebase resource. For users, the member should be: user:{email} For groups, the member should be: group:{email} |
| condition | [google.type.Expr](#google-type-Expr) | | The condition that is associated with this binding, only used in the project IAM policy. If the condition evaluates to true, then this binding applies to the current request. If the condition evaluates to false, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
-Support variables: resource.database: the database full name in &#34;instances/{instance}/databases/{database}&#34; format, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator. resource.schema: the schema name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator. resource.table: the table name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator. request.time: the expiration. Only support &#34;&lt;&#34; operation in `request.time &lt; timestamp(&#34;{ISO datetime string format}&#34;)`. request.row_limit: the maximum export rows, used by the &#34;roles/sqlEditorUser&#34; role. Only support &#34;&lt;=&#34; operation.
+Support variables: resource.database: the database full name in &#34;instances/{instance}/databases/{database}&#34; format, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator. resource.schema_name: the schema name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator. resource.table_name: the table name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator. request.time: the expiration. Only support &#34;&lt;&#34; operation in `request.time &lt; timestamp(&#34;{ISO datetime string format}&#34;)`. request.row_limit: the maximum export rows, used by the &#34;roles/sqlEditorUser&#34; role. Only support &#34;&lt;=&#34; operation.
-For example: resource.database == &#34;instances/local-pg/databases/postgres&#34; &amp;&amp; resource.schema in [&#34;public&#34;,&#34;another_schema&#34;] resource.database == &#34;instances/local-pg/databases/bytebase&#34; &amp;&amp; resource.schema == &#34;public&#34; &amp;&amp; resource.table in [&#34;audit_log&#34;] request.time &lt; timestamp(&#34;2025-04-26T11:24:48.655Z&#34;) &amp;&amp; request.row_limit &lt;= 1000 |
+For example: resource.database == &#34;instances/local-pg/databases/postgres&#34; &amp;&amp; resource.schema_name in [&#34;public&#34;,&#34;another_schema&#34;] resource.database == &#34;instances/local-pg/databases/bytebase&#34; &amp;&amp; resource.schema_name == &#34;public&#34; &amp;&amp; resource.table_name in [&#34;audit_log&#34;] request.time &lt; timestamp(&#34;2025-04-26T11:24:48.655Z&#34;) &amp;&amp; request.row_limit &lt;= 1000 |
| parsed_expr | [google.api.expr.v1alpha1.Expr](#google-api-expr-v1alpha1-Expr) | | The parsed expression of the condition. |
@@ -6034,9 +6034,9 @@ This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |
| title | [string](#string) | | The short name used in actual databases specified by users. |
| database_expr | [google.type.Expr](#google-type-Expr) | | The condition that is associated with this database group. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
-Support variables: resource.environment_name: the environment resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34; operations. resource.instance_id: the instance resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations. resource.database_name: the database name. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations. All variables should join with &#34;&amp;&amp;&#34; condition.
+Support variables: resource.environment_id: the environment resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34; operations. resource.instance_id: the instance resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations. resource.database_name: the database name. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations. resource.database_labels: the database labels. Support map access operations. All variables should join with &#34;&amp;&amp;&#34; condition.
-For example: resource.environment_name == &#34;test&#34; &amp;&amp; resource.database_name.startsWith(&#34;sample_&#34;) |
+For example: resource.environment_id == &#34;test&#34; &amp;&amp; resource.database_name.startsWith(&#34;sample_&#34;) resource.database_labels[&#34;tenant&#34;] == &#34;tenant1&#34; |
| matched_databases | [DatabaseGroup.Database](#bytebase-v1-DatabaseGroup-Database) | repeated | The list of databases that match the database group condition. |
@@ -6944,11 +6944,11 @@ For example: resource.instance_id == &#34;local&#34; &amp;&amp; resource.databas
| id | [string](#string) | | A unique identifier for a node in UUID format. |
| condition | [google.type.Expr](#google-type-Expr) | | The condition for the masking rule. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
-Support variables: environment_id: the environment resource id. project_id: the project resource id. instance_id: the instance resource id. database_name: the database name. table_name: the table name. column_name: the column name. classification_level: the classification level.
+Support variables: resource.environment_id: the environment resource id. resource.project_id: the project resource id. resource.instance_id: the instance resource id. resource.database_name: the database name. resource.table_name: the table name. resource.column_name: the column name. resource.classification_level: the classification level.
Each variable support following operations: ==: the value equals the target. !=: the value not equals the target. in: the value matches one of the targets. !(in): the value not matches any of the targets.
-For example: environment_id == &#34;test&#34; &amp;&amp; project_id == &#34;sample-project&#34; instance_id == &#34;sample-instance&#34; &amp;&amp; database_name == &#34;employee&#34; &amp;&amp; table_name in [&#34;table1&#34;, &#34;table2&#34;] environment_id != &#34;test&#34; || !(project_id in [&#34;poject1&#34;, &#34;prject2&#34;]) instance_id == &#34;sample-instance&#34; &amp;&amp; (database_name == &#34;db1&#34; || database_name == &#34;db2&#34;) |
+For example: resource.environment_id == &#34;test&#34; &amp;&amp; resource.project_id == &#34;sample-project&#34; resource.instance_id == &#34;sample-instance&#34; &amp;&amp; resource.database_name == &#34;employee&#34; &amp;&amp; resource.table_name in [&#34;table1&#34;, &#34;table2&#34;] resource.environment_id != &#34;test&#34; || !(resource.project_id in [&#34;poject1&#34;, &#34;prject2&#34;]) resource.instance_id == &#34;sample-instance&#34; &amp;&amp; (resource.database_name == &#34;db1&#34; || resource.database_name == &#34;db2&#34;) |
| semantic_type | [string](#string) | | |
@@ -9702,15 +9702,15 @@ When paginating, all other parameters provided to `LiskRisks` must match the cal
| active | [bool](#bool) | | |
| condition | [google.type.Expr](#google-type-Expr) | | The condition that is associated with the risk. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
-All supported variables: affected_rows: affected row count in the DDL/DML, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations. table_rows: table row count number, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations. environment_id: the environment resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. project_id: the project resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. db_engine: the database engine type, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. Check the Engine enum for the values. sql_type: the SQL type, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. when the risk source is DDL, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L70 for supported values. when the risk source is DML, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L71 for supported values. database_name: the database name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. schema_name: the schema name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. table_name: the table name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. sql_statement: the SQL statement, support &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. expiration_days: the role expiration days for the request, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations. role: the request role full name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
+All supported variables: affected_rows: affected row count in the DDL/DML, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations. table_rows: table row count number, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations. resource.environment_id: the environment resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. resource.project_id: the project resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. resource.db_engine: the database engine type, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. Check the Engine enum for the values. sql_type: the SQL type, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. when the risk source is DDL, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L70 for supported values. when the risk source is DML, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L71 for supported values. resource.database_name: the database name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. resource.schema_name: the schema name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. resource.table_name: the table name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. sql_statement: the SQL statement, support &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. expiration_days: the role expiration days for the request, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations. role: the request role full name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
-When the risk source is DDL/DML, support following variables: affected_rows table_rows environment_id project_id db_engine sql_type database_name schema_name table_name sql_statement
+When the risk source is DDL/DML, support following variables: affected_rows table_rows resource.environment_id resource.project_id resource.db_engine sql_type resource.database_name resource.schema_name resource.table_name sql_statement
-When the risk source is CREATE_DATABASE, support following variables: environment_id project_id db_engine database_name
+When the risk source is CREATE_DATABASE, support following variables: resource.environment_id resource.project_id resource.db_engine resource.database_name
-When the risk source is DATA_EXPORT, support following variables: environment_id project_id db_engine database_name schema_name table_name
+When the risk source is DATA_EXPORT, support following variables: resource.environment_id resource.project_id resource.db_engine resource.database_name resource.schema_name resource.table_name
-When the risk source is REQUEST_ROLE, support following variables: project_id expiration_days role |
+When the risk source is REQUEST_ROLE, support following variables: resource.project_id expiration_days role |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index e927313c6a..32ccdedfb5 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -15527,14 +15527,14 @@ The syntax and semantics of CEL are documented at https://github.com/google/cel-
Support variables:
resource.database: the database full name in &#34;instances/{instance}/databases/{database}&#34; format, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator.
-resource.schema: the schema name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator.
-resource.table: the table name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator.
+resource.schema_name: the schema name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator.
+resource.table_name: the table name, used by the &#34;roles/sqlEditorUser&#34; role, support &#34;==&#34; operator.
request.time: the expiration. Only support &#34;&lt;&#34; operation in `request.time &lt; timestamp(&#34;{ISO datetime string format}&#34;)`.
request.row_limit: the maximum export rows, used by the &#34;roles/sqlEditorUser&#34; role. Only support &#34;&lt;=&#34; operation.
For example:
-resource.database == &#34;instances/local-pg/databases/postgres&#34; &amp;&amp; resource.schema in [&#34;public&#34;,&#34;another_schema&#34;]
-resource.database == &#34;instances/local-pg/databases/bytebase&#34; &amp;&amp; resource.schema == &#34;public&#34; &amp;&amp; resource.table in [&#34;audit_log&#34;]
+resource.database == &#34;instances/local-pg/databases/postgres&#34; &amp;&amp; resource.schema_name in [&#34;public&#34;,&#34;another_schema&#34;]
+resource.database == &#34;instances/local-pg/databases/bytebase&#34; &amp;&amp; resource.schema_name == &#34;public&#34; &amp;&amp; resource.table_name in [&#34;audit_log&#34;]
request.time &lt; timestamp(&#34;2025-04-26T11:24:48.655Z&#34;) &amp;&amp; request.row_limit &lt;= 1000 </p></td>
</tr>
@@ -17245,13 +17245,15 @@ Format: projects/{project}/databaseGroups/{databaseGroup} </p></td>
The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
Support variables:
-resource.environment_name: the environment resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34; operations.
+resource.environment_id: the environment resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34; operations.
resource.instance_id: the instance resource id. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations.
resource.database_name: the database name. Support &#34;==&#34;, &#34;!=&#34;, &#34;in [XX]&#34;, &#34;!(in [xx])&#34;, &#34;contains&#34;, &#34;matches&#34;, &#34;startsWith&#34;, &#34;endsWith&#34; operations.
+resource.database_labels: the database labels. Support map access operations.
All variables should join with &#34;&amp;&amp;&#34; condition.
For example:
-resource.environment_name == &#34;test&#34; &amp;&amp; resource.database_name.startsWith(&#34;sample_&#34;) </p></td>
+resource.environment_id == &#34;test&#34; &amp;&amp; resource.database_name.startsWith(&#34;sample_&#34;)
+resource.database_labels[&#34;tenant&#34;] == &#34;tenant1&#34; </p></td>
</tr>
<tr>
@@ -19496,13 +19498,13 @@ resource.instance_id == &#34;local&#34; &amp;&amp; resource.database_name == &#3
The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
Support variables:
-environment_id: the environment resource id.
-project_id: the project resource id.
-instance_id: the instance resource id.
-database_name: the database name.
-table_name: the table name.
-column_name: the column name.
-classification_level: the classification level.
+resource.environment_id: the environment resource id.
+resource.project_id: the project resource id.
+resource.instance_id: the instance resource id.
+resource.database_name: the database name.
+resource.table_name: the table name.
+resource.column_name: the column name.
+resource.classification_level: the classification level.
Each variable support following operations:
==: the value equals the target.
@@ -19511,10 +19513,10 @@ in: the value matches one of the targets.
!(in): the value not matches any of the targets.
For example:
-environment_id == &#34;test&#34; &amp;&amp; project_id == &#34;sample-project&#34;
-instance_id == &#34;sample-instance&#34; &amp;&amp; database_name == &#34;employee&#34; &amp;&amp; table_name in [&#34;table1&#34;, &#34;table2&#34;]
-environment_id != &#34;test&#34; || !(project_id in [&#34;poject1&#34;, &#34;prject2&#34;])
-instance_id == &#34;sample-instance&#34; &amp;&amp; (database_name == &#34;db1&#34; || database_name == &#34;db2&#34;) </p></td>
+resource.environment_id == &#34;test&#34; &amp;&amp; resource.project_id == &#34;sample-project&#34;
+resource.instance_id == &#34;sample-instance&#34; &amp;&amp; resource.database_name == &#34;employee&#34; &amp;&amp; resource.table_name in [&#34;table1&#34;, &#34;table2&#34;]
+resource.environment_id != &#34;test&#34; || !(resource.project_id in [&#34;poject1&#34;, &#34;prject2&#34;])
+resource.instance_id == &#34;sample-instance&#34; &amp;&amp; (resource.database_name == &#34;db1&#34; || resource.database_name == &#34;db2&#34;) </p></td>
</tr>
<tr>
@@ -27111,15 +27113,15 @@ The syntax and semantics of CEL are documented at https://github.com/google/cel-
All supported variables:
affected_rows: affected row count in the DDL/DML, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations.
table_rows: table row count number, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations.
-environment_id: the environment resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations.
-project_id: the project resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
-db_engine: the database engine type, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. Check the Engine enum for the values.
+resource.environment_id: the environment resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations.
+resource.project_id: the project resource id, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
+resource.db_engine: the database engine type, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations. Check the Engine enum for the values.
sql_type: the SQL type, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34; operations.
when the risk source is DDL, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L70 for supported values.
when the risk source is DML, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L71 for supported values.
-database_name: the database name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
-schema_name: the schema name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
-table_name: the table name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
+resource.database_name: the database name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
+resource.schema_name: the schema name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
+resource.table_name: the table name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
sql_statement: the SQL statement, support &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
expiration_days: the role expiration days for the request, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#34; operations.
role: the request role full name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [xx]&#34;, &#34;!(in [xx])&#34;, &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
@@ -27127,31 +27129,31 @@ role: the request role full name, support &#34;==&#34;, &#34;!=&#34;, &#34;in [x
When the risk source is DDL/DML, support following variables:
affected_rows
table_rows
-environment_id
-project_id
-db_engine
+resource.environment_id
+resource.project_id
+resource.db_engine
sql_type
-database_name
-schema_name
-table_name
+resource.database_name
+resource.schema_name
+resource.table_name
sql_statement
When the risk source is CREATE_DATABASE, support following variables:
-environment_id
-project_id
-db_engine
-database_name
+resource.environment_id
+resource.project_id
+resource.db_engine
+resource.database_name
When the risk source is DATA_EXPORT, support following variables:
-environment_id
-project_id
-db_engine
-database_name
-schema_name
-table_name
+resource.environment_id
+resource.project_id
+resource.db_engine
+resource.database_name
+resource.schema_name
+resource.table_name
When the risk source is REQUEST_ROLE, support following variables:
-project_id
+resource.project_id
expiration_days
role </p></td>
</tr>
diff --git a/proto/v1/v1/database_group_service.proto b/proto/v1/v1/database_group_service.proto
index 2d6533fd12..1e148d9507 100644
--- a/proto/v1/v1/database_group_service.proto
+++ b/proto/v1/v1/database_group_service.proto
@@ -187,13 +187,15 @@ message DatabaseGroup {
// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
//
// Support variables:
- // resource.environment_name: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
+ // resource.environment_id: the environment resource id. Support "==", "!=", "in [XX]", "!(in [xx])" operations.
// resource.instance_id: the instance resource id. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
// resource.database_name: the database name. Support "==", "!=", "in [XX]", "!(in [xx])", "contains", "matches", "startsWith", "endsWith" operations.
+ // resource.database_labels: the database labels. Support map access operations.
// All variables should join with "&&" condition.
//
// For example:
- // resource.environment_name == "test" && resource.database_name.startsWith("sample_")
+ // resource.environment_id == "test" && resource.database_name.startsWith("sample_")
+ // resource.database_labels["tenant"] == "tenant1"
google.type.Expr database_expr = 3;
message Database {
diff --git a/proto/v1/v1/iam_policy.proto b/proto/v1/v1/iam_policy.proto
index 41bc0a8784..5bf8d37b7f 100644
--- a/proto/v1/v1/iam_policy.proto
+++ b/proto/v1/v1/iam_policy.proto
@@ -62,14 +62,14 @@ message Binding {
//
// Support variables:
// resource.database: the database full name in "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" role, support "==" operator.
- // resource.schema: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
- // resource.table: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ // resource.schema_name: the schema name, used by the "roles/sqlEditorUser" role, support "==" operator.
+ // resource.table_name: the table name, used by the "roles/sqlEditorUser" role, support "==" operator.
// request.time: the expiration. Only support "<" operation in `request.time < timestamp("{ISO datetime string format}")`.
// request.row_limit: the maximum export rows, used by the "roles/sqlEditorUser" role. Only support "<=" operation.
//
// For example:
- // resource.database == "instances/local-pg/databases/postgres" && resource.schema in ["public","another_schema"]
- // resource.database == "instances/local-pg/databases/bytebase" && resource.schema == "public" && resource.table in ["audit_log"]
+ // resource.database == "instances/local-pg/databases/postgres" && resource.schema_name in ["public","another_schema"]
+ // resource.database == "instances/local-pg/databases/bytebase" && resource.schema_name == "public" && resource.table_name in ["audit_log"]
// request.time < timestamp("2025-04-26T11:24:48.655Z") && request.row_limit <= 1000
google.type.Expr condition = 3;
diff --git a/proto/v1/v1/org_policy_service.proto b/proto/v1/v1/org_policy_service.proto
index 312f21019b..8f52eb0e35 100644
--- a/proto/v1/v1/org_policy_service.proto
+++ b/proto/v1/v1/org_policy_service.proto
@@ -393,13 +393,13 @@ message MaskingRulePolicy {
// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
//
// Support variables:
- // environment_id: the environment resource id.
- // project_id: the project resource id.
- // instance_id: the instance resource id.
- // database_name: the database name.
- // table_name: the table name.
- // column_name: the column name.
- // classification_level: the classification level.
+ // resource.environment_id: the environment resource id.
+ // resource.project_id: the project resource id.
+ // resource.instance_id: the instance resource id.
+ // resource.database_name: the database name.
+ // resource.table_name: the table name.
+ // resource.column_name: the column name.
+ // resource.classification_level: the classification level.
//
// Each variable support following operations:
// ==: the value equals the target.
@@ -408,10 +408,10 @@ message MaskingRulePolicy {
// !(in): the value not matches any of the targets.
//
// For example:
- // environment_id == "test" && project_id == "sample-project"
- // instance_id == "sample-instance" && database_name == "employee" && table_name in ["table1", "table2"]
- // environment_id != "test" || !(project_id in ["poject1", "prject2"])
- // instance_id == "sample-instance" && (database_name == "db1" || database_name == "db2")
+ // resource.environment_id == "test" && resource.project_id == "sample-project"
+ // resource.instance_id == "sample-instance" && resource.database_name == "employee" && resource.table_name in ["table1", "table2"]
+ // resource.environment_id != "test" || !(resource.project_id in ["poject1", "prject2"])
+ // resource.instance_id == "sample-instance" && (resource.database_name == "db1" || resource.database_name == "db2")
google.type.Expr condition = 2;
string semantic_type = 3;
diff --git a/proto/v1/v1/risk_service.proto b/proto/v1/v1/risk_service.proto
index 2393c330a7..da49c32735 100644
--- a/proto/v1/v1/risk_service.proto
+++ b/proto/v1/v1/risk_service.proto
@@ -157,15 +157,15 @@ message Risk {
// All supported variables:
// affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
// table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
- // environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
- // project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- // db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
+ // resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ // resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
// sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
// when the risk source is DDL, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L70 for supported values.
// when the risk source is DML, check https://github.com/bytebase/bytebase/blob/main/frontend/src/plugins/cel/types/values.ts#L71 for supported values.
- // database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- // schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
- // table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.database_name: the database name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.schema_name: the schema name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // resource.table_name: the table name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
// sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
// expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
// role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
@@ -173,31 +173,31 @@ message Risk {
// When the risk source is DDL/DML, support following variables:
// affected_rows
// table_rows
- // environment_id
- // project_id
- // db_engine
+ // resource.environment_id
+ // resource.project_id
+ // resource.db_engine
// sql_type
- // database_name
- // schema_name
- // table_name
+ // resource.database_name
+ // resource.schema_name
+ // resource.table_name
// sql_statement
//
// When the risk source is CREATE_DATABASE, support following variables:
- // environment_id
- // project_id
- // db_engine
- // database_name
+ // resource.environment_id
+ // resource.project_id
+ // resource.db_engine
+ // resource.database_name
//
// When the risk source is DATA_EXPORT, support following variables:
- // environment_id
- // project_id
- // db_engine
- // database_name
- // schema_name
- // table_name
+ // resource.environment_id
+ // resource.project_id
+ // resource.db_engine
+ // resource.database_name
+ // resource.schema_name
+ // resource.table_name
//
// When the risk source is REQUEST_ROLE, support following variables:
- // project_id
+ // resource.project_id
// expiration_days
// role
google.type.Expr condition = 8;