Skip to content

Commit

Permalink
Check for ALL PRIVILEGES with boundaries. Improve test case for MySQL…
Browse files Browse the repository at this point in the history
… 8 (#155)

Co-authored-by: Victor Cabezas <vcabezas@tuenti.com>
  • Loading branch information
Wiston999 and Victor Cabezas authored Jun 20, 2024
1 parent e094f30 commit 1a616c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mysql/resource_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ func normalizeColumnOrder(perm string) string {
return fmt.Sprintf("%s(%s)", precursor, partsTogether)
}

var kReAllPrivileges = regexp.MustCompile(`ALL ?(PRIVILEGES)?`)
var kReAllPrivileges = regexp.MustCompile(`\bALL ?(PRIVILEGES)?\b`)

func normalizePerms(perms []string) []string {
ret := []string{}
Expand Down
4 changes: 3 additions & 1 deletion mysql/resource_grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ func TestAccGrantComplexMySQL8(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccPrivilege("mysql_grant.test", "SHOW DATABASES", true, false),
testAccPrivilege("mysql_grant.test", "CONNECTION_ADMIN", true, false),
testAccPrivilege("mysql_grant.test", "FIREWALL_EXEMPT", true, false),
testAccPrivilege("mysql_grant.test", "SELECT", true, false),
testAccPrivilege("mysql_grant.test", "ALL PRIVILEGES", false, false),
),
},
},
Expand Down Expand Up @@ -616,7 +618,7 @@ resource "mysql_grant" "test" {
host = "${mysql_user.test.host}"
table = "*"
database = "*"
privileges = ["SHOW DATABASES", "CONNECTION_ADMIN", "SELECT"]
privileges = ["SHOW DATABASES", "CONNECTION_ADMIN", "SELECT", "FIREWALL_EXEMPT"]
}
`, dbName, dbName)
Expand Down

0 comments on commit 1a616c1

Please sign in to comment.