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: support table_name as a risk factor for DDL&DML (#13044)
p0ny6568800a7a61
diff --git a/backend/common/cel.go b/backend/common/cel.goindex 54316db7e8..3f3b3330c1 100644--- a/backend/common/cel.go+++ b/backend/common/cel.go@@ -24,6 +24,7 @@ var RiskFactors = []cel.EnvOption{cel.Variable("database_name", cel.StringType),cel.Variable("db_engine", cel.StringType),cel.Variable("sql_type", cel.StringType),+ cel.Variable("table_name", cel.StringType),// number factorscel.Variable("affected_rows", cel.IntType),diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.goindex 29f74019ac..75525821dd 100644--- a/backend/runner/approval/runner.go+++ b/backend/runner/approval/runner.go@@ -531,14 +531,26 @@ func getDatabaseGeneralIssueRisk(ctx context.Context, s *store.Store, sheetManag}args["affected_rows"] = report.AffectedRowsargs["table_rows"] = tableRows++ var tableNames []string+ for _, db := range report.GetChangedResources().GetDatabases() {+ for _, schema := range db.GetSchemas() {+ for _, table := range schema.GetTables() {+ tableNames = append(tableNames, table.Name)+ }+ }+ }for _, statementType := range report.StatementTypes {args["sql_type"] = statementType- out, _, err := prg.Eval(args)- if err != nil {- return 0, err- }- if res, ok := out.Equal(celtypes.True).Value().(bool); ok && res {- return risk.Level, nil+ for _, tableName := range tableNames {+ args["table_name"] = tableName+ out, _, err := prg.Eval(args)+ if err != nil {+ return 0, err+ }+ if res, ok := out.Equal(celtypes.True).Value().(bool); ok && res {+ return risk.Level, nil+ }}}}diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.tsindex 9c611a8eac..029baad33c 100644--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts@@ -60,6 +60,7 @@ const StringFactorList = ["database_name","db_engine","sql_type",+ "table_name",] as const;const FactorList = {@@ -84,6 +85,7 @@ const FactorList = {CreateDatabase: without([...StringFactorList],"sql_type",+ "table_name","expiration_days","export_rows"),@@ -95,6 +97,7 @@ const FactorList = {"table_rows","source","sql_type",+ "table_name","expiration_days","export_rows")@@ -107,6 +110,7 @@ const FactorList = {"affected_rows","table_rows","sql_type",+ "table_name","export_rows")),@@ -117,7 +121,8 @@ const FactorList = {"source","affected_rows","table_rows",- "sql_type"+ "sql_type",+ "table_name",)),};