Skip to content

Commit 5e3bf27

Browse files
authored
chore: check for valid regex in git auth configs (#10020)
1 parent 70a4e56 commit 5e3bf27

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

coderd/workspaceagents.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,9 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
21802180

21812181
var externalAuthConfig *externalauth.Config
21822182
for _, gitAuth := range api.ExternalAuthConfigs {
2183+
if gitAuth.Regex == nil {
2184+
continue
2185+
}
21832186
matches := gitAuth.Regex.MatchString(gitURL)
21842187
if !matches {
21852188
continue
@@ -2191,6 +2194,9 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
21912194
if len(api.ExternalAuthConfigs) > 0 {
21922195
regexURLs := make([]string, 0, len(api.ExternalAuthConfigs))
21932196
for _, extAuth := range api.ExternalAuthConfigs {
2197+
if extAuth.Regex == nil {
2198+
continue
2199+
}
21942200
regexURLs = append(regexURLs, fmt.Sprintf("%s=%q", extAuth.ID, extAuth.Regex.String()))
21952201
}
21962202
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, ","))

0 commit comments

Comments
 (0)