diff --git a/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go b/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go index 989dde52e312..f1fa2532646c 100644 --- a/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go +++ b/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go @@ -98,7 +98,9 @@ type SecretInfo struct { func getUserInfo(cfg *config.Config, key string) (UserInfoJSON, error) { var userInfo UserInfoJSON - client := analyzers.NewAnalyzeClient(cfg) + // POST request is considered as non-safe and sourcegraph has graphql APIs. They do not change any state. + // We are using unrestricted client to avoid error for non-safe API request. + client := analyzers.NewAnalyzeClientUnrestricted(cfg) payload := "{\"query\":\"query { currentUser { username, email, siteAdmin, createdAt } }\"}" req, err := http.NewRequest("POST", "https://sourcegraph.com/.api/graphql", strings.NewReader(payload)) if err != nil { @@ -132,7 +134,9 @@ func checkSiteAdmin(cfg *config.Config, key string) (bool, error) { } }` - client := analyzers.NewAnalyzeClient(cfg) + // POST request is considered as non-safe and sourcegraph has graphql APIs. They do not change any state. + // We are using unrestricted client to avoid error for non-safe API request. + client := analyzers.NewAnalyzeClientUnrestricted(cfg) req, err := http.NewRequest("POST", "https://sourcegraph.com/.api/graphql", strings.NewReader(query)) if err != nil { return false, err