Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: policy cel condition support environment (#6520)
Danny Xu1e8567654e98
diff --git a/backend/api/v1/cel_service.go b/backend/api/v1/cel_service.goindex b0cb01fc42..b8d8a8deab 100644--- a/backend/api/v1/cel_service.go+++ b/backend/api/v1/cel_service.go@@ -21,19 +21,9 @@ func NewCelService() *CelService {return &CelService{}}-var queryAttributes = []cel.EnvOption{- cel.Variable("request.time", cel.TimestampType),- cel.Variable("request.statement", cel.StringType),- cel.Variable("request.row_limit", cel.IntType),- cel.Variable("request.export_format", cel.StringType),- cel.Variable("resource.database", cel.StringType),- cel.Variable("resource.schema", cel.StringType),- cel.Variable("resource.table", cel.StringType),-}-// Parse parses a CEL expression.func (*CelService) Parse(_ context.Context, request *v1pb.ParseRequest) (*v1pb.ParseResponse, error) {- e, err := cel.NewEnv(queryAttributes...)+ e, err := cel.NewEnv(iamPolicyCELAttributes...)if err != nil {return nil, status.Errorf(codes.Internal, "failed to create CEL environment: %v", err)}diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex 5dfe20757d..d10ee9bc2f 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -2266,6 +2266,7 @@ var iamPolicyCELAttributes = []cel.EnvOption{cel.Variable("request.statement", cel.StringType),cel.Variable("request.row_limit", cel.IntType),cel.Variable("request.export_format", cel.StringType),+ cel.Variable("resource.environment", cel.StringType),cel.Variable("resource.database", cel.StringType),cel.Variable("resource.schema", cel.StringType),cel.Variable("resource.table", cel.StringType),diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 40f2642a73..21166b06cd 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -1256,12 +1256,13 @@ func (s *SQLService) checkQueryRights(for _, resource := range resourceList {databaseResourceURL := fmt.Sprintf("instances/%s/databases/%s", instance.ResourceID, resource.Database)attributes := map[string]any{- "request.time": time.Now(),- "resource.database": databaseResourceURL,- "resource.schema": resource.Schema,- "resource.table": resource.Table,- "request.statement": base64.StdEncoding.EncodeToString([]byte(statement)),- "request.row_limit": limit,+ "request.time": time.Now(),+ "resource.environment": instance.EnvironmentID,+ "resource.database": databaseResourceURL,+ "resource.schema": resource.Schema,+ "resource.table": resource.Table,+ "request.statement": base64.StdEncoding.EncodeToString([]byte(statement)),+ "request.row_limit": limit,}switch exportFormat {@@ -1396,7 +1397,7 @@ func evaluateCondition(expression string, attributes map[string]any) (bool, erroif expression == "" {return true, nil}- env, err := cel.NewEnv(queryAttributes...)+ env, err := cel.NewEnv(iamPolicyCELAttributes...)if err != nil {return false, err}