MCPcopy
hub / github.com/github/github-mcp-server / checkSubdomainIsolation

Function checkSubdomainIsolation

pkg/utils/api.go:202–221  ·  view source on GitHub ↗

checkSubdomainIsolation detects if GitHub Enterprise Server has subdomain isolation enabled by attempting to ping the raw. /_ping endpoint on the subdomain. The raw subdomain must always exist for subdomain isolation.

(scheme, hostname string)

Source from the content-addressed store, hash-verified

200// checkSubdomainIsolation detects if GitHub Enterprise Server has subdomain isolation enabled
201// by attempting to ping the raw.<host>/_ping endpoint on the subdomain. The raw subdomain must always exist for subdomain isolation.
202func checkSubdomainIsolation(scheme, hostname string) bool {
203 subdomainURL := fmt.Sprintf("%s://raw.%s/_ping", scheme, hostname)
204
205 client := &http.Client{
206 Timeout: 5 * time.Second,
207 // Don't follow redirects - we just want to check if the endpoint exists
208 //nolint:revive // parameters are required by http.Client.CheckRedirect signature
209 CheckRedirect: func(req *http.Request, via []*http.Request) error {
210 return http.ErrUseLastResponse
211 },
212 }
213
214 resp, err := client.Get(subdomainURL)
215 if err != nil {
216 return false
217 }
218 defer resp.Body.Close()
219
220 return resp.StatusCode == http.StatusOK
221}
222
223// Note that this does not handle ports yet, so development environments are out.
224func parseAPIHost(s string) (APIHost, error) {

Callers 1

newGHESHostFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected