Skip to content

Commit

Permalink
azurerm_synapse_firewall_rule: fix rule name regex
Browse files Browse the repository at this point in the history
The rule name regex is actually more lenient. To quote azure:
```
The firewall rule name cannot be empty, it cannot contain a
slash (/) or a backslash (\), can't end with '.', and can't
contain '<,>,*,%,&,:,\,/,?'. Additionally, the firewall rule
name cannot exceed 128 characters.
```

This fixes that

Signed-off-by: Frank Villaro-Dixon <frank.villarodixon@merkle.com>
  • Loading branch information
Frankkkkk committed Jul 17, 2023
1 parent 9eec73b commit 3f7bc4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/services/synapse/validate/firewall_rule_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func FirewallRuleName(i interface{}, k string) (warnings []string, errors []erro
// 1. can contain only letters, numbers, underscore and hyphen.
// 2. The value must be between 1 and 128 characters long

if !regexp.MustCompile(`^[a-zA-Z\d-_]{1,128}$`).MatchString(v) {
if !regexp.MustCompile(`^[^<>*%&:\\/?]{0,127}[^.<>*%&:\\/?]$`).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))
return
}
Expand Down
5 changes: 5 additions & 0 deletions internal/services/synapse/validate/firewall_rule_name_test.go
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

0 comments on commit 3f7bc4e

Please sign in to comment.