MCPcopy
hub / github.com/snyk/cli / createInternalProxy

Function createInternalProxy

cliv2/pkg/basic_workflows/legacycli.go:180–204  ·  view source on GitHub ↗
(config configuration.Configuration, debugLogger *zerolog.Logger, invocation workflow.InvocationContext)

Source from the content-addressed store, hash-verified

178}
179
180func createInternalProxy(config configuration.Configuration, debugLogger *zerolog.Logger, invocation workflow.InvocationContext) (*proxy.WrapperProxy, error) {
181 caData, err := GetGlobalCertAuthority(config, debugLogger)
182 if err != nil {
183 return nil, err
184 }
185
186 wrapperProxy, err := proxy.NewWrapperProxy(config, cliv2.GetFullVersion(), debugLogger, caData)
187 if err != nil {
188 return nil, errors.Wrap(err, "Failed to create proxy!")
189 }
190
191 wrapperProxy.RegisterInterceptor(interceptor.NewV1AnalyticsInterceptor(invocation))
192 wrapperProxy.RegisterInterceptor(interceptor.NewLegacyFeatureFlagInterceptor(invocation))
193 // The networkinjector intercepts all requests from the legacy CLI and re-routes them to the existing networking
194 // layer. It should therefore be kept as the last interceptor in the chain, as it circuit breaks goproxy's own
195 // routing. Any interceptor added later will not be called.
196 wrapperProxy.RegisterInterceptor(interceptor.NewNetworkInjector(invocation))
197
198 err = wrapperProxy.Start()
199 if err != nil {
200 return nil, errors.Wrap(err, "Failed to start the proxy!")
201 }
202
203 return wrapperProxy, nil
204}
205
206// ValidateGlibcVersion checks if the glibc version is supported and returns an Error Catalog error if it is not.
207// This check only applies to glibc-based Linux systems (amd64, arm64).

Callers 2

legacycliWorkflowFunction · 0.85

Calls 3

RegisterInterceptorMethod · 0.95
StartMethod · 0.95
GetGlobalCertAuthorityFunction · 0.85

Tested by 1