Skip to content

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

chore: match word boundary, more robust (#9513)

p0ny47a6ce9b05d2
diff --git a/backend/utils/database_group.go b/backend/utils/database_group.go
index 83fc281d0d..76489aadc4 100644
--- a/backend/utils/database_group.go
+++ b/backend/utils/database_group.go
@@ -2,6 +2,7 @@ package utils
import (
"fmt"
+ "regexp"
"strings"
"github.com/pkg/errors"
@@ -77,7 +78,11 @@ func GetStatementsAndSchemaGroupsFromSchemaGroups(statement string, engine store
continue
}
for _, schemaGroup := range schemaGroups {
- if strings.Contains(singleStatement.Text, schemaGroup.Placeholder) {
+ re, err := regexp.Compile(`\b` + schemaGroup.Placeholder + `\b`)
+ if err != nil {
+ return nil, nil, errors.Wrapf(err, "failed to compile regexp")
+ }
+ if re.MatchString(singleStatement.Text) {
curMatch = schemaGroup
break
}