From 5e3bf275da011dfd8fff9acfe69e2fe209cafd89 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Tue, 3 Oct 2023 11:45:07 -0500 Subject: [PATCH] chore: check for valid regex in git auth configs (#10020) --- coderd/workspaceagents.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coderd/workspaceagents.go b/coderd/workspaceagents.go index 9a39f5ac0f..a3b624dc37 100644 --- a/coderd/workspaceagents.go +++ b/coderd/workspaceagents.go @@ -2180,6 +2180,9 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) var externalAuthConfig *externalauth.Config for _, gitAuth := range api.ExternalAuthConfigs { + if gitAuth.Regex == nil { + continue + } matches := gitAuth.Regex.MatchString(gitURL) if !matches { continue @@ -2191,6 +2194,9 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request) if len(api.ExternalAuthConfigs) > 0 { regexURLs := make([]string, 0, len(api.ExternalAuthConfigs)) for _, extAuth := range api.ExternalAuthConfigs { + if extAuth.Regex == nil { + continue + } regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", extAuth.ID, extAuth.Regex.String())) } detail = fmt.Sprintf("The configured external auth provider have regex filters that do not match the git url. Provider url regexs: %s", strings.Join(regexURLs, ","))