Skip to content

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

feat: standardize CEL attribute naming with scope prefixes (#17662)

Danny Xu6d48330f70db
diff --git a/backend/api/v1/release_service_check.go b/backend/api/v1/release_service_check.go
index 630a093492..f034d84d05 100644
--- a/backend/api/v1/release_service_check.go
+++ b/backend/api/v1/release_service_check.go
@@ -248,7 +248,7 @@ loop:
"resource.database_name": database.DatabaseName,
// convert to string type otherwise cel-go will complain that storepb.Engine is not string type.
"resource.db_engine": engine.String(),
- "sql_statement": statement,
+ "statement.text": statement,
}
if database.EffectiveEnvironmentID != nil {
commonArgs["resource.environment_id"] = *database.EffectiveEnvironmentID
diff --git a/backend/api/v1/risk_service_calculator.go b/backend/api/v1/risk_service_calculator.go
index 7869fee44f..ff667aec8d 100644
--- a/backend/api/v1/risk_service_calculator.go
+++ b/backend/api/v1/risk_service_calculator.go
@@ -83,8 +83,8 @@ func CalculateRiskLevelWithOptionalSummaryReport(
}
}
}
- args["affected_rows"] = summaryReport.AffectedRows
- args["table_rows"] = tableRows
+ args["statement.affected_rows"] = summaryReport.AffectedRows
+ args["statement.table_rows"] = tableRows
var tableNames []string
for _, db := range summaryReport.GetChangedResources().GetDatabases() {
for _, schema := range db.GetSchemas() {
@@ -94,7 +94,7 @@ func CalculateRiskLevelWithOptionalSummaryReport(
}
}
for _, statementType := range summaryReport.StatementTypes {
- args["sql_type"] = statementType
+ args["statement.sql_type"] = statementType
for _, tableName := range tableNames {
args["resource.table_name"] = tableName
out, _, err := prg.Eval(args)
diff --git a/backend/common/cel.go b/backend/common/cel.go
index 66d0332d08..e02815afc0 100644
--- a/backend/common/cel.go
+++ b/backend/common/cel.go
@@ -25,13 +25,13 @@ var RiskFactors = []cel.EnvOption{
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),
- cel.Variable("sql_type", cel.StringType),
- cel.Variable("sql_statement", cel.StringType),
+ cel.Variable("statement.affected_rows", cel.IntType),
+ cel.Variable("statement.table_rows", cel.IntType),
+ cel.Variable("statement.sql_type", cel.StringType),
+ cel.Variable("statement.text", cel.StringType),
- cel.Variable("expiration_days", cel.IntType),
- cel.Variable("role", cel.StringType),
+ cel.Variable("request.expiration_days", cel.IntType),
+ cel.Variable("request.role", cel.StringType),
}
// ApprovalFactors are the variables when finding the approval template.
diff --git a/backend/generated-go/v1/risk_service.pb.go b/backend/generated-go/v1/risk_service.pb.go
index a974e33a4c..a02bfc41d6 100644
--- a/backend/generated-go/v1/risk_service.pb.go
+++ b/backend/generated-go/v1/risk_service.pb.go
@@ -416,12 +416,12 @@ type Risk struct {
// 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.
+ // statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
+ // statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
// resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
// resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
// resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
- // sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ // statement.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.
@@ -429,21 +429,21 @@ type Risk struct {
// 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.
+ // statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
+ // request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
//
// When the risk source is DDL/DML, support following variables:
- // affected_rows
- // table_rows
+ // statement.affected_rows
+ // statement.table_rows
// resource.environment_id
// resource.project_id
// resource.db_engine
- // sql_type
+ // statement.sql_type
// resource.database_name
// resource.schema_name
// resource.table_name
- // sql_statement
+ // statement.text
//
// When the risk source is CREATE_DATABASE, support following variables:
// resource.environment_id
@@ -461,8 +461,8 @@ type Risk struct {
//
// When the risk source is REQUEST_ROLE, support following variables:
// resource.project_id
- // expiration_days
- // role
+ // request.expiration_days
+ // request.role
Condition *expr.Expr `protobuf:"bytes,8,opt,name=condition,proto3" json:"condition,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
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
index ba8e3e67c3..365bd74764 100644
--- a/backend/migrator/migration/3.11/0004##migrate_cel_attribute_names.sql
+++ b/backend/migrator/migration/3.11/0004##migrate_cel_attribute_names.sql
@@ -18,6 +18,16 @@
-- 10. resource.table -> resource.table_name (in IAM policies)
-- 11. resource.labels -> resource.database_labels (in database groups)
--
+-- Statement-related attribute changes (adding statement.* prefix):
+-- 12. affected_rows -> statement.affected_rows
+-- 13. table_rows -> statement.table_rows
+-- 14. sql_type -> statement.sql_type
+-- 15. sql_statement -> statement.text
+--
+-- Request-related attribute changes (adding request.* prefix):
+-- 16. expiration_days -> request.expiration_days
+-- 17. role -> request.role
+--
-- Affected tables:
-- - risk: Risk evaluation CEL expressions
-- - db_group: Database group matching CEL expressions
@@ -26,8 +36,9 @@
-- 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
+-- We need to add resource.*, statement.*, and request.* prefixes to attributes that didn't have it
-- Using regexp_replace to match whole identifiers (not partial matches)
+-- Note: We must do sql_statement -> statement.text BEFORE sql_type -> statement.sql_type to avoid partial match issues
UPDATE risk
SET expression = jsonb_set(
expression,
@@ -40,38 +51,71 @@ SET expression = jsonb_set(
regexp_replace(
regexp_replace(
regexp_replace(
- expression->>'expression',
- '\m(environment_id)\M',
- 'resource.environment_id',
+ 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'
),
- '\m(project_id)\M',
- 'resource.project_id',
+ '\m(affected_rows)\M',
+ 'statement.affected_rows',
'g'
),
- '\m(instance_id)\M',
- 'resource.instance_id',
+ '\m(table_rows)\M',
+ 'statement.table_rows',
'g'
),
- '\m(db_engine)\M',
- 'resource.db_engine',
+ '\m(sql_statement)\M',
+ 'statement.text',
'g'
),
- '\m(database_name)\M',
- 'resource.database_name',
+ '\m(sql_type)\M',
+ 'statement.sql_type',
'g'
),
- '\m(schema_name)\M',
- 'resource.schema_name',
+ '\m(expiration_days)\M',
+ 'request.expiration_days',
'g'
),
- '\m(table_name)\M',
- 'resource.table_name',
+ '\mrole\M',
+ 'request.role',
'g'
)
)
)
-WHERE expression->>'expression' ~ '\m(environment_id|project_id|instance_id|db_engine|database_name|schema_name|table_name)\M';
+WHERE expression->>'expression' ~ '\m(environment_id|project_id|instance_id|db_engine|database_name|schema_name|table_name|affected_rows|table_rows|sql_statement|sql_type|expiration_days|role)\M'
+ AND expression->>'expression' !~ 'resource\.(environment_id|project_id|instance_id|db_engine|database_name|schema_name|table_name)'
+ AND expression->>'expression' !~ 'statement\.(affected_rows|table_rows|sql_type|text)'
+ AND expression->>'expression' !~ 'request\.(expiration_days|role)';
-- Update database group expressions
-- The db_group.expression column stores CEL expressions in jsonb format with an "expression" field
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 294cf56459..9dc8cf1782 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -469,7 +469,7 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I
"resource.database_name": databaseName,
// convert to string type otherwise cel-go will complain that storepb.Engine is not string type.
"resource.db_engine": instance.Metadata.GetEngine().String(),
- "sql_statement": taskStatement,
+ "statement.text": taskStatement,
}
risk, err := func() (int32, error) {
// The summary report is not always available.
@@ -680,9 +680,9 @@ func (r *Runner) getGrantRequestIssueRisk(ctx context.Context, issue *store.Issu
}
args := map[string]any{
- "resource.project_id": issue.Project.ResourceID,
- "expiration_days": expirationDays,
- "role": payload.GrantRequest.Role,
+ "resource.project_id": issue.Project.ResourceID,
+ "request.expiration_days": expirationDays,
+ "request.role": payload.GrantRequest.Role,
}
if len(factors.Databases) == 0 {
environments, err := r.store.GetEnvironmentSetting(ctx)
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 ea08ac2c17..89558e21d2 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
@@ -44,7 +44,7 @@ export const useRuleTemplates = () => {
expr: wrapAsGroup({
type: ExprType.Condition,
operator: "_==_",
- args: ["role", PresetRoleType.PROJECT_OWNER],
+ args: ["request.role", PresetRoleType.PROJECT_OWNER],
}),
level: PresetRiskLevel.HIGH,
source: Risk_Source.REQUEST_ROLE,
@@ -79,12 +79,12 @@ export const useRuleTemplates = () => {
{
type: ExprType.Condition,
operator: "_>_",
- args: ["affected_rows", 10000],
+ args: ["statement.affected_rows", 10000],
},
{
type: ExprType.Condition,
operator: "@in",
- args: ["sql_type", ["UPDATE", "DELETE"]],
+ args: ["statement.sql_type", ["UPDATE", "DELETE"]],
},
],
}),
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
index 7d8e6a3c56..6859dcb729 100644
--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
@@ -86,10 +86,10 @@ const schemaObjectNameFactorList: Factor[] = [
] as const;
const migrationFactorList: Factor[] = [
- "affected_rows",
- "table_rows",
- "sql_type",
- "sql_statement",
+ "statement.affected_rows",
+ "statement.table_rows",
+ "statement.sql_type",
+ "statement.text",
] as const;
export const RiskSourceFactorMap: Map<Risk_Source, Factor[]> = new Map([
@@ -122,8 +122,8 @@ export const RiskSourceFactorMap: Map<Risk_Source, Factor[]> = new Map([
[
"resource.environment_id",
"resource.project_id",
- "expiration_days",
- "role",
+ "request.expiration_days",
+ "request.role",
],
],
]);
@@ -288,10 +288,10 @@ export const getOptionConfigMap = (source: Risk_Source) => {
case "source":
options = getSourceOptions();
break;
- case "sql_type":
+ case "statement.sql_type":
options = getSQLTypeOptions(source);
break;
- case "role":
+ case "request.role":
options = getRoleOptions();
break;
//
@@ -303,11 +303,11 @@ export const getOptionConfigMap = (source: Risk_Source) => {
case "resource.database_name":
case "resource.column_name":
case "resource.classification_level":
- case "affected_rows":
- case "table_rows":
- case "sql_statement":
+ case "statement.affected_rows":
+ case "statement.table_rows":
+ case "statement.text":
case "request.row_limit":
- case "expiration_days":
+ case "request.expiration_days":
case "request.time":
break;
default:
@@ -327,8 +327,8 @@ export const factorSupportDropdown: Factor[] = [
"resource.project_id",
"resource.instance_id",
"resource.db_engine",
- "sql_type",
+ "statement.sql_type",
"level",
"source",
- "role",
+ "request.role",
];
diff --git a/frontend/src/plugins/cel/types/factor.ts b/frontend/src/plugins/cel/types/factor.ts
index 896ae47486..f7dc8bba8a 100644
--- a/frontend/src/plugins/cel/types/factor.ts
+++ b/frontend/src/plugins/cel/types/factor.ts
@@ -1,14 +1,14 @@
export const NumberFactorList = [
// Risk related factors
- "affected_rows",
- "table_rows",
+ "statement.affected_rows",
+ "statement.table_rows",
"level",
// Grant request issue related factors
"request.row_limit",
// Request query/export factors
- "expiration_days",
+ "request.expiration_days",
] as const;
export type NumberFactor = (typeof NumberFactorList)[number];
@@ -22,9 +22,9 @@ export const StringFactorList = [
"resource.table_name",
"resource.instance_id",
"resource.db_engine",
- "sql_type",
- "sql_statement",
- "role",
+ "statement.sql_type",
+ "statement.text",
+ "request.role",
// Grant request issue related factors
"resource.database",
diff --git a/frontend/src/plugins/cel/types/operator.ts b/frontend/src/plugins/cel/types/operator.ts
index efc0ba4ab0..847ecf6e84 100644
--- a/frontend/src/plugins/cel/types/operator.ts
+++ b/frontend/src/plugins/cel/types/operator.ts
@@ -54,8 +54,14 @@ export const isStringOperator = (op: Operator): op is StringOperator => {
/// Define supported operators for each factor
const OperatorList: Record<Factor, Operator[]> = {
- affected_rows: uniq([...EqualityOperatorList, ...CompareOperatorList]),
- table_rows: uniq([...EqualityOperatorList, ...CompareOperatorList]),
+ "statement.affected_rows": uniq([
+ ...EqualityOperatorList,
+ ...CompareOperatorList,
+ ]),
+ "statement.table_rows": uniq([
+ ...EqualityOperatorList,
+ ...CompareOperatorList,
+ ]),
level: uniq([...EqualityOperatorList, ...CollectionOperatorList]),
source: uniq([...EqualityOperatorList, ...CollectionOperatorList]),
@@ -99,17 +105,20 @@ const OperatorList: Record<Factor, Operator[]> = {
...CollectionOperatorList,
...StringOperatorList,
]),
- sql_type: uniq([
+ "statement.sql_type": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
]),
- sql_statement: uniq([...StringOperatorList]),
+ "statement.text": uniq([...StringOperatorList]),
"resource.classification_level": uniq([...CollectionOperatorList]),
// Request query/export factors
- expiration_days: uniq([...EqualityOperatorList, ...CompareOperatorList]),
- role: uniq([
+ "request.expiration_days": uniq([
+ ...EqualityOperatorList,
+ ...CompareOperatorList,
+ ]),
+ "request.role": uniq([
...EqualityOperatorList,
...CollectionOperatorList,
...StringOperatorList,
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 20f94d04a6..9a97b2cab4 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
@@ -198,32 +198,32 @@ export declare type Risk = Message<"bytebase.v1.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.
+ * statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
+ * statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
* resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
* resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
* resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
- * sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ * statement.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.
* 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.
+ * statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ * request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
+ * request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
*
* When the risk source is DDL/DML, support following variables:
- * affected_rows
- * table_rows
+ * statement.affected_rows
+ * statement.table_rows
* resource.environment_id
* resource.project_id
* resource.db_engine
- * sql_type
+ * statement.sql_type
* resource.database_name
* resource.schema_name
* resource.table_name
- * sql_statement
+ * statement.text
*
* When the risk source is CREATE_DATABASE, support following variables:
* resource.environment_id
@@ -241,8 +241,8 @@ export declare type Risk = Message<"bytebase.v1.Risk"> & {
*
* When the risk source is REQUEST_ROLE, support following variables:
* resource.project_id
- * expiration_days
- * role
+ * request.expiration_days
+ * request.role
*
* @generated from field: google.type.Expr condition = 8;
*/
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 48a957483c..51187a4b9b 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -12710,32 +12710,32 @@ components:
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.
+ statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
+ statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
- sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ statement.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.
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.
+ statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
+ request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
When the risk source is DDL/DML, support following variables:
- affected_rows
- table_rows
+ statement.affected_rows
+ statement.table_rows
resource.environment_id
resource.project_id
resource.db_engine
- sql_type
+ statement.sql_type
resource.database_name
resource.schema_name
resource.table_name
- sql_statement
+ statement.text
When the risk source is CREATE_DATABASE, support following variables:
resource.environment_id
@@ -12753,8 +12753,8 @@ components:
When the risk source is REQUEST_ROLE, support following variables:
resource.project_id
- expiration_days
- role
+ request.expiration_days
+ request.role
Role:
type: object
properties:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 270bed0ed9..741623c660 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -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. 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.
+All supported variables: statement.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. statement.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. statement.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. statement.text: the SQL statement, support &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations. request.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. request.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 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 DDL/DML, support following variables: statement.affected_rows statement.table_rows resource.environment_id resource.project_id resource.db_engine statement.sql_type resource.database_name resource.schema_name resource.table_name statement.text
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: 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: resource.project_id expiration_days role |
+When the risk source is REQUEST_ROLE, support following variables: resource.project_id request.expiration_days request.role |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 32ccdedfb5..a04affbf68 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -27111,32 +27111,32 @@ If this field is omitted, there are no subsequent pages. </p></td>
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.
+statement.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.
+statement.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.
+statement.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.
+statement.text: the SQL statement, support &#34;contains()&#34;, &#34;matches()&#34;, &#34;startsWith()&#34;, &#34;endsWith()&#34; operations.
+request.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.
+request.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
+statement.affected_rows
+statement.table_rows
resource.environment_id
resource.project_id
resource.db_engine
-sql_type
+statement.sql_type
resource.database_name
resource.schema_name
resource.table_name
-sql_statement
+statement.text
When the risk source is CREATE_DATABASE, support following variables:
resource.environment_id
@@ -27154,8 +27154,8 @@ resource.table_name
When the risk source is REQUEST_ROLE, support following variables:
resource.project_id
-expiration_days
-role </p></td>
+request.expiration_days
+request.role </p></td>
</tr>
</tbody>
diff --git a/proto/v1/v1/risk_service.proto b/proto/v1/v1/risk_service.proto
index da49c32735..467d7451cd 100644
--- a/proto/v1/v1/risk_service.proto
+++ b/proto/v1/v1/risk_service.proto
@@ -155,32 +155,32 @@ message 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.
+ // statement.affected_rows: affected row count in the DDL/DML, support "==", "!=", "<", "<=", ">", ">=" operations.
+ // statement.table_rows: table row count number, support "==", "!=", "<", "<=", ">", ">=" operations.
// resource.environment_id: the environment resource id, support "==", "!=", "in [xx]", "!(in [xx])" operations.
// resource.project_id: the project resource id, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
// resource.db_engine: the database engine type, support "==", "!=", "in [xx]", "!(in [xx])" operations. Check the Engine enum for the values.
- // sql_type: the SQL type, support "==", "!=", "in [xx]", "!(in [xx])" operations.
+ // statement.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.
// 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.
+ // statement.text: the SQL statement, support "contains()", "matches()", "startsWith()", "endsWith()" operations.
+ // request.expiration_days: the role expiration days for the request, support "==", "!=", "<", "<=", ">", ">=" operations.
+ // request.role: the request role full name, support "==", "!=", "in [xx]", "!(in [xx])", "contains()", "matches()", "startsWith()", "endsWith()" operations.
//
// When the risk source is DDL/DML, support following variables:
- // affected_rows
- // table_rows
+ // statement.affected_rows
+ // statement.table_rows
// resource.environment_id
// resource.project_id
// resource.db_engine
- // sql_type
+ // statement.sql_type
// resource.database_name
// resource.schema_name
// resource.table_name
- // sql_statement
+ // statement.text
//
// When the risk source is CREATE_DATABASE, support following variables:
// resource.environment_id
@@ -198,7 +198,7 @@ message Risk {
//
// When the risk source is REQUEST_ROLE, support following variables:
// resource.project_id
- // expiration_days
- // role
+ // request.expiration_days
+ // request.role
google.type.Expr condition = 8;
}