diff --git a/CHANGELOG.md b/CHANGELOG.md index 80bab086d..e5efe87f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - if the language server listener is shut down, set initialized to false - log error stream of language server to idea.log - show error / warn messages if the project is null (e.g. for offline handling) +- add no_proxy environment variable, if proxy exceptions are defined ## [2.9.1] ### Fixed diff --git a/src/main/kotlin/snyk/common/EnvironmentHelper.kt b/src/main/kotlin/snyk/common/EnvironmentHelper.kt index 1f66c2b28..001bb0b92 100644 --- a/src/main/kotlin/snyk/common/EnvironmentHelper.kt +++ b/src/main/kotlin/snyk/common/EnvironmentHelper.kt @@ -67,6 +67,7 @@ object EnvironmentHelper { } environment["http_proxy"] = "http://$authentication$proxyHost:${proxySettings.PROXY_PORT}" environment["https_proxy"] = "http://$authentication$proxyHost:${proxySettings.PROXY_PORT}" + environment["no_proxy"] = proxySettings.PROXY_EXCEPTIONS } } diff --git a/src/test/kotlin/io/snyk/plugin/cli/ConsoleCommandRunnerTest.kt b/src/test/kotlin/io/snyk/plugin/cli/ConsoleCommandRunnerTest.kt index f5c28ee82..0c31a3b0c 100644 --- a/src/test/kotlin/io/snyk/plugin/cli/ConsoleCommandRunnerTest.kt +++ b/src/test/kotlin/io/snyk/plugin/cli/ConsoleCommandRunnerTest.kt @@ -2,7 +2,6 @@ package io.snyk.plugin.cli import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.ide.plugins.PluginManagerCore -import com.intellij.openapi.components.service import com.intellij.openapi.extensions.PluginId import com.intellij.openapi.progress.EmptyProgressIndicator import com.intellij.openapi.progress.ProgressIndicator @@ -14,20 +13,15 @@ import com.intellij.testFramework.LightPlatformTestCase import com.intellij.util.net.HttpConfigurable import io.mockk.every import io.mockk.mockkObject -import io.mockk.mockkStatic import io.mockk.unmockkAll import io.mockk.verify import io.sentry.protocol.SentryId import io.snyk.plugin.DEFAULT_TIMEOUT_FOR_SCAN_WAITING_MS -import io.snyk.plugin.getCliFile import io.snyk.plugin.getPluginPath -import io.snyk.plugin.isCliInstalled import io.snyk.plugin.pluginSettings import io.snyk.plugin.removeDummyCliFile import io.snyk.plugin.resetSettings -import io.snyk.plugin.services.download.SnykCliDownloaderService import io.snyk.plugin.setupDummyCliFile -import org.junit.Ignore import snyk.PLUGIN_ID import snyk.errorHandler.SentryErrorReporter import java.net.URLEncoder @@ -161,10 +155,12 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { val originalProxyHost = httpConfigurable.PROXY_HOST val originalProxyPort = httpConfigurable.PROXY_PORT val originalUseProxy = httpConfigurable.USE_HTTP_PROXY + val originalProxyExceptions = httpConfigurable.PROXY_EXCEPTIONS try { httpConfigurable.PROXY_PORT = 3128 httpConfigurable.PROXY_HOST = "testProxy" httpConfigurable.USE_HTTP_PROXY = true + httpConfigurable.PROXY_EXCEPTIONS = "testExceptions" val generalCommandLine = GeneralCommandLine("") val expectedProxy = "http://testProxy:3128" @@ -176,6 +172,7 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { httpConfigurable.USE_HTTP_PROXY = originalUseProxy httpConfigurable.PROXY_HOST = originalProxyHost httpConfigurable.PROXY_PORT = originalProxyPort + httpConfigurable.PROXY_EXCEPTIONS = originalProxyExceptions } } @@ -187,6 +184,7 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { val originalProxyAuthentication = httpConfigurable.PROXY_AUTHENTICATION val originalLogin = httpConfigurable.proxyLogin val originalPassword = httpConfigurable.plainProxyPassword + val originalProxyExceptions = httpConfigurable.PROXY_EXCEPTIONS try { httpConfigurable.PROXY_PORT = 3128 httpConfigurable.PROXY_HOST = "testProxy" @@ -194,6 +192,7 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { httpConfigurable.PROXY_AUTHENTICATION = true httpConfigurable.proxyLogin = "testLogin" httpConfigurable.plainProxyPassword = "test%!@Password" + httpConfigurable.PROXY_EXCEPTIONS = "testExceptions" val encodedLogin = URLEncoder.encode(httpConfigurable.proxyLogin, "UTF-8") val encodedPassword = URLEncoder.encode(httpConfigurable.plainProxyPassword, "UTF-8") @@ -212,6 +211,7 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { httpConfigurable.PROXY_AUTHENTICATION = originalProxyAuthentication httpConfigurable.proxyLogin = originalLogin httpConfigurable.plainProxyPassword = originalPassword + httpConfigurable.PROXY_EXCEPTIONS = originalProxyExceptions } } @@ -224,12 +224,14 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { val originalAuthenticationCancelled = httpConfigurable.AUTHENTICATION_CANCELLED val originalLogin = httpConfigurable.proxyLogin val originalPassword = httpConfigurable.plainProxyPassword + val originalProxyExceptions = httpConfigurable.PROXY_EXCEPTIONS try { httpConfigurable.PROXY_PORT = 3128 httpConfigurable.PROXY_HOST = "testProxy" httpConfigurable.USE_HTTP_PROXY = true httpConfigurable.PROXY_AUTHENTICATION = true httpConfigurable.AUTHENTICATION_CANCELLED = true + httpConfigurable.PROXY_EXCEPTIONS = "testExceptions" val generalCommandLine = GeneralCommandLine("") val expectedProxy = @@ -238,6 +240,7 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { ConsoleCommandRunner().setupCliEnvironmentVariables(generalCommandLine, "") assertEquals(expectedProxy, generalCommandLine.environment["https_proxy"]) + assertEquals(httpConfigurable.PROXY_EXCEPTIONS, generalCommandLine.environment["no_proxy"]) } finally { httpConfigurable.USE_HTTP_PROXY = originalUseProxy httpConfigurable.PROXY_HOST = originalProxyHost @@ -246,6 +249,7 @@ class ConsoleCommandRunnerTest : LightPlatformTestCase() { httpConfigurable.AUTHENTICATION_CANCELLED = originalAuthenticationCancelled httpConfigurable.proxyLogin = originalLogin httpConfigurable.plainProxyPassword = originalPassword + httpConfigurable.PROXY_EXCEPTIONS = originalProxyExceptions } }