Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_synapse_firewall_rule: fix rule name regex #22571

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/services/synapse/validate/firewall_rule_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ func FirewallRuleName(i interface{}, k string) (warnings []string, errors []erro
}

// The name attribute rules are :
// 1. can contain only letters, numbers, underscore and hyphen.
// 1. Can't contain '<,>,*,%,&,:,\,/,?'.
// 2. Can't end with '.'
// 2. The value must be between 1 and 128 characters long

if !regexp.MustCompile(`^[a-zA-Z\d-_]{1,128}$`).MatchString(v) {
errors = append(errors, fmt.Errorf("%s can contain only letters, numbers, underscore and hyphen, and be between 1 and 128 characters long", k))
if !regexp.MustCompile(`^[^<>*%&:\\/?]{0,127}[^.<>*%&:\\/?]$`).MatchString(v) {
errors = append(errors, fmt.Errorf("%s can't contain '<,>,*,%%,&,:,\\,/,?', can't end with '.', and must be between 1 and 128 characters long", k))
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func TestFirewallRuleName(t *testing.T) {
input: "ab-c",
expected: true,
},
{
// can contain utf-8 chars
input: "øüå-rule",
expected: true,
},
{
// can't contain `*`
input: "abcon*demand",
Expand Down