Skip to content

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

docs: add doc for expr (#15979)

ecmadao8a0a3e1f511e
diff --git a/frontend/src/types/proto/v1/iam_policy.ts b/frontend/src/types/proto/v1/iam_policy.ts
index b2931deaa8..fa844820fa 100644
--- a/frontend/src/types/proto/v1/iam_policy.ts
+++ b/frontend/src/types/proto/v1/iam_policy.ts
@@ -62,9 +62,22 @@ export interface Binding {
*/
members: string[];
/**
- * The condition that is associated with this binding.
+ * 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 "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ * resource.schema: the schema name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ * resource.table: the table name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ * 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/projectExporter" 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"]
+ * request.time < timestamp("2025-04-26T11:24:48.655Z") && request.row_limit <= 1000
*/
condition:
| Expr
diff --git a/frontend/src/types/proto/v1/issue_service.ts b/frontend/src/types/proto/v1/issue_service.ts
index 1e61cd7e54..60a5406027 100644
--- a/frontend/src/types/proto/v1/issue_service.ts
+++ b/frontend/src/types/proto/v1/issue_service.ts
@@ -509,6 +509,7 @@ export interface GrantRequest {
* Format: users/{email}.
*/
user: string;
+ /** The condition for the role. Same as the condtion in IAM Binding message. */
condition: Expr | undefined;
expiration: Duration | undefined;
}
diff --git a/frontend/src/types/proto/v1/org_policy_service.ts b/frontend/src/types/proto/v1/org_policy_service.ts
index 25078c4787..18311a5dfe 100644
--- a/frontend/src/types/proto/v1/org_policy_service.ts
+++ b/frontend/src/types/proto/v1/org_policy_service.ts
@@ -434,7 +434,24 @@ export interface MaskingExceptionPolicy_MaskingException {
* - `group:{email}`: An email address for group.
*/
member: string;
- /** The condition that is associated with this exception policy instance. */
+ /**
+ * The condition that is associated with this exception policy instance.
+ * The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ * If the condition is empty, means the user can access all databases without expiration.
+ *
+ * Support variables:
+ * resource.instance_id: the instance resource id. Only support "==" operation.
+ * resource.database_name: the database name. Only support "==" operation.
+ * resource.schema_name: the schema name. Only support "==" operation.
+ * resource.table_name: the table name. Only support "==" operation.
+ * resource.column_name: the column name. Only support "==" operation.
+ * request.time: the expiration. Only support "<" operation in `request.time < timestamp("{ISO datetime string format}")`
+ * All variables should join with "&&" condition.
+ *
+ * For example:
+ * resource.instance_id == "local" && resource.database_name == "employee" && request.time < timestamp("2025-04-30T11:10:39.000Z")
+ * resource.instance_id == "local" && resource.database_name == "employee"
+ */
condition: Expr | undefined;
}
@@ -504,6 +521,31 @@ export interface MaskingRulePolicy {
export interface MaskingRulePolicy_MaskingRule {
/** A unique identifier for a node in UUID format. */
id: string;
+ /**
+ * 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.
+ *
+ * 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 == "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")
+ */
condition: Expr | undefined;
semanticType: string;
}
diff --git a/frontend/src/types/proto/v1/risk_service.ts b/frontend/src/types/proto/v1/risk_service.ts
index c5cc156ad8..8e80744fdc 100644
--- a/frontend/src/types/proto/v1/risk_service.ts
+++ b/frontend/src/types/proto/v1/risk_service.ts
@@ -76,6 +76,72 @@ export interface Risk {
title: string;
level: number;
active: boolean;
+ /**
+ * 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 "==", "!=", "<", "<=", ">", ">=" 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.
+ * 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.
+ * sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ * export_rows: export data count, support "==", "!=", "<", "<=", ">", ">=" operations.
+ * expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" 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 CREATE_DATABASE, support following variables:
+ * environment_id
+ * project_id
+ * db_engine
+ * database_name
+ *
+ * When the risk source is DATA_EXPORT, support following variables:
+ * environment_id
+ * project_id
+ * db_engine
+ * database_name
+ * schema_name
+ * table_name
+ * export_rows
+ *
+ * When the risk source is REQUEST_QUERY, support following variables:
+ * environment_id
+ * project_id
+ * db_engine
+ * database_name
+ * schema_name
+ * table_name
+ * expiration_days
+ *
+ * When the risk source is REQUEST_EXPORT, support following variables:
+ * environment_id
+ * project_id
+ * db_engine
+ * database_name
+ * schema_name
+ * table_name
+ * expiration_days
+ * export_rows
+ */
condition: Expr | undefined;
}
diff --git a/frontend/src/types/proto/v1/setting_service.ts b/frontend/src/types/proto/v1/setting_service.ts
index e741870399..380a95b039 100644
--- a/frontend/src/types/proto/v1/setting_service.ts
+++ b/frontend/src/types/proto/v1/setting_service.ts
@@ -485,7 +485,20 @@ export interface WorkspaceApprovalSetting {
}
export interface WorkspaceApprovalSetting_Rule {
- template: ApprovalTemplate | undefined;
+ template:
+ | ApprovalTemplate
+ | undefined;
+ /**
+ * The condition that is associated with the rule.
+ * The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ *
+ * Support variables:
+ * source: the risk source, check the Source enum in the Risk message for the values.
+ * level: the risk level, support 100 (low), 200 (moderate) and 300 (high).
+ *
+ * For examples:
+ * (source == "DML" && level == 200) || (source == "DDL" && level == 300)
+ */
condition: Expr | undefined;
}
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 0db56b9f29..5ac9ffaa84 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -8348,9 +8348,22 @@ components:
allOf:
- $ref: '#/components/schemas/Expr'
description: |-
- The condition that is associated with this binding.
+ 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 "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ resource.schema: the schema name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ resource.table: the table name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ 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/projectExporter" 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"]
+ request.time < timestamp("2025-04-26T11:24:48.655Z") && request.row_limit <= 1000
parsedExpr:
readOnly: true
allOf:
@@ -9602,7 +9615,9 @@ components:
The user to be granted.
Format: users/{email}.
condition:
- $ref: '#/components/schemas/Expr'
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: The condition for the role. Same as the condtion in IAM Binding message.
expiration:
pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$
type: string
@@ -11946,7 +11961,73 @@ components:
active:
type: boolean
condition:
- $ref: '#/components/schemas/Expr'
+ allOf:
+ - $ref: '#/components/schemas/Expr'
+ description: |-
+ 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 "==", "!=", "<", "<=", ">", ">=" 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.
+ 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.
+ sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ export_rows: export data count, support "==", "!=", "<", "<=", ">", ">=" operations.
+ expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" 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 CREATE_DATABASE, support following variables:
+ environment_id
+ project_id
+ db_engine
+ database_name
+
+ When the risk source is DATA_EXPORT, support following variables:
+ environment_id
+ project_id
+ db_engine
+ database_name
+ schema_name
+ table_name
+ export_rows
+
+ When the risk source is REQUEST_QUERY, support following variables:
+ environment_id
+ project_id
+ db_engine
+ database_name
+ schema_name
+ table_name
+ expiration_days
+
+ When the risk source is REQUEST_EXPORT, support following variables:
+ environment_id
+ project_id
+ db_engine
+ database_name
+ schema_name
+ table_name
+ expiration_days
+ export_rows
Role:
type: object
properties:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 81fafe9a6f..39a97a3bf2 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -3451,7 +3451,7 @@ LIST, HASH (https://www.postgresql.org/docs/current/ddl-partitioning.html)
| ----- | ---- | ----- | ----------- |
| role | [string](#string) | | The requested role. Format: roles/EXPORTER. |
| user | [string](#string) | | The user to be granted. Format: users/{email}. |
-| condition | [google.type.Expr](#google-type-Expr) | | |
+| condition | [google.type.Expr](#google-type-Expr) | | The condition for the role. Same as the condtion in IAM Binding message. |
| expiration | [google.protobuf.Duration](#google-protobuf-Duration) | | |
@@ -4873,7 +4873,11 @@ The data in setting value.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| template | [ApprovalTemplate](#bytebase-v1-ApprovalTemplate) | | |
-| condition | [google.type.Expr](#google-type-Expr) | | |
+| condition | [google.type.Expr](#google-type-Expr) | | The condition that is associated with the rule. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+
+Support variables: source: the risk source, check the Source enum in the Risk message for the values. level: the risk level, support 100 (low), 200 (moderate) and 300 (high).
+
+For examples: (source == &#34;DML&#34; &amp;&amp; level == 200) || (source == &#34;DDL&#34; &amp;&amp; level == 300) |
@@ -5398,7 +5402,11 @@ The theme resources.
| ----- | ---- | ----- | ----------- |
| role | [string](#string) | | The role that is assigned to the members. Format: roles/{role} |
| 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. 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. |
+| 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; and &#34;roles/projectExporter&#34; role. resource.schema: the schema name, used by the &#34;roles/sqlEditorUser&#34; and &#34;roles/projectExporter&#34; role. resource.table: the table name, used by the &#34;roles/sqlEditorUser&#34; and &#34;roles/projectExporter&#34; role. 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/projectExporter&#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 |
| parsed_expr | [google.api.expr.v1alpha1.Expr](#google-api-expr-v1alpha1-Expr) | | The parsed expression of the condition. |
@@ -6907,7 +6915,11 @@ MaskingExceptionPolicy is the allowlist of users who can access sensitive data.
| member | [string](#string) | | Member is the principal who bind to this exception policy instance.
- `user:{email}`: An email address that represents a specific Bytebase account. For example, `[email protected]`. - `group:{email}`: An email address for group. |
-| condition | [google.type.Expr](#google-type-Expr) | | The condition that is associated with this exception policy instance. |
+| condition | [google.type.Expr](#google-type-Expr) | | The condition that is associated with this exception policy instance. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec If the condition is empty, means the user can access all databases without expiration.
+
+Support variables: resource.instance_id: the instance resource id. Only support &#34;==&#34; operation. resource.database_name: the database name. Only support &#34;==&#34; operation. resource.schema_name: the schema name. Only support &#34;==&#34; operation. resource.table_name: the table name. Only support &#34;==&#34; operation. resource.column_name: the column name. Only support &#34;==&#34; operation. request.time: the expiration. Only support &#34;&lt;&#34; operation in `request.time &lt; timestamp(&#34;{ISO datetime string format}&#34;)` All variables should join with &#34;&amp;&amp;&#34; condition.
+
+For example: resource.instance_id == &#34;local&#34; &amp;&amp; resource.database_name == &#34;employee&#34; &amp;&amp; request.time &lt; timestamp(&#34;2025-04-30T11:10:39.000Z&#34;) resource.instance_id == &#34;local&#34; &amp;&amp; resource.database_name == &#34;employee&#34; |
@@ -6938,7 +6950,13 @@ MaskingExceptionPolicy is the allowlist of users who can access sensitive data.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | A unique identifier for a node in UUID format. |
-| condition | [google.type.Expr](#google-type-Expr) | | |
+| 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.
+
+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;) |
| semantic_type | [string](#string) | | |
@@ -9491,7 +9509,19 @@ When paginating, all other parameters provided to `LiskRisks` must match the cal
| title | [string](#string) | | |
| level | [int32](#int32) | | |
| active | [bool](#bool) | | |
-| condition | [google.type.Expr](#google-type-Expr) | | |
+| 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. export_rows: export data count, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#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.
+
+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 CREATE_DATABASE, support following variables: environment_id project_id db_engine database_name
+
+When the risk source is DATA_EXPORT, support following variables: environment_id project_id db_engine database_name schema_name table_name export_rows
+
+When the risk source is REQUEST_QUERY, support following variables: environment_id project_id db_engine database_name schema_name table_name expiration_days
+
+When the risk source is REQUEST_EXPORT, support following variables: environment_id project_id db_engine database_name schema_name table_name expiration_days export_rows |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 00ac765524..fc250d401a 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -10501,7 +10501,7 @@ Format: users/{email}. </p></td>
<td>condition</td>
<td><a href="#google.type.Expr">google.type.Expr</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>The condition for the role. Same as the condtion in IAM Binding message. </p></td>
</tr>
<tr>
@@ -14107,7 +14107,15 @@ server would not persist the setting value if it is true. </p></td>
<td>condition</td>
<td><a href="#google.type.Expr">google.type.Expr</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>The condition that is associated with the rule.
+The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+
+Support variables:
+source: the risk source, check the Source enum in the Risk message for the values.
+level: the risk level, support 100 (low), 200 (moderate) and 300 (high).
+
+For examples:
+(source == &#34;DML&#34; &amp;&amp; level == 200) || (source == &#34;DDL&#34; &amp;&amp; level == 300) </p></td>
</tr>
</tbody>
@@ -15600,9 +15608,22 @@ For groups, the member should be: group:{email} </p></td>
<td>condition</td>
<td><a href="#google.type.Expr">google.type.Expr</a></td>
<td></td>
- <td><p>The condition that is associated with this binding.
+ <td><p>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. </p></td>
+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; and &#34;roles/projectExporter&#34; role.
+resource.schema: the schema name, used by the &#34;roles/sqlEditorUser&#34; and &#34;roles/projectExporter&#34; role.
+resource.table: the table name, used by the &#34;roles/sqlEditorUser&#34; and &#34;roles/projectExporter&#34; role.
+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/projectExporter&#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 </p></td>
</tr>
<tr>
@@ -19303,7 +19324,22 @@ If this field is omitted, there are no subsequent pages. </p></td>
<td>condition</td>
<td><a href="#google.type.Expr">google.type.Expr</a></td>
<td></td>
- <td><p>The condition that is associated with this exception policy instance. </p></td>
+ <td><p>The condition that is associated with this exception policy instance.
+The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+If the condition is empty, means the user can access all databases without expiration.
+
+Support variables:
+resource.instance_id: the instance resource id. Only support &#34;==&#34; operation.
+resource.database_name: the database name. Only support &#34;==&#34; operation.
+resource.schema_name: the schema name. Only support &#34;==&#34; operation.
+resource.table_name: the table name. Only support &#34;==&#34; operation.
+resource.column_name: the column name. Only support &#34;==&#34; operation.
+request.time: the expiration. Only support &#34;&lt;&#34; operation in `request.time &lt; timestamp(&#34;{ISO datetime string format}&#34;)`
+All variables should join with &#34;&amp;&amp;&#34; condition.
+
+For example:
+resource.instance_id == &#34;local&#34; &amp;&amp; resource.database_name == &#34;employee&#34; &amp;&amp; request.time &lt; timestamp(&#34;2025-04-30T11:10:39.000Z&#34;)
+resource.instance_id == &#34;local&#34; &amp;&amp; resource.database_name == &#34;employee&#34; </p></td>
</tr>
</tbody>
@@ -19358,7 +19394,29 @@ If this field is omitted, there are no subsequent pages. </p></td>
<td>condition</td>
<td><a href="#google.type.Expr">google.type.Expr</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>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.
+
+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;) </p></td>
</tr>
<tr>
@@ -26322,7 +26380,70 @@ If this field is omitted, there are no subsequent pages. </p></td>
<td>condition</td>
<td><a href="#google.type.Expr">google.type.Expr</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>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.
+export_rows: export data count, support &#34;==&#34;, &#34;!=&#34;, &#34;&lt;&#34;, &#34;&lt;=&#34;, &#34;&gt;&#34;, &#34;&gt;=&#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.
+
+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 CREATE_DATABASE, support following variables:
+environment_id
+project_id
+db_engine
+database_name
+
+When the risk source is DATA_EXPORT, support following variables:
+environment_id
+project_id
+db_engine
+database_name
+schema_name
+table_name
+export_rows
+
+When the risk source is REQUEST_QUERY, support following variables:
+environment_id
+project_id
+db_engine
+database_name
+schema_name
+table_name
+expiration_days
+
+When the risk source is REQUEST_EXPORT, support following variables:
+environment_id
+project_id
+db_engine
+database_name
+schema_name
+table_name
+expiration_days
+export_rows </p></td>
</tr>
</tbody>
diff --git a/proto/generated-go/v1/iam_policy.pb.go b/proto/generated-go/v1/iam_policy.pb.go
index de69e1d10a..1e8353ebd1 100644
--- a/proto/generated-go/v1/iam_policy.pb.go
+++ b/proto/generated-go/v1/iam_policy.pb.go
@@ -251,9 +251,22 @@ type Binding struct {
// For users, the member should be: user:{email}
// For groups, the member should be: group:{email}
Members []string `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"`
- // The condition that is associated with this binding.
+ // 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 "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ // resource.schema: the schema name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ // resource.table: the table name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ // 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/projectExporter" 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"]
+ // 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.
ParsedExpr *v1alpha1.Expr `protobuf:"bytes,4,opt,name=parsed_expr,json=parsedExpr,proto3" json:"parsed_expr,omitempty"`
diff --git a/proto/generated-go/v1/issue_service.pb.go b/proto/generated-go/v1/issue_service.pb.go
index d22d31ccc0..073146b615 100644
--- a/proto/generated-go/v1/issue_service.pb.go
+++ b/proto/generated-go/v1/issue_service.pb.go
@@ -1411,7 +1411,8 @@ type GrantRequest struct {
Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
// The user to be granted.
// Format: users/{email}.
- User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"`
+ User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"`
+ // The condition for the role. Same as the condtion in IAM Binding message.
Condition *expr.Expr `protobuf:"bytes,3,opt,name=condition,proto3" json:"condition,omitempty"`
Expiration *durationpb.Duration `protobuf:"bytes,4,opt,name=expiration,proto3" json:"expiration,omitempty"`
unknownFields protoimpl.UnknownFields
diff --git a/proto/generated-go/v1/org_policy_service.pb.go b/proto/generated-go/v1/org_policy_service.pb.go
index fde15b80d6..d74cb77c8f 100644
--- a/proto/generated-go/v1/org_policy_service.pb.go
+++ b/proto/generated-go/v1/org_policy_service.pb.go
@@ -1449,6 +1449,21 @@ type MaskingExceptionPolicy_MaskingException struct {
// - `group:{email}`: An email address for group.
Member string `protobuf:"bytes,3,opt,name=member,proto3" json:"member,omitempty"`
// The condition that is associated with this exception policy instance.
+ // The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ // If the condition is empty, means the user can access all databases without expiration.
+ //
+ // Support variables:
+ // resource.instance_id: the instance resource id. Only support "==" operation.
+ // resource.database_name: the database name. Only support "==" operation.
+ // resource.schema_name: the schema name. Only support "==" operation.
+ // resource.table_name: the table name. Only support "==" operation.
+ // resource.column_name: the column name. Only support "==" operation.
+ // request.time: the expiration. Only support "<" operation in `request.time < timestamp("{ISO datetime string format}")`
+ // All variables should join with "&&" condition.
+ //
+ // For example:
+ // resource.instance_id == "local" && resource.database_name == "employee" && request.time < timestamp("2025-04-30T11:10:39.000Z")
+ // resource.instance_id == "local" && resource.database_name == "employee"
Condition *expr.Expr `protobuf:"bytes,4,opt,name=condition,proto3" json:"condition,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -1508,7 +1523,30 @@ func (x *MaskingExceptionPolicy_MaskingException) GetCondition() *expr.Expr {
type MaskingRulePolicy_MaskingRule struct {
state protoimpl.MessageState `protogen:"open.v1"`
// A unique identifier for a node in UUID format.
- Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+ // 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.
+ //
+ // 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 == "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")
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/proto/generated-go/v1/risk_service.pb.go b/proto/generated-go/v1/risk_service.pb.go
index bcde3b1251..75d64a8d5f 100644
--- a/proto/generated-go/v1/risk_service.pb.go
+++ b/proto/generated-go/v1/risk_service.pb.go
@@ -354,12 +354,78 @@ func (x *DeleteRiskRequest) GetName() string {
type Risk struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Format: risks/{risk}
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Source Risk_Source `protobuf:"varint,3,opt,name=source,proto3,enum=bytebase.v1.Risk_Source" json:"source,omitempty"`
- Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
- Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"`
- Active bool `protobuf:"varint,7,opt,name=active,proto3" json:"active,omitempty"`
- Condition *expr.Expr `protobuf:"bytes,8,opt,name=condition,proto3" json:"condition,omitempty"`
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Source Risk_Source `protobuf:"varint,3,opt,name=source,proto3,enum=bytebase.v1.Risk_Source" json:"source,omitempty"`
+ Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
+ Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"`
+ Active bool `protobuf:"varint,7,opt,name=active,proto3" json:"active,omitempty"`
+ // 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 "==", "!=", "<", "<=", ">", ">=" 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.
+ // 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.
+ // sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // export_rows: export data count, support "==", "!=", "<", "<=", ">", ">=" operations.
+ // expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" 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 CREATE_DATABASE, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ //
+ // When the risk source is DATA_EXPORT, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ // schema_name
+ // table_name
+ // export_rows
+ //
+ // When the risk source is REQUEST_QUERY, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ // schema_name
+ // table_name
+ // expiration_days
+ //
+ // When the risk source is REQUEST_EXPORT, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ // schema_name
+ // table_name
+ // expiration_days
+ // export_rows
+ Condition *expr.Expr `protobuf:"bytes,8,opt,name=condition,proto3" json:"condition,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
diff --git a/proto/generated-go/v1/setting_service.pb.go b/proto/generated-go/v1/setting_service.pb.go
index 1c222de0a4..e9dca9a203 100644
--- a/proto/generated-go/v1/setting_service.pb.go
+++ b/proto/generated-go/v1/setting_service.pb.go
@@ -2453,9 +2453,18 @@ func (x *AppIMSetting_DingTalk) GetRobotCode() string {
}
type WorkspaceApprovalSetting_Rule struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Template *ApprovalTemplate `protobuf:"bytes,2,opt,name=template,proto3" json:"template,omitempty"`
- Condition *expr.Expr `protobuf:"bytes,3,opt,name=condition,proto3" json:"condition,omitempty"`
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Template *ApprovalTemplate `protobuf:"bytes,2,opt,name=template,proto3" json:"template,omitempty"`
+ // The condition that is associated with the rule.
+ // The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ //
+ // Support variables:
+ // source: the risk source, check the Source enum in the Risk message for the values.
+ // level: the risk level, support 100 (low), 200 (moderate) and 300 (high).
+ //
+ // For examples:
+ // (source == "DML" && level == 200) || (source == "DDL" && level == 300)
+ Condition *expr.Expr `protobuf:"bytes,3,opt,name=condition,proto3" json:"condition,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
diff --git a/proto/v1/v1/iam_policy.proto b/proto/v1/v1/iam_policy.proto
index 54f4869e4f..3ff1471e2d 100644
--- a/proto/v1/v1/iam_policy.proto
+++ b/proto/v1/v1/iam_policy.proto
@@ -55,9 +55,22 @@ message Binding {
// For groups, the member should be: group:{email}
repeated string members = 2;
- // The condition that is associated with this binding.
+ // 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 "instances/{instance}/databases/{database}" format, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ // resource.schema: the schema name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ // resource.table: the table name, used by the "roles/sqlEditorUser" and "roles/projectExporter" role.
+ // 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/projectExporter" 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"]
+ // request.time < timestamp("2025-04-26T11:24:48.655Z") && request.row_limit <= 1000
google.type.Expr condition = 3;
// The parsed expression of the condition.
diff --git a/proto/v1/v1/issue_service.proto b/proto/v1/v1/issue_service.proto
index 53deaf823e..cf7c626dcf 100644
--- a/proto/v1/v1/issue_service.proto
+++ b/proto/v1/v1/issue_service.proto
@@ -407,6 +407,7 @@ message GrantRequest {
// The user to be granted.
// Format: users/{email}.
string user = 2;
+ // The condition for the role. Same as the condtion in IAM Binding message.
google.type.Expr condition = 3;
google.protobuf.Duration expiration = 4;
}
diff --git a/proto/v1/v1/org_policy_service.proto b/proto/v1/v1/org_policy_service.proto
index 413caf5739..28a00cedab 100644
--- a/proto/v1/v1/org_policy_service.proto
+++ b/proto/v1/v1/org_policy_service.proto
@@ -333,6 +333,21 @@ message MaskingExceptionPolicy {
string member = 3;
// The condition that is associated with this exception policy instance.
+ // The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ // If the condition is empty, means the user can access all databases without expiration.
+ //
+ // Support variables:
+ // resource.instance_id: the instance resource id. Only support "==" operation.
+ // resource.database_name: the database name. Only support "==" operation.
+ // resource.schema_name: the schema name. Only support "==" operation.
+ // resource.table_name: the table name. Only support "==" operation.
+ // resource.column_name: the column name. Only support "==" operation.
+ // request.time: the expiration. Only support "<" operation in `request.time < timestamp("{ISO datetime string format}")`
+ // All variables should join with "&&" condition.
+ //
+ // For example:
+ // resource.instance_id == "local" && resource.database_name == "employee" && request.time < timestamp("2025-04-30T11:10:39.000Z")
+ // resource.instance_id == "local" && resource.database_name == "employee"
google.type.Expr condition = 4;
}
@@ -344,6 +359,29 @@ message MaskingRulePolicy {
// A unique identifier for a node in UUID format.
string id = 1;
+ // 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.
+ //
+ // 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 == "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")
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 58bc3f9175..0c192b442e 100644
--- a/proto/v1/v1/risk_service.proto
+++ b/proto/v1/v1/risk_service.proto
@@ -126,5 +126,70 @@ message Risk {
string title = 4;
int32 level = 5;
bool active = 7;
+
+ // 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 "==", "!=", "<", "<=", ">", ">=" 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.
+ // 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.
+ // sql_statement: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // export_rows: export data count, support "==", "!=", "<", "<=", ">", ">=" operations.
+ // expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" 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 CREATE_DATABASE, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ //
+ // When the risk source is DATA_EXPORT, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ // schema_name
+ // table_name
+ // export_rows
+ //
+ // When the risk source is REQUEST_QUERY, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ // schema_name
+ // table_name
+ // expiration_days
+ //
+ // When the risk source is REQUEST_EXPORT, support following variables:
+ // environment_id
+ // project_id
+ // db_engine
+ // database_name
+ // schema_name
+ // table_name
+ // expiration_days
+ // export_rows
google.type.Expr condition = 8;
}
diff --git a/proto/v1/v1/setting_service.proto b/proto/v1/v1/setting_service.proto
index 57a48f1475..1fffe24b3c 100644
--- a/proto/v1/v1/setting_service.proto
+++ b/proto/v1/v1/setting_service.proto
@@ -283,6 +283,15 @@ message Announcement {
message WorkspaceApprovalSetting {
message Rule {
ApprovalTemplate template = 2;
+ // The condition that is associated with the rule.
+ // The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
+ //
+ // Support variables:
+ // source: the risk source, check the Source enum in the Risk message for the values.
+ // level: the risk level, support 100 (low), 200 (moderate) and 300 (high).
+ //
+ // For examples:
+ // (source == "DML" && level == 200) || (source == "DDL" && level == 300)
google.type.Expr condition = 3;
}
repeated Rule rules = 1;