diff --git a/README.md b/README.md index a699802c..762ef102 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,28 @@ $ go get github.com/snyk/code-client-go Use the HTTP client to make HTTP requests with configured retriable codes and authorisation headers for Snyk Rest APIs. +Implement the `github.com/snyk/code-client-go/http.Config` interface to configure the Snyk Code API client from applications. + +Provide a net/http.Client factory to customize the underlying HTTP protocol behavior (timeouts, etc). + ```go -engine := workflow.NewDefaultWorkFlowEngine() -httpClient := http.NewHTTPClient(engine, engine.GetNetworkAccess().GetHttpClient, codeInstrumentor, codeErrorReporter) +import ( + "net/http" + + "github.com/rs/zerolog" + codehttp "github.com/snyk/code-client-go/http" +) + +logger := zerlog.NewLogger(...) +config := newConfigForMyApp() +httpClient := codehttp.NewHTTPClient(logger, config, func() *http.Client { return http.DefaultClient }, codeInstrumentor, codeErrorReporter) ``` The HTTP client exposes a `DoCall` function. +### Configuration + +Implement the http.Config interface and to configure the Snyk Code API client from applications. ### Snyk Code Client @@ -28,8 +43,7 @@ Use the Snyk Code Client to make calls to the DeepCode API using the `httpClient ```go -engine := workflow.NewDefaultWorkFlowEngine() -snykCode := deepcode.NewSnykCodeClient(engine, httpClient, testutil.NewTestInstrumentor()) +snykCode := deepcode.NewSnykCodeClient(logger, httpClient, testutil.NewTestInstrumentor()) ``` The Snyk Code Client exposes the following functions: @@ -66,4 +80,4 @@ The Code Scanner exposes a `UploadAndAnalyze` function. ### Observability -Under [./observability](./observability) we have defined some observability interfaces which allows consumers of the library to inject their own observability implementations as long as they follow the defined interfaces. \ No newline at end of file +Under [./observability](./observability) we have defined some observability interfaces which allows consumers of the library to inject their own observability implementations as long as they follow the defined interfaces. diff --git a/bundle/bundle_manager.go b/bundle/bundle_manager.go index 777e93dd..a65868cb 100644 --- a/bundle/bundle_manager.go +++ b/bundle/bundle_manager.go @@ -18,12 +18,12 @@ package bundle import ( "context" - "github.com/rs/zerolog" - "github.com/snyk/go-application-framework/pkg/workflow" "os" "path/filepath" "github.com/puzpuzpuz/xsync" + "github.com/rs/zerolog" + "github.com/snyk/code-client-go/deepcode" "github.com/snyk/code-client-go/internal/util" "github.com/snyk/code-client-go/observability" @@ -58,7 +58,7 @@ type BundleManager interface { } func NewBundleManager( - engine workflow.Engine, + logger *zerolog.Logger, SnykCode deepcode.SnykCodeClient, instrumentor observability.Instrumentor, errorReporter observability.ErrorReporter, @@ -67,7 +67,7 @@ func NewBundleManager( SnykCode: SnykCode, instrumentor: instrumentor, errorReporter: errorReporter, - logger: engine.GetLogger(), + logger: logger, supportedExtensions: xsync.NewMapOf[bool](), supportedConfigFiles: xsync.NewMapOf[bool](), } diff --git a/bundle/bundle_manager_test.go b/bundle/bundle_manager_test.go index 3c44cd82..d34f3e66 100644 --- a/bundle/bundle_manager_test.go +++ b/bundle/bundle_manager_test.go @@ -19,14 +19,13 @@ package bundle_test import ( "bytes" "context" - "github.com/rs/zerolog" "os" "path/filepath" "strings" "testing" "github.com/golang/mock/gomock" - "github.com/snyk/go-application-framework/pkg/workflow" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -62,7 +61,7 @@ func Test_Create(t *testing.T) { err := os.WriteFile(file, []byte(data), 0600) require.NoError(t, err) - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) bundle, err := bundleManager.Create(context.Background(), "testHost", "testRequestId", @@ -95,7 +94,7 @@ func Test_Create(t *testing.T) { err := os.WriteFile(file, []byte(data), 0600) require.NoError(t, err) - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) bundle, err := bundleManager.Create(context.Background(), "testHost", "testRequestId", @@ -133,7 +132,7 @@ func Test_Create(t *testing.T) { ) require.NoError(t, err) - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) bundle, err := bundleManager.Create(context.Background(), "testHost", "testRequestId", @@ -170,7 +169,7 @@ func Test_Create(t *testing.T) { }, ) require.NoError(t, err) - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) bundle, err := bundleManager.Create(context.Background(), "testHost", "testRequestId", @@ -204,7 +203,7 @@ func Test_Create(t *testing.T) { err := os.WriteFile(file, []byte("some content so the file won't be skipped"), 0600) assert.Nil(t, err) - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) bundle, err := bundleManager.Create(context.Background(), "testHost", "testRequestId", @@ -253,7 +252,7 @@ func Test_Create(t *testing.T) { require.NoError(t, err) } - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) bundle, err := bundleManager.Create(context.Background(), "testHost", "testRequestId", @@ -286,7 +285,7 @@ func Test_Upload(t *testing.T) { mockInstrumentor.EXPECT().Finish(gomock.Any()).Times(2) mockErrorReporter := mocks.NewMockErrorReporter(ctrl) - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) documentURI, bundleFile := createTempFileInDir(t, "bundleDoc.java", 10, temporaryDir) bundleFileMap := map[string]deepcode2.BundleFile{} bundleFileMap[documentURI] = bundleFile @@ -309,7 +308,7 @@ func Test_Upload(t *testing.T) { mockInstrumentor.EXPECT().StartSpan(gomock.Any(), gomock.Any()).Return(mockSpan).Times(2) mockInstrumentor.EXPECT().Finish(gomock.Any()).Times(2) mockErrorReporter := mocks.NewMockErrorReporter(ctrl) - var bundleManager = bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + var bundleManager = bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) bundleFileMap := map[string]deepcode2.BundleFile{} var missingFiles []string @@ -353,7 +352,7 @@ func Test_IsSupported_Extensions(t *testing.T) { }, nil) mockInstrumentor := mocks.NewMockInstrumentor(ctrl) mockErrorReporter := mocks.NewMockErrorReporter(ctrl) - bundler := bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + bundler := bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) t.Run("should return true for supported languages", func(t *testing.T) { supported, _ := bundler.IsSupported(context.Background(), "testHost", "C:\\some\\path\\Test.java") @@ -392,7 +391,7 @@ func Test_IsSupported_ConfigFiles(t *testing.T) { }, nil) mockInstrumentor := mocks.NewMockInstrumentor(ctrl) mockErrorReporter := mocks.NewMockErrorReporter(ctrl) - bundler := bundle.NewBundleManager(workflow.NewDefaultWorkFlowEngine(), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) + bundler := bundle.NewBundleManager(newLogger(t), mockSnykCodeClient, mockInstrumentor, mockErrorReporter) dir, _ := os.Getwd() t.Run("should return true for supported config files", func(t *testing.T) { @@ -457,3 +456,9 @@ func sliceToChannel(slice []string) <-chan string { return ch } + +func newLogger(t *testing.T) *zerolog.Logger { + t.Helper() + logger := zerolog.New(zerolog.NewTestWriter(t)) + return &logger +} diff --git a/deepcode/client.go b/deepcode/client.go index a437e866..0fc6f86f 100644 --- a/deepcode/client.go +++ b/deepcode/client.go @@ -25,8 +25,6 @@ import ( "strconv" "github.com/rs/zerolog" - "github.com/snyk/go-application-framework/pkg/configuration" - "github.com/snyk/go-application-framework/pkg/workflow" codeClientHTTP "github.com/snyk/code-client-go/http" "github.com/snyk/code-client-go/observability" @@ -71,17 +69,15 @@ type BundleResponse struct { type snykCodeClient struct { httpClient codeClientHTTP.HTTPClient instrumentor observability.Instrumentor - engine workflow.Engine logger *zerolog.Logger } func NewSnykCodeClient( - engine workflow.Engine, + logger *zerolog.Logger, httpClient codeClientHTTP.HTTPClient, instrumentor observability.Instrumentor, ) *snykCodeClient { - logger := engine.GetLogger() - return &snykCodeClient{httpClient, instrumentor, engine, logger} + return &snykCodeClient{httpClient, instrumentor, logger} } func (s *snykCodeClient) GetFilters(ctx context.Context, snykCodeApiUrl string) ( @@ -95,14 +91,12 @@ func (s *snykCodeClient) GetFilters(ctx context.Context, snykCodeApiUrl string) span := s.instrumentor.StartSpan(ctx, method) defer s.instrumentor.Finish(span) - c := s.engine.GetConfiguration() - host, err := s.FormatCodeApiURL(snykCodeApiUrl) if err != nil { return FiltersResponse{ConfigFiles: nil, Extensions: nil}, err } - responseBody, err := s.httpClient.DoCall(span.Context(), c, host, "GET", "/filters", nil) + responseBody, err := s.httpClient.DoCall(span.Context(), host, "GET", "/filters", nil) if err != nil { return FiltersResponse{ConfigFiles: nil, Extensions: nil}, err } @@ -132,14 +126,12 @@ func (s *snykCodeClient) CreateBundle( return "", nil, err } - c := s.engine.GetConfiguration() - host, err := s.FormatCodeApiURL(snykCodeApiUrl) if err != nil { return "", nil, err } - responseBody, err := s.httpClient.DoCall(span.Context(), c, host, "POST", "/bundle", requestBody) + responseBody, err := s.httpClient.DoCall(span.Context(), host, "POST", "/bundle", requestBody) if err != nil { return "", nil, err } @@ -176,14 +168,12 @@ func (s *snykCodeClient) ExtendBundle( return "", nil, err } - c := s.engine.GetConfiguration() - host, err := s.FormatCodeApiURL(snykCodeApiUrl) if err != nil { return "", nil, err } - responseBody, err := s.httpClient.DoCall(span.Context(), c, host, "PUT", "/bundle/"+bundleHash, requestBody) + responseBody, err := s.httpClient.DoCall(span.Context(), host, "PUT", "/bundle/"+bundleHash, requestBody) if err != nil { return "", nil, err } @@ -196,9 +186,7 @@ var codeApiRegex = regexp.MustCompile(`^(deeproxy\.)?`) // This is only exported for tests. func (s *snykCodeClient) FormatCodeApiURL(snykCodeApiUrl string) (string, error) { - config := s.engine.GetConfiguration() - - if !config.GetBool(configuration.IS_FEDRAMP) { + if !s.httpClient.Config().IsFedramp() { return snykCodeApiUrl, nil } u, err := url.Parse(snykCodeApiUrl) @@ -208,7 +196,7 @@ func (s *snykCodeClient) FormatCodeApiURL(snykCodeApiUrl string) (string, error) u.Host = codeApiRegex.ReplaceAllString(u.Host, "api.") - organization := config.GetString(configuration.ORGANIZATION) + organization := s.httpClient.Config().Organization() if organization == "" { return "", errors.New("Organization is required in a fedramp environment") } diff --git a/deepcode/client_pact_test.go b/deepcode/client_pact_test.go index 905ad5d9..193f5111 100644 --- a/deepcode/client_pact_test.go +++ b/deepcode/client_pact_test.go @@ -22,13 +22,13 @@ import ( "net/http" "testing" + "github.com/golang/mock/gomock" "github.com/pact-foundation/pact-go/dsl" - "github.com/snyk/go-application-framework/pkg/configuration" - "github.com/snyk/go-application-framework/pkg/workflow" "github.com/stretchr/testify/assert" "github.com/snyk/code-client-go/deepcode" codeClientHTTP "github.com/snyk/code-client-go/http" + httpmocks "github.com/snyk/code-client-go/http/mocks" "github.com/snyk/code-client-go/internal/util" "github.com/snyk/code-client-go/internal/util/testutil" ) @@ -206,11 +206,10 @@ func TestSnykCodeBackendServicePact(t *testing.T) { func setupPact(t *testing.T) string { t.Helper() - config := configuration.NewInMemory() - config.Set(configuration.ORGANIZATION, orgUUID) - config.Set(configuration.AUTHENTICATION_TOKEN, "00000000-0000-0000-0000-000000000001") - - engine := workflow.NewWorkFlowEngine(config) + ctrl := gomock.NewController(t) + config := httpmocks.NewMockConfig(ctrl) + config.EXPECT().IsFedramp().AnyTimes().Return(false) + config.EXPECT().Organization().AnyTimes().Return(orgUUID) pact = dsl.Pact{ Consumer: consumer, @@ -221,16 +220,13 @@ func setupPact(t *testing.T) string { // Proactively start service to get access to the port pact.Setup(true) snykCodeApiUrl := fmt.Sprintf("http://localhost:%d", pact.Server.Port) - additionalURLs := config.GetStringSlice(configuration.AUTHENTICATION_ADDITIONAL_URLS) - additionalURLs = append(additionalURLs, snykCodeApiUrl) - config.Set(configuration.AUTHENTICATION_ADDITIONAL_URLS, additionalURLs) instrumentor := testutil.NewTestInstrumentor() errorReporter := testutil.NewTestErrorReporter() - httpClient := codeClientHTTP.NewHTTPClient(engine, func() *http.Client { - return engine.GetNetworkAccess().GetHttpClient() + httpClient := codeClientHTTP.NewHTTPClient(newLogger(t), config, func() *http.Client { + return http.DefaultClient }, instrumentor, errorReporter) - client = deepcode.NewSnykCodeClient(engine, httpClient, instrumentor) + client = deepcode.NewSnykCodeClient(newLogger(t), httpClient, instrumentor) return snykCodeApiUrl } @@ -239,7 +235,6 @@ func getPutPostHeaderMatcher() dsl.MapMatcher { return dsl.MapMatcher{ "Content-Type": dsl.String("application/octet-stream"), "Content-Encoding": dsl.String("gzip"), - "Session-Token": dsl.Regex("token fc763eba-0905-41c5-a27f-3934ab26786c", sessionTokenMatcher), "snyk-org-name": dsl.Regex(orgUUID, uuidMatcher), "snyk-request-id": getSnykRequestIdMatcher(), } @@ -264,8 +259,6 @@ func TestSnykCodeBackendServicePact_LocalCodeEngine(t *testing.T) { Headers: dsl.MapMatcher{ "Content-Type": dsl.String("application/json"), "snyk-request-id": getSnykRequestIdMatcher(), - "Session-Token": dsl.Regex("token fc763eba-0905-41c5-a27f-3934ab26786c", sessionTokenMatcher), - "Authorization": dsl.Regex("token fc763eba-0905-41c5-a27f-3934ab26786c", sessionTokenMatcher), }, }).WillRespondWith(dsl.Response{ Status: 200, diff --git a/deepcode/client_test.go b/deepcode/client_test.go index 903a117c..4b9b31e7 100644 --- a/deepcode/client_test.go +++ b/deepcode/client_test.go @@ -22,13 +22,11 @@ import ( "time" "github.com/golang/mock/gomock" - "github.com/google/uuid" - "github.com/snyk/go-application-framework/pkg/configuration" - "github.com/snyk/go-application-framework/pkg/workflow" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "github.com/snyk/code-client-go/deepcode" - mocks2 "github.com/snyk/code-client-go/http/mocks" + httpmocks "github.com/snyk/code-client-go/http/mocks" "github.com/snyk/code-client-go/internal/util" "github.com/snyk/code-client-go/observability/mocks" ) @@ -61,13 +59,18 @@ func TestSnykCodeBackendService_GetFilters(t *testing.T) { mockSpan := mocks.NewMockSpan(ctrl) mockSpan.EXPECT().GetTraceId().AnyTimes() mockSpan.EXPECT().Context().AnyTimes() - mockHTTPClient := mocks2.NewMockHTTPClient(ctrl) - mockHTTPClient.EXPECT().DoCall(gomock.Any(), gomock.Any(), "http://fake-host", "GET", "/filters", gomock.Any()).Return([]byte(`{"configFiles": ["test"], "extensions": ["test"]}`), nil).Times(1) + mockConfig := httpmocks.NewMockConfig(ctrl) + mockConfig.EXPECT().Organization().AnyTimes().Return("") + mockConfig.EXPECT().IsFedramp().AnyTimes().Return(false) + mockHTTPClient := httpmocks.NewMockHTTPClient(ctrl) + mockHTTPClient.EXPECT().Config().AnyTimes().Return(mockConfig) + mockHTTPClient.EXPECT().DoCall(gomock.Any(), "http://fake-host", "GET", "/filters", gomock.Any()).Return([]byte(`{"configFiles": ["test"], "extensions": ["test"]}`), nil).Times(1) + mockInstrumentor := mocks.NewMockInstrumentor(ctrl) mockInstrumentor.EXPECT().StartSpan(gomock.Any(), gomock.Any()).Return(mockSpan).Times(1) mockInstrumentor.EXPECT().Finish(gomock.Any()).Times(1) - s := deepcode.NewSnykCodeClient(workflow.NewDefaultWorkFlowEngine(), mockHTTPClient, mockInstrumentor) + s := deepcode.NewSnykCodeClient(newLogger(t), mockHTTPClient, mockInstrumentor) filters, err := s.GetFilters(context.Background(), "http://fake-host") assert.Nil(t, err) assert.Equal(t, 1, len(filters.ConfigFiles)) @@ -79,13 +82,17 @@ func TestSnykCodeBackendService_CreateBundle(t *testing.T) { mockSpan := mocks.NewMockSpan(ctrl) mockSpan.EXPECT().GetTraceId().AnyTimes() mockSpan.EXPECT().Context().AnyTimes() - mockHTTPClient := mocks2.NewMockHTTPClient(ctrl) - mockHTTPClient.EXPECT().DoCall(gomock.Any(), gomock.Any(), "http://fake-host", "POST", "/bundle", gomock.Any()).Return([]byte(`{"bundleHash": "bundleHash", "missingFiles": ["test"]}`), nil).Times(1) + mockConfig := httpmocks.NewMockConfig(ctrl) + mockConfig.EXPECT().Organization().AnyTimes().Return("") + mockConfig.EXPECT().IsFedramp().AnyTimes().Return(false) + mockHTTPClient := httpmocks.NewMockHTTPClient(ctrl) + mockHTTPClient.EXPECT().Config().AnyTimes().Return(mockConfig) + mockHTTPClient.EXPECT().DoCall(gomock.Any(), "http://fake-host", "POST", "/bundle", gomock.Any()).Return([]byte(`{"bundleHash": "bundleHash", "missingFiles": ["test"]}`), nil).Times(1) mockInstrumentor := mocks.NewMockInstrumentor(ctrl) mockInstrumentor.EXPECT().StartSpan(gomock.Any(), gomock.Any()).Return(mockSpan).Times(1) mockInstrumentor.EXPECT().Finish(gomock.Any()).Times(1) - s := deepcode.NewSnykCodeClient(workflow.NewDefaultWorkFlowEngine(), mockHTTPClient, mockInstrumentor) + s := deepcode.NewSnykCodeClient(newLogger(t), mockHTTPClient, mockInstrumentor) files := map[string]string{} randomAddition := fmt.Sprintf("\n public void random() { System.out.println(\"%d\") }", time.Now().UnixMicro()) files[path1] = util.Hash([]byte(content + randomAddition)) @@ -101,14 +108,18 @@ func TestSnykCodeBackendService_ExtendBundle(t *testing.T) { mockSpan := mocks.NewMockSpan(ctrl) mockSpan.EXPECT().GetTraceId().AnyTimes() mockSpan.EXPECT().Context().AnyTimes() - mockHTTPClient := mocks2.NewMockHTTPClient(ctrl) - mockHTTPClient.EXPECT().DoCall(gomock.Any(), gomock.Any(), "http://fake-host", "POST", "/bundle", gomock.Any()).Return([]byte(`{"bundleHash": "bundleHash", "missingFiles": []}`), nil).Times(1) - mockHTTPClient.EXPECT().DoCall(gomock.Any(), gomock.Any(), "http://fake-host", "PUT", "/bundle/bundleHash", gomock.Any()).Return([]byte(`{"bundleHash": "bundleHash", "missingFiles": []}`), nil).Times(1) + mockConfig := httpmocks.NewMockConfig(ctrl) + mockConfig.EXPECT().Organization().AnyTimes().Return("") + mockConfig.EXPECT().IsFedramp().AnyTimes().Return(false) + mockHTTPClient := httpmocks.NewMockHTTPClient(ctrl) + mockHTTPClient.EXPECT().Config().AnyTimes().Return(mockConfig) + mockHTTPClient.EXPECT().DoCall(gomock.Any(), "http://fake-host", "POST", "/bundle", gomock.Any()).Return([]byte(`{"bundleHash": "bundleHash", "missingFiles": []}`), nil).Times(1) + mockHTTPClient.EXPECT().DoCall(gomock.Any(), "http://fake-host", "PUT", "/bundle/bundleHash", gomock.Any()).Return([]byte(`{"bundleHash": "bundleHash", "missingFiles": []}`), nil).Times(1) mockInstrumentor := mocks.NewMockInstrumentor(ctrl) mockInstrumentor.EXPECT().StartSpan(gomock.Any(), gomock.Any()).Return(mockSpan).Times(2) mockInstrumentor.EXPECT().Finish(gomock.Any()).Times(2) - s := deepcode.NewSnykCodeClient(workflow.NewDefaultWorkFlowEngine(), mockHTTPClient, mockInstrumentor) + s := deepcode.NewSnykCodeClient(newLogger(t), mockHTTPClient, mockInstrumentor) var removedFiles []string files := map[string]string{} files[path1] = util.Hash([]byte(content)) @@ -137,18 +148,17 @@ func createTestExtendMap() map[string]deepcode.BundleFile { func Test_getCodeApiUrl(t *testing.T) { ctrl := gomock.NewController(t) - mockHTTPClient := mocks2.NewMockHTTPClient(ctrl) mockInstrumentor := mocks.NewMockInstrumentor(ctrl) + logger := newLogger(t) t.Run("Changes the URL if FedRAMP", func(t *testing.T) { - engine := workflow.NewDefaultWorkFlowEngine() - config := engine.GetConfiguration() - config.Set(configuration.IS_FEDRAMP, true) - random, _ := uuid.NewRandom() - orgUUID := random.String() - config.Set(configuration.ORGANIZATION, orgUUID) - engine.SetConfiguration(config) - s := deepcode.NewSnykCodeClient(engine, mockHTTPClient, mockInstrumentor) + mockHTTPClient := httpmocks.NewMockHTTPClient(ctrl) + config := httpmocks.NewMockConfig(ctrl) + config.EXPECT().IsFedramp().AnyTimes().Return(true) + config.EXPECT().Organization().AnyTimes().Return(orgUUID) + mockHTTPClient.EXPECT().Config().AnyTimes().Return(config) + + s := deepcode.NewSnykCodeClient(logger, mockHTTPClient, mockInstrumentor) input := "https://snyk.io/api/v1" expected := "https://api.snyk.io/hidden/orgs/" + orgUUID + "/code" @@ -159,11 +169,13 @@ func Test_getCodeApiUrl(t *testing.T) { }) t.Run("Does not change the URL if it's not FedRAMP", func(t *testing.T) { - engine := workflow.NewDefaultWorkFlowEngine() - config := engine.GetConfiguration() - config.Set(configuration.IS_FEDRAMP, false) - engine.SetConfiguration(config) - s := deepcode.NewSnykCodeClient(engine, mockHTTPClient, mockInstrumentor) + mockHTTPClient := httpmocks.NewMockHTTPClient(ctrl) + config := httpmocks.NewMockConfig(ctrl) + config.EXPECT().IsFedramp().AnyTimes().Return(false) + config.EXPECT().Organization().AnyTimes().Return("") + mockHTTPClient.EXPECT().Config().AnyTimes().Return(config) + + s := deepcode.NewSnykCodeClient(logger, mockHTTPClient, mockInstrumentor) input := "https://snyk.io/api/v1" expected := "https://snyk.io/api/v1" @@ -174,3 +186,9 @@ func Test_getCodeApiUrl(t *testing.T) { assert.Contains(t, actual, expected) }) } + +func newLogger(t *testing.T) *zerolog.Logger { + t.Helper() + logger := zerolog.New(zerolog.NewTestWriter(t)) + return &logger +} diff --git a/deepcode/pacts/snykls-snykcodeapi.json b/deepcode/pacts/snykls-snykcodeapi.json index a8550774..a5bfada0 100644 --- a/deepcode/pacts/snykls-snykcodeapi.json +++ b/deepcode/pacts/snykls-snykcodeapi.json @@ -12,20 +12,10 @@ "method": "GET", "path": "/filters", "headers": { - "Authorization": "token fc763eba-0905-41c5-a27f-3934ab26786c", "Content-Type": "application/json", - "Session-Token": "token fc763eba-0905-41c5-a27f-3934ab26786c", "snyk-request-id": "fc763eba-0905-41c5-a27f-3934ab26786c" }, "matchingRules": { - "$.headers.Authorization": { - "match": "regex", - "regex": "^token [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - }, - "$.headers.Session-Token": { - "match": "regex", - "regex": "^token [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" - }, "$.headers.snyk-request-id": { "match": "regex", "regex": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" diff --git a/go.mod b/go.mod index fe9582d6..89263f96 100644 --- a/go.mod +++ b/go.mod @@ -9,54 +9,22 @@ require ( github.com/pkg/errors v0.9.1 github.com/puzpuzpuz/xsync v1.5.2 github.com/rs/zerolog v1.32.0 - github.com/snyk/go-application-framework v0.0.0-20240111143643-fa847b8a9a3b github.com/stretchr/testify v1.8.4 golang.org/x/net v0.22.0 ) require ( - github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/fatih/color v1.16.0 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/jcmturner/aescts/v2 v2.0.0 // indirect - github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect - github.com/jcmturner/gofork v1.7.6 // indirect - github.com/jcmturner/goidentity/v6 v6.0.1 // indirect - github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect - github.com/jcmturner/rpc/v2 v2.0.3 // indirect - github.com/magiconair/properties v1.8.7 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/pelletier/go-toml/v2 v2.1.1 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/sagikazarmark/locafero v0.4.0 // indirect - github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65 // indirect - github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.6.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.18.2 // indirect - github.com/subosito/gotenv v1.6.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.16.0 // indirect - golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.19.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7f9ee4ba..c13ac8cc 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7VVbI0o4wBRNQIgn917usHWOd6VAffYI= -github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -35,6 +33,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -44,13 +43,7 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= -github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= -github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= -github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= @@ -90,10 +83,6 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -101,9 +90,6 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -115,10 +101,6 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= -github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= -github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/graphql-go v1.2.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= @@ -138,16 +120,12 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= -github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -156,18 +134,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hasura/go-graphql-client v0.6.3/go.mod h1:kvaJsDhxGbkIJ1jgebkrnt9EDIELZHpsAMint56v+2I= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= -github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= -github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo= -github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= -github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg= -github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo= -github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o= -github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg= -github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8= -github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs= -github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY= -github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -182,6 +148,7 @@ github.com/klauspost/compress v1.14.2/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -190,8 +157,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= -github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -211,8 +176,6 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4 github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -224,10 +187,7 @@ github.com/pact-foundation/pact-go v1.7.0 h1:5iyVyg+avkWz9Jn7cefRmlPbXu+KMZvWblI github.com/pact-foundation/pact-go v1.7.0/go.mod h1:NcAbRqIE0cjRF+JKl2vcLlzjvrgcZrnq4SwQu2o4PeA= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= -github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -257,66 +217,41 @@ github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= -github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= -github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= -github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/snyk/go-application-framework v0.0.0-20240111143643-fa847b8a9a3b h1:8fFjcaUZpjLV06AtIqtB7QRMYBH/5dxv2CJp319q2Gs= -github.com/snyk/go-application-framework v0.0.0-20240111143643-fa847b8a9a3b/go.mod h1:Yz/qxFyfhf0xbA+z8Vzr5IM9IDG+BS+2PiGaP1yAsEw= -github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65 h1:CEQuYv0Go6MEyRCD3YjLYM2u3Oxkx8GpCpFBd4rUTUk= -github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65/go.mod h1:88KbbvGYlmLgee4OcQ19yr0bNpXpOr2kciOthaSzCAg= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= -github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= -github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= -github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= -github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= -github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -326,16 +261,11 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -350,7 +280,6 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -367,26 +296,19 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -406,25 +328,16 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -450,7 +363,6 @@ golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -466,8 +378,6 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -492,10 +402,6 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -503,8 +409,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/http/config.go b/http/config.go new file mode 100644 index 00000000..ec193ae4 --- /dev/null +++ b/http/config.go @@ -0,0 +1,13 @@ +package http + +// Config defines the configurable options for the HTTP client. +type Config interface { + + // Organization is the Snyk organization in which code SAST is being run. + // Permissions may be granted in the context of an organization. Reports + // are also stored in the context of an owning organization. + Organization() string + + // IsFedramp indicates whether the code SAST is being run in the context of FedRAMP. + IsFedramp() bool +} diff --git a/http/http.go b/http/http.go index 502ba0b2..7d42a917 100644 --- a/http/http.go +++ b/http/http.go @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// Package http defines the HTTP client used to interact with the Snyk Code API. package http import ( @@ -24,8 +26,6 @@ import ( "time" "github.com/rs/zerolog" - "github.com/snyk/go-application-framework/pkg/configuration" - "github.com/snyk/go-application-framework/pkg/workflow" "github.com/snyk/code-client-go/internal/util/encoding" "github.com/snyk/code-client-go/observability" @@ -33,8 +33,8 @@ import ( //go:generate mockgen -destination=mocks/http.go -source=http.go -package mocks type HTTPClient interface { + Config() Config DoCall(ctx context.Context, - config configuration.Configuration, host string, method string, path string, @@ -47,16 +47,17 @@ type httpClient struct { instrumentor observability.Instrumentor errorReporter observability.ErrorReporter logger *zerolog.Logger + config Config } func NewHTTPClient( - engine workflow.Engine, + logger *zerolog.Logger, + config Config, clientFactory func() *http.Client, instrumentor observability.Instrumentor, errorReporter observability.ErrorReporter, ) HTTPClient { - logger := engine.GetLogger() - return &httpClient{clientFactory, instrumentor, errorReporter, logger} + return &httpClient{clientFactory, instrumentor, errorReporter, logger, config} } var retryErrorCodes = map[int]bool{ @@ -66,8 +67,11 @@ var retryErrorCodes = map[int]bool{ http.StatusInternalServerError: true, } +func (s *httpClient) Config() Config { + return s.config +} + func (s *httpClient) DoCall(ctx context.Context, - config configuration.Configuration, host string, method string, path string, @@ -87,7 +91,7 @@ func (s *httpClient) DoCall(ctx context.Context, } var req *http.Request - req, err = s.newRequest(config, host, method, path, bodyBuffer, requestId) + req, err = s.newRequest(host, method, path, bodyBuffer, requestId) if err != nil { return nil, err } @@ -127,7 +131,6 @@ func (s *httpClient) DoCall(ctx context.Context, } func (s *httpClient) newRequest( - config configuration.Configuration, host string, method string, path string, @@ -139,7 +142,7 @@ func (s *httpClient) newRequest( return nil, err } - s.addOrganization(config, req) + s.addOrganization(req) s.addDefaultHeaders(req, requestId, method) return req, nil } @@ -169,9 +172,9 @@ func (s *httpClient) httpCall(req *http.Request) (*http.Response, []byte, error) return response, responseBody, nil } -func (s *httpClient) addOrganization(config configuration.Configuration, req *http.Request) { +func (s *httpClient) addOrganization(req *http.Request) { // Setting a chosen org name for the request - org := config.GetString(configuration.ORGANIZATION) + org := s.config.Organization() if org != "" { req.Header.Set("snyk-org-name", org) } diff --git a/http/http_test.go b/http/http_test.go index 209f99e1..72d15d69 100644 --- a/http/http_test.go +++ b/http/http_test.go @@ -21,11 +21,11 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/snyk/go-application-framework/pkg/configuration" - "github.com/snyk/go-application-framework/pkg/workflow" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" codeClientHTTP "github.com/snyk/code-client-go/http" + httpmocks "github.com/snyk/code-client-go/http/mocks" "github.com/snyk/code-client-go/observability" "github.com/snyk/code-client-go/observability/mocks" ) @@ -60,9 +60,12 @@ func TestSnykCodeBackendService_DoCall_shouldRetry(t *testing.T) { mockInstrumentor.EXPECT().StartSpan(gomock.Any(), gomock.Any()).Return(mockSpan).Times(1) mockInstrumentor.EXPECT().Finish(gomock.Any()).Times(1) mockErrorReporter := mocks.NewMockErrorReporter(ctrl) + config := httpmocks.NewMockConfig(ctrl) + config.EXPECT().IsFedramp().AnyTimes().Return(false) + config.EXPECT().Organization().AnyTimes().Return("") - s := codeClientHTTP.NewHTTPClient(workflow.NewDefaultWorkFlowEngine(), dummyClientFactory, mockInstrumentor, mockErrorReporter) - _, err := s.DoCall(context.Background(), configuration.New(), "", "GET", "https: //httpstat.us/500", nil) + s := codeClientHTTP.NewHTTPClient(newLogger(t), config, dummyClientFactory, mockInstrumentor, mockErrorReporter) + _, err := s.DoCall(context.Background(), "", "GET", "https: //httpstat.us/500", nil) assert.Error(t, err) assert.Equal(t, 3, d.calls) } @@ -80,8 +83,17 @@ func TestSnykCodeBackendService_doCall_rejected(t *testing.T) { mockInstrumentor.EXPECT().Finish(gomock.Any()).Times(1) mockErrorReporter := mocks.NewMockErrorReporter(ctrl) mockErrorReporter.EXPECT().CaptureError(gomock.Any(), observability.ErrorReporterOptions{ErrorDiagnosticPath: ""}) + config := httpmocks.NewMockConfig(ctrl) + config.EXPECT().IsFedramp().AnyTimes().Return(false) + config.EXPECT().Organization().AnyTimes().Return("") - s := codeClientHTTP.NewHTTPClient(workflow.NewDefaultWorkFlowEngine(), dummyClientFactory, mockInstrumentor, mockErrorReporter) - _, err := s.DoCall(context.Background(), configuration.New(), "", "GET", "https://127.0.0.1", nil) + s := codeClientHTTP.NewHTTPClient(newLogger(t), config, dummyClientFactory, mockInstrumentor, mockErrorReporter) + _, err := s.DoCall(context.Background(), "", "GET", "https://127.0.0.1", nil) assert.Error(t, err) } + +func newLogger(t *testing.T) *zerolog.Logger { + t.Helper() + logger := zerolog.New(zerolog.NewTestWriter(t)) + return &logger +} diff --git a/http/mocks/http.go b/http/mocks/http.go index fce8251b..0a7142bb 100644 --- a/http/mocks/http.go +++ b/http/mocks/http.go @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - configuration "github.com/snyk/go-application-framework/pkg/configuration" + http "github.com/snyk/code-client-go/http" ) // MockHTTPClient is a mock of HTTPClient interface. @@ -35,17 +35,82 @@ func (m *MockHTTPClient) EXPECT() *MockHTTPClientMockRecorder { return m.recorder } +// Config mocks base method. +func (m *MockHTTPClient) Config() http.Config { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Config") + ret0, _ := ret[0].(http.Config) + return ret0 +} + +// Config indicates an expected call of Config. +func (mr *MockHTTPClientMockRecorder) Config() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Config", reflect.TypeOf((*MockHTTPClient)(nil).Config)) +} + // DoCall mocks base method. -func (m *MockHTTPClient) DoCall(ctx context.Context, config configuration.Configuration, host, method, path string, requestBody []byte) ([]byte, error) { +func (m *MockHTTPClient) DoCall(ctx context.Context, host, method, path string, requestBody []byte) ([]byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DoCall", ctx, config, host, method, path, requestBody) + ret := m.ctrl.Call(m, "DoCall", ctx, host, method, path, requestBody) ret0, _ := ret[0].([]byte) ret1, _ := ret[1].(error) return ret0, ret1 } // DoCall indicates an expected call of DoCall. -func (mr *MockHTTPClientMockRecorder) DoCall(ctx, config, host, method, path, requestBody interface{}) *gomock.Call { +func (mr *MockHTTPClientMockRecorder) DoCall(ctx, host, method, path, requestBody interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoCall", reflect.TypeOf((*MockHTTPClient)(nil).DoCall), ctx, host, method, path, requestBody) +} + +// MockConfig is a mock of Config interface. +type MockConfig struct { + ctrl *gomock.Controller + recorder *MockConfigMockRecorder +} + +// MockConfigMockRecorder is the mock recorder for MockConfig. +type MockConfigMockRecorder struct { + mock *MockConfig +} + +// NewMockConfig creates a new mock instance. +func NewMockConfig(ctrl *gomock.Controller) *MockConfig { + mock := &MockConfig{ctrl: ctrl} + mock.recorder = &MockConfigMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockConfig) EXPECT() *MockConfigMockRecorder { + return m.recorder +} + +// IsFedramp mocks base method. +func (m *MockConfig) IsFedramp() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsFedramp") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsFedramp indicates an expected call of IsFedramp. +func (mr *MockConfigMockRecorder) IsFedramp() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsFedramp", reflect.TypeOf((*MockConfig)(nil).IsFedramp)) +} + +// Organization mocks base method. +func (m *MockConfig) Organization() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Organization") + ret0, _ := ret[0].(string) + return ret0 +} + +// Organization indicates an expected call of Organization. +func (mr *MockConfigMockRecorder) Organization() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DoCall", reflect.TypeOf((*MockHTTPClient)(nil).DoCall), ctx, config, host, method, path, requestBody) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Organization", reflect.TypeOf((*MockConfig)(nil).Organization)) }