From 9e49298e8ff963ed0632c953beb251da4cd10c63 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Mon, 8 Apr 2024 10:55:19 +0200 Subject: [PATCH 1/8] feat: download CLI version according to supported protocol version [IDE-157] --- .../plugin/services/SnykApplicationSettingsStateService.kt | 4 ++-- .../io/snyk/plugin/services/download/CliDownloaderTest.kt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt index 866ea45cb..5d182c087 100644 --- a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt +++ b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt @@ -27,9 +27,9 @@ import java.util.UUID ) class SnykApplicationSettingsStateService : PersistentStateComponent { - var currentLSProtocolVersion: Int? = 0 - val requiredLsProtocolVersion = 10 + val requiredLsProtocolVersion = 11 + var currentLSProtocolVersion: Int? = 0 var isGlobalIgnoresFeatureEnabled = false var cliBaseDownloadURL: String = "https://static.snyk.io" var cliPath: String = getPluginPath() + separator + Platform.current().snykWrapperFileName diff --git a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderTest.kt b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderTest.kt index 482c9ccee..9d22bb72c 100644 --- a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderTest.kt +++ b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderTest.kt @@ -62,6 +62,7 @@ class CliDownloaderTest { CliDownloader.LATEST_RELEASES_URL ) } + @Test fun `should not delete file if checksum verification fails`() { val testFile = Files.createTempFile("test", "test").toFile() From c297496c361e4f88e646b243c77ffa6a6627330f Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Mon, 8 Apr 2024 14:01:43 +0200 Subject: [PATCH 2/8] fix: tests (wip) --- .../snyk/plugin/services/SnykApplicationSettingsStateService.kt | 2 +- .../plugin/services/download/CliDownloaderServiceIntegTest.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt index 5d182c087..a7cf8aaae 100644 --- a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt +++ b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt @@ -27,7 +27,7 @@ import java.util.UUID ) class SnykApplicationSettingsStateService : PersistentStateComponent { - val requiredLsProtocolVersion = 11 + val requiredLsProtocolVersion = 10 var currentLSProtocolVersion: Int? = 0 var isGlobalIgnoresFeatureEnabled = false diff --git a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt index 65fa2c22c..eaafe9a62 100644 --- a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt +++ b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt @@ -19,7 +19,6 @@ import io.snyk.plugin.removeDummyCliFile import io.snyk.plugin.resetSettings import io.snyk.plugin.services.SnykApplicationSettingsStateService import org.apache.http.HttpStatus -import org.junit.Assert.assertNotEquals import snyk.common.lsp.LanguageServerWrapper import java.io.File import java.net.SocketTimeoutException From 8ff1d400715868c35883f454df065db213d152d1 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Mon, 8 Apr 2024 18:09:46 +0200 Subject: [PATCH 3/8] fix: added forced silent update for mismatched protocol versions --- .../plugin/services/SnykApplicationSettingsStateService.kt | 1 + .../plugin/services/download/CliDownloaderServiceIntegTest.kt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt index a7cf8aaae..2e49778ae 100644 --- a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt +++ b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt @@ -27,6 +27,7 @@ import java.util.UUID ) class SnykApplicationSettingsStateService : PersistentStateComponent { + var currentLSProtocolVersion: Int? = 0 val requiredLsProtocolVersion = 10 var currentLSProtocolVersion: Int? = 0 diff --git a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt index eaafe9a62..80299a730 100644 --- a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt +++ b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt @@ -18,7 +18,10 @@ import io.snyk.plugin.pluginSettings import io.snyk.plugin.removeDummyCliFile import io.snyk.plugin.resetSettings import io.snyk.plugin.services.SnykApplicationSettingsStateService +import junit.framework.TestCase +import junit.framework.TestCase.* import org.apache.http.HttpStatus +import org.junit.Assert.assertNotEquals import snyk.common.lsp.LanguageServerWrapper import java.io.File import java.net.SocketTimeoutException From 6f5faeb7fcd365edf99b9083a29294a9fafabaf6 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Mon, 8 Apr 2024 18:11:13 +0200 Subject: [PATCH 4/8] fix: remove unnecessary suppressions/imports --- .../plugin/services/download/CliDownloaderServiceIntegTest.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt index 80299a730..65fa2c22c 100644 --- a/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt +++ b/src/test/kotlin/io/snyk/plugin/services/download/CliDownloaderServiceIntegTest.kt @@ -18,8 +18,6 @@ import io.snyk.plugin.pluginSettings import io.snyk.plugin.removeDummyCliFile import io.snyk.plugin.resetSettings import io.snyk.plugin.services.SnykApplicationSettingsStateService -import junit.framework.TestCase -import junit.framework.TestCase.* import org.apache.http.HttpStatus import org.junit.Assert.assertNotEquals import snyk.common.lsp.LanguageServerWrapper From 1fec016041ca3384d9b0f66cf2674e90a71f12b8 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Tue, 9 Apr 2024 08:29:44 +0200 Subject: [PATCH 5/8] chore: bump required protocol version, fix small code quality issue --- .../java/ai/deepcode/javaclient/DeepCodeRestApiImpl.java | 6 +++--- .../plugin/services/SnykApplicationSettingsStateService.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ai/deepcode/javaclient/DeepCodeRestApiImpl.java b/src/main/java/ai/deepcode/javaclient/DeepCodeRestApiImpl.java index 33b6d8927..72024de1c 100644 --- a/src/main/java/ai/deepcode/javaclient/DeepCodeRestApiImpl.java +++ b/src/main/java/ai/deepcode/javaclient/DeepCodeRestApiImpl.java @@ -9,6 +9,7 @@ import ai.deepcode.javaclient.responses.CreateBundleResponse; import ai.deepcode.javaclient.responses.GetAnalysisResponse; import ai.deepcode.javaclient.responses.GetFiltersResponse; +import com.intellij.openapi.diagnostic.Logger; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import org.jetbrains.annotations.NotNull; @@ -42,6 +43,7 @@ public class DeepCodeRestApiImpl implements DeepCodeRestApi { public static final String API_URL = "https://deeproxy.snyk.io/"; + public static final @NotNull Logger LOGGER = Logger.getInstance(DeepCodeRestApiImpl.class); private static Retrofit retrofit = buildRetrofit(API_URL, false, false); @@ -79,9 +81,7 @@ private static Retrofit buildRetrofit( SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); builder.sslSocketFactory(sslSocketFactory, x509TrustManager); } catch (NoSuchAlgorithmException | KeyManagementException e) { - // TODO(pavel): extract Retrofit and OkHttpClient into configuration object to simplify API - // client building. - e.printStackTrace(); + LOGGER.warn("Failed to disable SSL verification. Check your JDK", e); } } diff --git a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt index 2e49778ae..8c4f121b8 100644 --- a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt +++ b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt @@ -28,7 +28,7 @@ import java.util.UUID class SnykApplicationSettingsStateService : PersistentStateComponent { var currentLSProtocolVersion: Int? = 0 - val requiredLsProtocolVersion = 10 + val requiredLsProtocolVersion = 11 var currentLSProtocolVersion: Int? = 0 var isGlobalIgnoresFeatureEnabled = false From 135fee734df30c8f677237e46d7a1431539d7b06 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Tue, 9 Apr 2024 08:32:12 +0200 Subject: [PATCH 6/8] docs: update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 492d4eecb..eaf7de52f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## [2.7.14] ### Added - force download of compatible CLI on mismatched LS protocol versions +- bumped LS protocol version to ensure built-in LS in CLI has necessary commands for global ignores ## [2.7.13] ### Added From 419048cc051e2b623201ec9560ebc908cf3f29f4 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Tue, 9 Apr 2024 12:36:22 +0200 Subject: [PATCH 7/8] fix: merge error --- .../snyk/plugin/services/SnykApplicationSettingsStateService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt index 8c4f121b8..5d182c087 100644 --- a/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt +++ b/src/main/kotlin/io/snyk/plugin/services/SnykApplicationSettingsStateService.kt @@ -27,7 +27,6 @@ import java.util.UUID ) class SnykApplicationSettingsStateService : PersistentStateComponent { - var currentLSProtocolVersion: Int? = 0 val requiredLsProtocolVersion = 11 var currentLSProtocolVersion: Int? = 0 From c29dd8128daa830f0eaf46b7e7c9a7abe8282cde Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Tue, 9 Apr 2024 13:42:25 +0200 Subject: [PATCH 8/8] fix: github action warnings, bump versions --- .github/workflows/build.yml | 18 +++++++++--------- .github/workflows/detekt.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e623443c..0c728d05b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 test: name: Test @@ -25,16 +25,16 @@ jobs: steps: - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 name: Setup Java with: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '17' - name: Setup Gradle Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -57,7 +57,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Snyk uses: snyk/actions/setup@0.4.0 @@ -73,18 +73,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 # PluginVerifier has been compiled by a more recent version of the Java - Java 11. # That's why, we are using not version 8 here, but 11. - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 name: Setup Java with: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '17' - name: Setup Gradle Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches diff --git a/.github/workflows/detekt.yml b/.github/workflows/detekt.yml index ac42c3e6f..218385c72 100644 --- a/.github/workflows/detekt.yml +++ b/.github/workflows/detekt.yml @@ -9,16 +9,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 name: Setup Java with: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '17' - name: Setup Gradle Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5e311956..bcb38eee3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,18 +21,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 name: Setup Java with: distribution: 'temurin' # See 'Supported distributions' for available options java-version: '17' - name: Setup Gradle Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches