From 7b7b0360c26879bb729e2cfddfd5d079f5e2816b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Scha=CC=88fer?= <101886095+PeterSchafer@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:03:44 +0200 Subject: [PATCH 1/7] chore: temporarily enable make debug --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1358cc6c87..11e99c9543 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1241,7 +1241,7 @@ jobs: command: make binary-releases/release.json - run: name: Making release notes - command: make binary-releases/RELEASE_NOTES.md binary-releases/fips/RELEASE_NOTES.md + command: make -d binary-releases/RELEASE_NOTES.md binary-releases/fips/RELEASE_NOTES.md - run: name: Validating artifacts command: ./release-scripts/validate-checksums.sh From 29638f3e299aa8ac2888939fb84e64981b9e63dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Scha=CC=88fer?= <101886095+PeterSchafer@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:37:52 +0200 Subject: [PATCH 2/7] fix: dependencies for RELEASE_NOTES target --- .circleci/config.yml | 2 +- Makefile | 7 ++----- release-scripts/prepare-release.sh | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 11e99c9543..1358cc6c87 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1241,7 +1241,7 @@ jobs: command: make binary-releases/release.json - run: name: Making release notes - command: make -d binary-releases/RELEASE_NOTES.md binary-releases/fips/RELEASE_NOTES.md + command: make binary-releases/RELEASE_NOTES.md binary-releases/fips/RELEASE_NOTES.md - run: name: Validating artifacts command: ./release-scripts/validate-checksums.sh diff --git a/Makefile b/Makefile index 13bf251169..37ba1b5597 100644 --- a/Makefile +++ b/Makefile @@ -89,11 +89,8 @@ $(BINARY_OUTPUT_FOLDER)/sha256sums.txt.asc: $(BINARY_OUTPUT_FOLDER)/release.json: ./release-scripts/release.json.sh -# --commit-path is forwarded to `git log `. -# We're using this to remove CLIv2 changes in v1's changelogs. -# :(exclude) syntax: https://git-scm.com/docs/gitglossary.html#Documentation/gitglossary.txt-exclude -# Release notes uses version from package.json so we need to prepack beforehand. -$(BINARY_OUTPUT_FOLDER)/RELEASE_NOTES.md: $(BINARY_OUTPUT_FOLDER) $(BINARY_OUTPUT_FOLDER)/version +# This target must not have any dependency to support checked in Release Notes that don't get overridden. +$(BINARY_OUTPUT_FOLDER)/RELEASE_NOTES.md: npx conventional-changelog-cli -l -r 1 -n ./release-scripts/conventional-changelog-cli-config.js > $(BINARY_OUTPUT_FOLDER)/RELEASE_NOTES.md $(BINARY_OUTPUT_FOLDER)/fips/RELEASE_NOTES.md: $(BINARY_OUTPUT_FOLDER)/RELEASE_NOTES.md $(BINARY_OUTPUT_FOLDER)/fips diff --git a/release-scripts/prepare-release.sh b/release-scripts/prepare-release.sh index e1487984d4..307cff0bc4 100755 --- a/release-scripts/prepare-release.sh +++ b/release-scripts/prepare-release.sh @@ -22,7 +22,7 @@ if [ -f binary-releases/RELEASE_NOTES.md ]; then fi # Generate the release notes baseline from the commits -make binary-releases/RELEASE_NOTES.md format +make binary-releases binary-releases/version binary-releases/RELEASE_NOTES.md format # if the release notes are generated locally, the version contains something like X.Y.Z-dev.hash # the replacement below ensures that the version in the RELEASE_NOTES.md is X.Y.Z From 24b4952887c4b892b27e2d478a6fe0a37097eb0f Mon Sep 17 00:00:00 2001 From: acke Date: Wed, 19 Jun 2024 09:23:21 +0200 Subject: [PATCH 3/7] fix(langauge-server): only log msg when not succeeding to send event to endpoint --- cliv2/go.mod | 2 +- cliv2/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cliv2/go.mod b/cliv2/go.mod index 57391956f0..89c318cd49 100644 --- a/cliv2/go.mod +++ b/cliv2/go.mod @@ -18,7 +18,7 @@ require ( github.com/snyk/go-application-framework v0.0.0-20240614132431-77ccf7f7ec6b github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65 github.com/snyk/snyk-iac-capture v0.6.5 - github.com/snyk/snyk-ls v0.0.0-20240614150602-18030073ba4f + github.com/snyk/snyk-ls v0.0.0-20240619071554-76f5f6d43b0e github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 diff --git a/cliv2/go.sum b/cliv2/go.sum index 047d205ac7..888ecc2e59 100644 --- a/cliv2/go.sum +++ b/cliv2/go.sum @@ -752,8 +752,8 @@ github.com/snyk/policy-engine v0.30.11 h1:wUy5LMar2vccMbNM62MSBRdjAQAhAbIm7aNXXO github.com/snyk/policy-engine v0.30.11/go.mod h1:O6nwYXbb+SNDrYVWBwkieOwVuwXNKBHuXLm//fLz9Dw= github.com/snyk/snyk-iac-capture v0.6.5 h1:992DXCAJSN97KtUh8T5ndaWwd/6ZCal2bDkRXqM1u/E= github.com/snyk/snyk-iac-capture v0.6.5/go.mod h1:e47i55EmM0F69ZxyFHC4sCi7vyaJW6DLoaamJJCzWGk= -github.com/snyk/snyk-ls v0.0.0-20240614150602-18030073ba4f h1:9dE1XVec9pafU3ZCV1Y03/SXvFx6INLoBgvKLPvFC08= -github.com/snyk/snyk-ls v0.0.0-20240614150602-18030073ba4f/go.mod h1:jLNjt3gzdyUNbhqsd1JDdoCx6t8doWD2av3vWAxcTDA= +github.com/snyk/snyk-ls v0.0.0-20240619071554-76f5f6d43b0e h1:uAbOmBbKwBMy31pvb0x1922OX33n+R8j4P+AGrIxWMY= +github.com/snyk/snyk-ls v0.0.0-20240619071554-76f5f6d43b0e/go.mod h1:jLNjt3gzdyUNbhqsd1JDdoCx6t8doWD2av3vWAxcTDA= 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/sourcegraph/go-lsp v0.0.0-20240223163137-f80c5dd31dfd h1:Dq5WSzWsP1TbVi10zPWBI5LKEBDg4Y1OhWEph1wr5WQ= From 66209646c54c581b35981e508df1d8f1f7ff5ae0 Mon Sep 17 00:00:00 2001 From: mgyorke Date: Thu, 20 Jun 2024 15:46:10 +0000 Subject: [PATCH 4/7] chore: update release notes (#5336) * chore: update release notes * fix: change to release date --- binary-releases/RELEASE_NOTES.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/binary-releases/RELEASE_NOTES.md b/binary-releases/RELEASE_NOTES.md index a93dc0a3fa..22ffbf332a 100644 --- a/binary-releases/RELEASE_NOTES.md +++ b/binary-releases/RELEASE_NOTES.md @@ -2,6 +2,16 @@ The Snyk CLI is being deployed to different deployment channels, users can select the stability level according to their needs. For details please see [this documentation](https://docs.snyk.io/snyk-cli/releases-and-channels-for-the-snyk-cli) +### News + +This Snyk CLI release delivers an assortment of bug fixes and improvements. + +- We've added support for pnpm, giving you more flexibility in your project setup. +- You can now scan npm/yarn projects even without lockfiles, ensuring comprehensive vulnerability detection regardless of your dependency management approach. +- We're committed to strengthening security. This release includes redaction of additional sensitive data in debug logs, minimizing potential risks. + +## Complete changelog + ### Features - **test:** Added pnpm support under 'enablePnpmCli' feature flag ([#5181](https://github.com/snyk/snyk/issues/5181)) ([46769cc](https://github.com/snyk/snyk/commit/46769ccefc0c9ca98a44ad4bdd2b4d8161294dbf)) @@ -13,7 +23,7 @@ The Snyk CLI is being deployed to different deployment channels, users can selec - **language-server:** Add --all-projects flag scans by default [IDE-318](<[#5247](https://github.com/snyk/snyk/issues/5247)>) ([fdcf30e](https://github.com/snyk/snyk/commit/fdcf30e7421b7f8342d11003508f293661264a66)) - **language-server:** Enable incremental scanning [IDE-275](<[#5291](https://github.com/snyk/snyk/issues/5291)>) ([d198685](https://github.com/snyk/snyk/commit/d1986856b152419e1712fa2c35b9b73303c428f9)) - **language-server:** Add support for IDE themes ([c1c4d08](https://github.com/snyk/snyk/commit/c1c4d0805252ee96c7e081edd6b4e42a23cee3b8)) -- **language-server:** Consistent styling acorss intellij and vscode ([#5282](https://github.com/snyk/snyk/issues/5282)) ([9aa6f76](https://github.com/snyk/snyk/commit/9aa6f76201661e8270a92ccc38c75285df435634)) +- **language-server:** Consistent styling across intellij and vscode ([#5282](https://github.com/snyk/snyk/issues/5282)) ([9aa6f76](https://github.com/snyk/snyk/commit/9aa6f76201661e8270a92ccc38c75285df435634)) - **logging:** Redact additional types of sensitive data from debug logs ([#5254](https://github.com/snyk/snyk/issues/5254)) ([056cdab](https://github.com/snyk/snyk/commit/056cdab070102aec927db831090b5bb82df9d31e)) ### Bug Fixes From 99773c3eac6c41c61c9da7fc0f1b991e5298dc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Comb=C3=BCchen?= Date: Thu, 20 Jun 2024 19:22:39 +0200 Subject: [PATCH 5/7] fix: fix issues in JSON output of `sbom test` command (#5331) Include CWE values on `CWE` property. Correct casing of `.semver.vulnerable` property. --- cliv2/go.mod | 2 +- cliv2/go.sum | 4 ++-- test/jest/acceptance/snyk-sbom-test/all-projects.spec.ts | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cliv2/go.mod b/cliv2/go.mod index 57391956f0..b4e406c961 100644 --- a/cliv2/go.mod +++ b/cliv2/go.mod @@ -12,7 +12,7 @@ require ( github.com/rs/zerolog v1.32.0 github.com/snyk/cli-extension-dep-graph v0.0.0-20240426125928-8d56ac52821e github.com/snyk/cli-extension-iac-rules v0.0.0-20240422133948-ae17a4306672 - github.com/snyk/cli-extension-sbom v0.0.0-20240523084359-a2830fadb001 + github.com/snyk/cli-extension-sbom v0.0.0-20240619142341-3b3fe79e862c github.com/snyk/container-cli v0.0.0-20240322120441-6d9b9482f9b1 github.com/snyk/error-catalog-golang-public v0.0.0-20240605115201-8461850930e6 github.com/snyk/go-application-framework v0.0.0-20240614132431-77ccf7f7ec6b diff --git a/cliv2/go.sum b/cliv2/go.sum index 047d205ac7..dd74d6133d 100644 --- a/cliv2/go.sum +++ b/cliv2/go.sum @@ -736,8 +736,8 @@ github.com/snyk/cli-extension-dep-graph v0.0.0-20240426125928-8d56ac52821e h1:j1 github.com/snyk/cli-extension-dep-graph v0.0.0-20240426125928-8d56ac52821e/go.mod h1:QF3v8HBpOpyudYNCuR8LqfULutO76c91sBdLzD+pBJU= github.com/snyk/cli-extension-iac-rules v0.0.0-20240422133948-ae17a4306672 h1:AkLej8Lk//vFex1fiygSYFrQTUd0xP+GyRbsI+m2kwQ= github.com/snyk/cli-extension-iac-rules v0.0.0-20240422133948-ae17a4306672/go.mod h1:2vKTUsW73sVbDcyD19iNLfN0so2GSu9BE3k/fqG0mjA= -github.com/snyk/cli-extension-sbom v0.0.0-20240523084359-a2830fadb001 h1:EP9cL93+Lqw/wP/C80Sx+pyMYrqQY2NiuLDrad0lZ9w= -github.com/snyk/cli-extension-sbom v0.0.0-20240523084359-a2830fadb001/go.mod h1:lqmQT+QdzLdfi7qsqIH4qvCsSWu+P09GDFwQcmFfC0g= +github.com/snyk/cli-extension-sbom v0.0.0-20240619142341-3b3fe79e862c h1:nqFKbstv5PqnRKP4CgW2/Egmbjq6Ej89GzgYFaj+cZ0= +github.com/snyk/cli-extension-sbom v0.0.0-20240619142341-3b3fe79e862c/go.mod h1:lqmQT+QdzLdfi7qsqIH4qvCsSWu+P09GDFwQcmFfC0g= github.com/snyk/code-client-go v1.8.0 h1:6H883KAn7ybiSIxhvL2QR9yEyHgAwA2+9WVHMDNEKa8= github.com/snyk/code-client-go v1.8.0/go.mod h1:orU911flV1kJQOlxxx0InUQkAfpBrcERsb2olfnlI8s= github.com/snyk/container-cli v0.0.0-20240322120441-6d9b9482f9b1 h1:9RKY9NdX5DrJAoVXDP0JiqrXT+4Nb9NH8pjEcA0NsLA= diff --git a/test/jest/acceptance/snyk-sbom-test/all-projects.spec.ts b/test/jest/acceptance/snyk-sbom-test/all-projects.spec.ts index 85dd16e39d..3143a27099 100644 --- a/test/jest/acceptance/snyk-sbom-test/all-projects.spec.ts +++ b/test/jest/acceptance/snyk-sbom-test/all-projects.spec.ts @@ -103,6 +103,8 @@ describe('snyk sbom test (mocked server only)', () => { ); expect(stdout).toContain('"version":"3.0.4",'); expect(stdout).toContain('"name":"minimatch"'); + expect(stdout).toContain('"CWE":["CWE-1333"]'); + expect(stdout).toContain('"semver":{"vulnerable":["3.0.4"]}'); expect(code).toEqual(1); From e5d35b4df9154cf27594c1630b3741fbfb338acd Mon Sep 17 00:00:00 2001 From: PeterSchafer <101886095+PeterSchafer@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:43:52 +0200 Subject: [PATCH 6/7] fix(language-server): Fix race conditions when using internal proxy concurrently (#5332) * fix: Fix race conditions when using internal proxy concurrently * fix: incorrect log message * fix: extend cleanup to remove tmp folders of old processes * fix: fix logic and make pattern more explicit --- cliv2/cmd/cliv2/main.go | 7 ++- cliv2/internal/cliv2/cliv2.go | 69 ++++++++++++++++++++++++++ cliv2/internal/cliv2/cliv2_test.go | 16 ++++-- cliv2/internal/utils/directories.go | 4 +- cliv2/pkg/basic_workflows/legacycli.go | 36 ++++++++++++-- 5 files changed, 122 insertions(+), 10 deletions(-) diff --git a/cliv2/cmd/cliv2/main.go b/cliv2/cmd/cliv2/main.go index 9ef7bee4fa..67eca31c9f 100644 --- a/cliv2/cmd/cliv2/main.go +++ b/cliv2/cmd/cliv2/main.go @@ -447,7 +447,9 @@ func displayError(err error, userInterface ui.UserInterface, config configuratio } uiError := userInterface.OutputError(err) - globalLogger.Err(uiError).Msg("ui failed show error") + if uiError != nil { + globalLogger.Err(uiError).Msg("ui failed to show error") + } } } } @@ -573,6 +575,9 @@ func MainWithErrorCode() int { cliAnalytics.GetInstrumentation().SetStatus(analytics.Failure) } + // cleanup resources in use + basic_workflows.Cleanup() + return exitCode } diff --git a/cliv2/internal/cliv2/cliv2.go b/cliv2/internal/cliv2/cliv2.go index a965acf323..020e9cbddf 100644 --- a/cliv2/internal/cliv2/cliv2.go +++ b/cliv2/internal/cliv2/cliv2.go @@ -13,9 +13,12 @@ import ( "os" "os/exec" "path" + "path/filepath" "regexp" "slices" + "strconv" "strings" + "syscall" "time" "github.com/gofrs/flock" @@ -135,6 +138,16 @@ func (c *CLI) Init() (err error) { } func (c *CLI) ClearCache() error { + err := c.clearVersionFolders() + if err != nil { + return err + } + + err = c.clearTemporaryProcessFolders() + return err +} + +func (c *CLI) clearVersionFolders() error { // Get files in directory fileInfo, err := os.ReadDir(c.CacheDirectory) if err != nil { @@ -163,6 +176,58 @@ func (c *CLI) ClearCache() error { return nil } +func (c *CLI) clearTemporaryProcessFolders() error { + // clean up the tmp dir of the current version + maxConsecutiveDeletes := 5 + deleteCount := 0 + tempDir := filepath.Dir(c.GetTempDir()) + fileInfo, err := os.ReadDir(tempDir) + if err != nil { + return err + } + + // cleanup tmp files related to a non-existing process + processTempPattern := regexp.MustCompile("pid([0-9]*)") + for _, file := range fileInfo { + currentPath := path.Join(tempDir, file.Name()) + matches := processTempPattern.FindStringSubmatch(file.Name()) + if len(matches) == 2 { + processFound := true + pid, localError := strconv.Atoi(matches[1]) + if localError != nil { + continue + } + + p, localError := os.FindProcess(pid) + if localError != nil { + processFound = false + } + + if p != nil { + localError = p.Signal(syscall.Signal(0)) + if localError != nil { + processFound = false + } + } + + if !processFound { + deleteCount++ + err = os.RemoveAll(currentPath) + if err != nil { + c.DebugLogger.Println("Error deleting temporary files: ", currentPath) + } + } + } + + // Stop the loop after 5 deletions to not create too much overhead + if deleteCount == maxConsecutiveDeletes { + break + } + } + + return nil +} + func (c *CLI) AppendEnvironmentVariables(env []string) { c.env = append(c.env, env...) } @@ -210,6 +275,10 @@ func (c *CLI) GetBinaryLocation() string { return c.v1BinaryLocation } +func (c *CLI) GetTempDir() string { + return local_utils.GetTemporaryDirectory(c.CacheDirectory, cliv1.CLIV1Version()) +} + func (c *CLI) printVersion() { _, _ = fmt.Fprintln(c.stdout, GetFullVersion()) } diff --git a/cliv2/internal/cliv2/cliv2_test.go b/cliv2/internal/cliv2/cliv2_test.go index 875263c10c..fd752b882e 100644 --- a/cliv2/internal/cliv2/cliv2_test.go +++ b/cliv2/internal/cliv2/cliv2_test.go @@ -8,6 +8,7 @@ import ( "os" "os/exec" "path" + "path/filepath" "runtime" "sort" "testing" @@ -410,11 +411,16 @@ func Test_clearCache(t *testing.T) { lockfile := path.Join(cli.CacheDirectory, "v1.914.0.lock") randomFile := path.Join(versionNoV, "filename") currentVersion := cli.GetBinaryLocation() + tempDir := filepath.Dir(cli.GetTempDir()) + oldProcessTempDir := path.Join(tempDir, "pid123") + oldProcessTempDirFile := path.Join(oldProcessTempDir, "bla.txt") - _ = os.Mkdir(versionWithV, 0755) - _ = os.Mkdir(versionNoV, 0755) - _ = os.WriteFile(randomFile, []byte("Writing some strings"), 0666) - _ = os.WriteFile(lockfile, []byte("Writing some strings"), 0666) + assert.NoError(t, os.Mkdir(versionWithV, 0755)) + assert.NoError(t, os.Mkdir(versionNoV, 0755)) + assert.NoError(t, os.Mkdir(oldProcessTempDir, 0755)) + assert.NoError(t, os.WriteFile(randomFile, []byte("Writing some strings"), 0666)) + assert.NoError(t, os.WriteFile(lockfile, []byte("Writing some strings"), 0666)) + assert.NoError(t, os.WriteFile(oldProcessTempDirFile, []byte("Writing some strings"), 0666)) // clear cache err := cli.ClearCache() @@ -424,9 +430,11 @@ func Test_clearCache(t *testing.T) { assert.NoDirExists(t, versionWithV) assert.NoDirExists(t, versionNoV) assert.NoFileExists(t, randomFile) + assert.NoFileExists(t, oldProcessTempDirFile) // check if directories that need to exist still exist assert.FileExists(t, currentVersion) assert.FileExists(t, lockfile) + assert.DirExists(t, cli.GetTempDir()) } func Test_clearCacheBigCache(t *testing.T) { diff --git a/cliv2/internal/utils/directories.go b/cliv2/internal/utils/directories.go index 6764d20735..bc6a5a598c 100644 --- a/cliv2/internal/utils/directories.go +++ b/cliv2/internal/utils/directories.go @@ -1,6 +1,7 @@ package utils import ( + "fmt" "os" "path" @@ -15,7 +16,8 @@ const CACHEDIR_PERMISSION = 0755 // |- Temp directory (example: /Users/username/Library/Caches/snyk/snyk-cli/1.1075.0/tmp/) func GetTemporaryDirectory(baseCacheDirectory string, versionNumber string) string { - return path.Join(GetVersionCacheDirectory(baseCacheDirectory, versionNumber), "tmp") + pid := os.Getpid() + return path.Join(GetVersionCacheDirectory(baseCacheDirectory, versionNumber), "tmp", fmt.Sprintf("pid%d", pid)) } func GetVersionCacheDirectory(baseCacheDirectory string, versionNumber string) string { diff --git a/cliv2/pkg/basic_workflows/legacycli.go b/cliv2/pkg/basic_workflows/legacycli.go index 3ed93af28f..dc3b71a440 100644 --- a/cliv2/pkg/basic_workflows/legacycli.go +++ b/cliv2/pkg/basic_workflows/legacycli.go @@ -5,8 +5,10 @@ import ( "bytes" "net/http" "os" + "sync" "github.com/pkg/errors" + "github.com/rs/zerolog" "github.com/snyk/go-application-framework/pkg/auth" "github.com/snyk/go-application-framework/pkg/configuration" "github.com/snyk/go-application-framework/pkg/logging" @@ -23,6 +25,9 @@ import ( var WORKFLOWID_LEGACY_CLI workflow.Identifier = workflow.NewWorkflowIdentifier("legacycli") var DATATYPEID_LEGACY_CLI_STDOUT workflow.Identifier = workflow.NewTypeIdentifier(WORKFLOWID_LEGACY_CLI, "stdout") +var proxySingleton *proxy.WrapperProxy +var proxyMutex sync.Mutex + const ( PROXY_NOAUTH string = "proxy-noauth" ) @@ -132,12 +137,10 @@ func legacycliWorkflow( cli.SetIoStreams(os.Stdin, os.Stdout, scrubbedStderr) } - // init proxy object - wrapperProxy, err := proxy.NewWrapperProxy(config, cliv2.GetFullVersion(), debugLogger) + wrapperProxy, err := getProxyInstance(config, debugLogger) if err != nil { - return output, errors.Wrap(err, "Failed to create proxy!") + return output, err } - defer wrapperProxy.Close() wrapperProxy.SetUpstreamProxyAuthentication(proxyAuthenticationMechanism) @@ -175,3 +178,28 @@ func legacycliWorkflow( return output, err } + +func Cleanup() { + proxyMutex.Lock() + defer proxyMutex.Unlock() + if proxySingleton != nil { + proxySingleton.Close() + proxySingleton = nil + } +} + +func getProxyInstance(config configuration.Configuration, debugLogger *zerolog.Logger) (*proxy.WrapperProxy, error) { + var err error + proxyMutex.Lock() + defer proxyMutex.Unlock() + + if proxySingleton == nil { + // init proxy object + proxySingleton, err = proxy.NewWrapperProxy(config, cliv2.GetFullVersion(), debugLogger) + if err != nil { + return nil, errors.Wrap(err, "Failed to create proxy!") + } + } + + return proxySingleton, nil +} From 8775e83867acaf3ad4dbf6dac23a0e276725dfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Scha=CC=88fer?= <101886095+PeterSchafer@users.noreply.github.com> Date: Mon, 24 Jun 2024 15:37:10 +0200 Subject: [PATCH 7/7] fix: Performance and visualization bugs in experimental native code test --- cliv2/go.mod | 2 +- cliv2/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cliv2/go.mod b/cliv2/go.mod index 89c318cd49..6c600f2573 100644 --- a/cliv2/go.mod +++ b/cliv2/go.mod @@ -15,7 +15,7 @@ require ( github.com/snyk/cli-extension-sbom v0.0.0-20240523084359-a2830fadb001 github.com/snyk/container-cli v0.0.0-20240322120441-6d9b9482f9b1 github.com/snyk/error-catalog-golang-public v0.0.0-20240605115201-8461850930e6 - github.com/snyk/go-application-framework v0.0.0-20240614132431-77ccf7f7ec6b + github.com/snyk/go-application-framework v0.0.0-20240624121329-845d8c3cb5a2 github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65 github.com/snyk/snyk-iac-capture v0.6.5 github.com/snyk/snyk-ls v0.0.0-20240619071554-76f5f6d43b0e diff --git a/cliv2/go.sum b/cliv2/go.sum index 888ecc2e59..7b2fd4dc32 100644 --- a/cliv2/go.sum +++ b/cliv2/go.sum @@ -744,8 +744,8 @@ github.com/snyk/container-cli v0.0.0-20240322120441-6d9b9482f9b1 h1:9RKY9NdX5DrJ github.com/snyk/container-cli v0.0.0-20240322120441-6d9b9482f9b1/go.mod h1:38w+dcAQp9eG3P5t2eNS9eG0reut10AeJjLv5lJ5lpM= github.com/snyk/error-catalog-golang-public v0.0.0-20240605115201-8461850930e6 h1:0t2lDRZY9zn/zgmY9sbRZ4WZFFR+7lIV/4+CMPUhJOs= github.com/snyk/error-catalog-golang-public v0.0.0-20240605115201-8461850930e6/go.mod h1:Ytttq7Pw4vOCu9NtRQaOeDU2dhBYUyNBe6kX4+nIIQ4= -github.com/snyk/go-application-framework v0.0.0-20240614132431-77ccf7f7ec6b h1:dnbbyMpHnd6cAOYfZ2jM5LZ1LU8g8LdQ+6GajWXqWpg= -github.com/snyk/go-application-framework v0.0.0-20240614132431-77ccf7f7ec6b/go.mod h1:v76hiANT35FweRFQEosU5KQ8q27BviioeJkWOh00ghY= +github.com/snyk/go-application-framework v0.0.0-20240624121329-845d8c3cb5a2 h1:i0/X/lV0TFZBRZfrgYmPF+OAIipHjeMlXTVIcFv5A+0= +github.com/snyk/go-application-framework v0.0.0-20240624121329-845d8c3cb5a2/go.mod h1:gz3PN/OfEBbtB4VxbnV33XipM8MjBcVszPJeOhCu2DU= 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/snyk/policy-engine v0.30.11 h1:wUy5LMar2vccMbNM62MSBRdjAQAhAbIm7aNXXO+g2tk=