From 604d78d985c31119ca29487f205a2a7142e565c9 Mon Sep 17 00:00:00 2001 From: Shawn Wang Date: Wed, 18 Oct 2023 15:30:02 -0700 Subject: [PATCH] Fix regex quoting Signed-off-by: Shawn Wang --- nsxt/provider.go | 4 ++-- nsxt/resource_nsxt_node_user.go | 2 +- nsxt/resource_nsxt_policy_role_binding.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nsxt/provider.go b/nsxt/provider.go index 33eec89bf..76a1948a7 100644 --- a/nsxt/provider.go +++ b/nsxt/provider.go @@ -806,8 +806,8 @@ func (processor logRequestProcessor) Process(req *http.Request) error { } // Replace sensitive information in HTTP headers - authHeaderRegexp := regexp.MustCompile("(?i)Authorization:.*") - cspHeaderRegexp := regexp.MustCompile("(?i)Csp-Auth-Token:.*") + authHeaderRegexp := regexp.MustCompile(`(?i)Authorization:.*`) + cspHeaderRegexp := regexp.MustCompile(`(?i)Csp-Auth-Token:.*`) replaced := authHeaderRegexp.ReplaceAllString(string(reqDump), "") replaced = cspHeaderRegexp.ReplaceAllString(replaced, "") diff --git a/nsxt/resource_nsxt_node_user.go b/nsxt/resource_nsxt_node_user.go index 80e41fb7b..dd527b690 100644 --- a/nsxt/resource_nsxt_node_user.go +++ b/nsxt/resource_nsxt_node_user.go @@ -95,7 +95,7 @@ func validateUsername() schema.SchemaValidateFunc { return } - r := regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9@-_.\\-]*$") + r := regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9@-_.\-]*$`) if ok := r.MatchString(v); !ok { es = append(es, fmt.Errorf("username %s is invalid", v)) return diff --git a/nsxt/resource_nsxt_policy_role_binding.go b/nsxt/resource_nsxt_policy_role_binding.go index a14642d80..41837780c 100644 --- a/nsxt/resource_nsxt_policy_role_binding.go +++ b/nsxt/resource_nsxt_policy_role_binding.go @@ -94,7 +94,7 @@ func resourceNsxtPolicyUserManagementRoleBinding() *schema.Resource { Required: true, ValidateFunc: validation.StringMatch( regexp.MustCompile( - "^[_a-z0-9-]+$"), + `^[_a-z0-9-]+$`), "Must be a valid role identifier matching: ^[_a-z0-9-]+$"), }, "role_display_name": {