Skip to content

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

feat: risk new factor: table rows (#10640)

p0ny96cefabcf412
diff --git a/backend/common/cel.go b/backend/common/cel.go
index b2e15f1a74..becad1457e 100644
--- a/backend/common/cel.go
+++ b/backend/common/cel.go
@@ -30,6 +30,7 @@ var RiskFactors = []cel.EnvOption{
cel.Variable("affected_rows", cel.IntType),
cel.Variable("expiration_days", cel.IntType),
cel.Variable("export_rows", cel.IntType),
+ cel.Variable("table_rows", cel.IntType),
}
// ApprovalFactors are the variables when finding the approval template.
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 517b8d35d0..cbeb999aeb 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -515,6 +515,7 @@ func getDatabaseGeneralIssueRisk(ctx context.Context, s *store.Store, licenseSer
"db_engine": instance.Engine.String(),
"sql_type": "UNKNOWN",
"affected_rows": math.MaxInt32,
+ "table_rows": math.MaxInt64,
}
if run, ok := latestPlanCheckRun[Key{
@@ -526,7 +527,16 @@ func getDatabaseGeneralIssueRisk(ctx context.Context, s *store.Store, licenseSer
if report == nil {
continue
}
+ var tableRows int64
+ for _, db := range report.GetChangedResources().GetDatabases() {
+ for _, sc := range db.GetSchemas() {
+ for _, tb := range sc.GetTables() {
+ tableRows += tb.GetTableRows()
+ }
+ }
+ }
args["affected_rows"] = report.AffectedRows
+ args["table_rows"] = tableRows
for _, statementType := range report.StatementTypes {
args["sql_type"] = statementType
res, _, err := prg.Eval(args)
@@ -546,6 +556,7 @@ func getDatabaseGeneralIssueRisk(ctx context.Context, s *store.Store, licenseSer
args["sql_type"] = "UNKNOWN"
args["affected_rows"] = math.MaxInt32
+ args["table_rows"] = math.MaxInt64
res, _, err := prg.Eval(args)
if err != nil {
return 0, err