Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use code-client-go to create and extend bundle [IDE-175] #455

Merged
merged 7 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
env:
DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}}
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
SNYK_TOKEN_CONSISTENT_IGNORES: ${{secrets.SNYK_TOKEN_CONSISTENT_IGNORES }}
run: |
export PATH=$PATH:~/pact/bin

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/instance-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
- name: Run Instance Tests
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
SNYK_TOKEN_CONSISTENT_IGNORES: ${{secrets.SNYK_TOKEN_CONSISTENT_IGNORES }}
SNYK_API: ${{ secrets.SNYK_API }}
run: |
make instance-test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
env:
DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}}
SNYK_TOKEN: ${{secrets.SNYK_TOKEN }}
SNYK_TOKEN_CONSISTENT_IGNORES: ${{secrets.SNYK_TOKEN_CONSISTENT_IGNORES }}
INTEG_TESTS: 'true'
SMOKE_TESTS: 'true'
run: |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ proxy-test:

instance-test:
@echo "==> Running instance tests"
@export SMOKE_TESTS=1 && cd application/server && go test -run Test_SmokeWorkspaceScanOssAndCode && cd -
@export SMOKE_TESTS=1 && cd application/server && go test -run Test_SmokeWorkspaceScan && cd -

instance-standard-test:
@echo "==> Running instance tests for the standard environment"
Expand Down
28 changes: 25 additions & 3 deletions application/di/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
"runtime"
"sync"

codeClient "github.com/snyk/code-client-go"
codeClientBundle "github.com/snyk/code-client-go/bundle"
codeClientDeepCode "github.com/snyk/code-client-go/deepcode"
codeClientHTTP "github.com/snyk/code-client-go/http"
codeClientObservability "github.com/snyk/code-client-go/observability"

"github.com/snyk/snyk-ls/infrastructure/cli/cli_constants"
Expand Down Expand Up @@ -75,6 +79,7 @@ var fileWatcher *watcher.FileWatcher
var initMutex = &sync.Mutex{}
var notifier notification.Notifier
var codeInstrumentor codeClientObservability.Instrumentor
var codeErrorReporter codeClientObservability.ErrorReporter

func Init() {
initMutex.Lock()
Expand Down Expand Up @@ -121,8 +126,9 @@ func initInfrastructure() {
})
}

engine := c.Engine()
// init NetworkAccess
networkAccess := c.Engine().GetNetworkAccess()
networkAccess := engine.GetNetworkAccess()

notifier = domainNotify.NewNotifier()
errorReporter = sentry.NewSentryErrorReporter(notifier)
Expand All @@ -140,12 +146,28 @@ func initInfrastructure() {
}

codeInstrumentor = code.NewCodeInstrumentor()
snykCodeClient = code.NewSnykCodeHTTPClient(codeInstrumentor, errorReporter, networkAccess.GetHttpClient)
codeErrorReporter = code.NewCodeErrorReporter(errorReporter)

snykCodeClient = code.NewSnykCodeHTTPClient(codeInstrumentor, codeErrorReporter, networkAccess.GetHttpClient)
snykCodeBundleUploader = code.NewBundler(snykCodeClient, codeInstrumentor)

httpClient := codeClientHTTP.NewHTTPClient(engine.GetLogger(), config.CurrentConfig(),
networkAccess.GetHttpClient, codeInstrumentor,
codeErrorReporter)
snykCode := codeClientDeepCode.NewSnykCodeClient(engine.GetLogger(), httpClient, codeInstrumentor)
bundleManager := codeClientBundle.NewBundleManager(engine.GetLogger(), snykCode, codeInstrumentor, codeErrorReporter)
codeClientScanner := codeClient.NewCodeScanner(
bundleManager,
codeInstrumentor,
codeErrorReporter,
engine.GetLogger(),
)

infrastructureAsCodeScanner = iac.New(instrumentor, errorReporter, analytics, snykCli)
openSourceScanner = oss.NewCLIScanner(instrumentor, errorReporter, analytics, snykCli, learnService, notifier, c)
scanNotifier, _ = appNotification.NewScanNotifier(notifier)
snykCodeScanner = code.New(snykCodeBundleUploader, snykApiClient, errorReporter, analytics, learnService, notifier)
snykCodeScanner = code.New(snykCodeBundleUploader, snykApiClient, codeErrorReporter, analytics, learnService, notifier,
codeClientScanner)
cliInitializer = cli.NewInitializer(errorReporter, installer, notifier, snykCli)
authInitializer := cliauth.NewInitializer(authenticationService, errorReporter, analytics, notifier)
scanInitializer = initialize.NewDelegatingInitializer(
Expand Down
5 changes: 4 additions & 1 deletion application/di/test_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func TestInit(t *testing.T) {
GetLesson(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(&learn.Lesson{}, nil).AnyTimes()
learnService = learnMock
snykCodeScanner = code.New(snykCodeBundleUploader, snykApiClient, errorReporter, analytics, learnService, notifier)
codeClientScanner := &code.FakeCodeScannerClient{}
codeErrorReporter = code.NewCodeErrorReporter(errorReporter)
snykCodeScanner = code.New(snykCodeBundleUploader, snykApiClient, codeErrorReporter, analytics, learnService,
notifier, codeClientScanner)
openSourceScanner = oss.NewCLIScanner(instrumentor, errorReporter, analytics, snykCli, learnService, notifier, c)
infrastructureAsCodeScanner = iac.New(instrumentor, errorReporter, analytics, snykCli)
scanner = snyk.NewDelegatingScanner(
Expand Down
Loading
Loading