Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: restrict cel format when updating project members (#8468)
zll6003995480125d7
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex a36ace00ac..62ea03fe36 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -2847,6 +2847,10 @@ func validateBindings(bindings []*v1pb.Binding, roles []*v1pb.Role) error {}}projectRoleMap[binding.Role] = true++ if _, err := common.ValidateProjectMemberCELExpr(binding.Condition); err != nil {+ return err+ }}// Must contain one owner binding.if _, ok := projectRoleMap["roles/OWNER"]; !ok {diff --git a/backend/common/convert.go b/backend/common/convert.goindex bbeeba5e7e..9f7db9b209 100644--- a/backend/common/convert.go+++ b/backend/common/convert.go@@ -73,6 +73,17 @@ var MaskingExceptionPolicyCELAttributes = []cel.EnvOption{cel.ParserExpressionSizeLimit(celLimit),}+var ProjectMemberCELAttributes = []cel.EnvOption{+ cel.Variable("resource.environment_name", cel.StringType),+ cel.Variable("resource.database", cel.StringType),+ cel.Variable("resource.schema", cel.StringType),+ cel.Variable("resource.table", cel.StringType),+ cel.Variable("request.statement", cel.StringType),+ cel.Variable("request.row_limit", cel.IntType),+ cel.Variable("request.time", cel.TimestampType),+ cel.ParserExpressionSizeLimit(celLimit),+}+// ConvertParsedRisk converts parsed risk to unparsed format.func ConvertParsedRisk(expression *v1alpha1.ParsedExpr) (*expr.Expr, error) {if expression == nil || expression.Expr == nil {@@ -202,6 +213,27 @@ func ValidateMaskingExceptionCELExpr(expr string) (cel.Program, error) {return prog, nil}+func ValidateProjectMemberCELExpr(expression *expr.Expr) (cel.Program, error) {+ if expression == nil || expression.Expression == "" {+ return nil, nil+ }+ e, err := cel.NewEnv(+ ProjectMemberCELAttributes...,+ )+ if err != nil {+ return nil, status.Errorf(codes.Internal, err.Error())+ }+ ast, issues := e.Parse(expression.Expression)+ if issues != nil && issues.Err() != nil {+ return nil, status.Errorf(codes.InvalidArgument, issues.Err().Error())+ }+ prog, err := e.Program(ast)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }+ return prog, nil+}+// QueryExportFactors is the factors for query and export.type QueryExportFactors struct {DatabaseNames []string