Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: fix panic when SQL has no FROM clause (#3566)
rebelice13c7974a58ba
diff --git a/plugin/db/util/driverutil.go b/plugin/db/util/driverutil.goindex 6b8b2681ca..525a0c9600 100644--- a/plugin/db/util/driverutil.go+++ b/plugin/db/util/driverutil.go@@ -799,9 +799,15 @@ func extractMySQLStarLength(fieldName []string, selectStmt *tidbast.SelectStmt)}func extractMySQLSingleTable(fromClause *tidbast.TableRefsClause) (string, string, bool) {+ if fromClause == nil || fromClause.TableRefs == nil {+ return "", "", false+ }if fromClause.TableRefs.Right != nil {return "", "", false}+ if fromClause.TableRefs.Left == nil {+ return "", "", false+ }tableSource, ok := fromClause.TableRefs.Left.(*tidbast.TableSource)if !ok {return "", "", falsediff --git a/plugin/db/util/driverutil_test.go b/plugin/db/util/driverutil_test.goindex 9cfc3b051e..1cfe2c3071 100644--- a/plugin/db/util/driverutil_test.go+++ b/plugin/db/util/driverutil_test.go@@ -287,6 +287,12 @@ func TestExtractSensitiveField(t *testing.T) {6: true,},},+ {+ statement: "select 1;",+ fieldName: []string{"1"},+ sensitiveDataMap: db.SensitiveDataMap{},+ fieldMap: sensitiveFiledMap{},+ },}for _, test := range tests {