From a31ac72cff068816afa6c4b9dc690c3d7ba698a8 Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Wed, 24 Jul 2024 13:21:22 +0200 Subject: [PATCH 1/2] CM-38373 - Disable Sentry for on-premise installations; fix deserialization errors; fix auth check --- CHANGELOG.md | 10 +++++++++- gradle.properties | 2 +- src/main/kotlin/com/cycode/plugin/Consts.kt | 2 ++ .../com/cycode/plugin/cli/models/AuthCheckResult.kt | 2 +- .../kotlin/com/cycode/plugin/sentry/SentryInit.kt | 13 +++++++++++++ .../kotlin/com/cycode/plugin/services/CliService.kt | 8 ++++---- .../com/cycode/plugin/services/CycodeService.kt | 4 ++-- src/main/kotlin/com/cycode/plugin/utils/Plugin.kt | 6 ++++++ 8 files changed, 38 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acb9da2..1a25222 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ## [Unreleased] +## [1.9.4] - 2024-07-24 + +- Disable Sentry for on-premise installations +- Fix deserialization errors +- Fix auth check + ## [1.9.3] - 2024-07-15 - Disable unhandled exceptions logging @@ -101,6 +107,8 @@ The first public release of the plugin. +[1.9.4]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.9.4 + [1.9.3]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.9.3 [1.9.2]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.9.2 @@ -141,4 +149,4 @@ The first public release of the plugin. [1.0.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.0.0 -[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.9.3...HEAD +[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.9.4...HEAD diff --git a/gradle.properties b/gradle.properties index 6bddc82..237b24c 100755 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.cycode.plugin pluginName = Cycode pluginRepositoryUrl = https://github.com/cycodehq/intellij-platform-plugin # SemVer format -> https://semver.org -pluginVersion = 1.9.3 +pluginVersion = 1.9.4 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 211.1 diff --git a/src/main/kotlin/com/cycode/plugin/Consts.kt b/src/main/kotlin/com/cycode/plugin/Consts.kt index f70adc8..5828748 100644 --- a/src/main/kotlin/com/cycode/plugin/Consts.kt +++ b/src/main/kotlin/com/cycode/plugin/Consts.kt @@ -29,6 +29,8 @@ class Consts { val DEFAULT_CLI_PATH = getDefaultCliPath() const val REQUIRED_CLI_VERSION = "1.10.3" + const val CYCODE_DOMAIN = "cycode.com" + const val CLI_GITHUB_ORG = "cycodehq" const val CLI_GITHUB_REPO = "cycode-cli" const val CLI_GITHUB_TAG = "v$REQUIRED_CLI_VERSION" diff --git a/src/main/kotlin/com/cycode/plugin/cli/models/AuthCheckResult.kt b/src/main/kotlin/com/cycode/plugin/cli/models/AuthCheckResult.kt index 02ef237..168c3be 100644 --- a/src/main/kotlin/com/cycode/plugin/cli/models/AuthCheckResult.kt +++ b/src/main/kotlin/com/cycode/plugin/cli/models/AuthCheckResult.kt @@ -3,7 +3,7 @@ package com.cycode.plugin.cli.models data class AuthCheckResult( val result: Boolean, val message: String, - val data: AuthCheckResultData, + val data: AuthCheckResultData? = null, ) data class AuthCheckResultData( diff --git a/src/main/kotlin/com/cycode/plugin/sentry/SentryInit.kt b/src/main/kotlin/com/cycode/plugin/sentry/SentryInit.kt index 8de67a9..e27a16b 100644 --- a/src/main/kotlin/com/cycode/plugin/sentry/SentryInit.kt +++ b/src/main/kotlin/com/cycode/plugin/sentry/SentryInit.kt @@ -1,7 +1,9 @@ package com.cycode.plugin.sentry import com.cycode.plugin.Consts +import com.cycode.plugin.utils.isOnPremiseInstallation import io.sentry.Sentry +import io.sentry.SentryOptions import io.sentry.protocol.User object SentryInit { @@ -14,6 +16,13 @@ object SentryInit { options.release = Consts.SENTRY_RELEASE options.isSendDefaultPii = Consts.SENTRY_SEND_DEFAULT_PII options.serverName = "" + options.beforeSend = SentryOptions.BeforeSendCallback { event, _ -> + if (isSentryDisabled()) { + return@BeforeSendCallback null + } + + event + } } } @@ -26,4 +35,8 @@ object SentryInit { } } } + + private fun isSentryDisabled(): Boolean { + return isOnPremiseInstallation() + } } diff --git a/src/main/kotlin/com/cycode/plugin/services/CliService.kt b/src/main/kotlin/com/cycode/plugin/services/CliService.kt index 6895cea..48051e3 100644 --- a/src/main/kotlin/com/cycode/plugin/services/CliService.kt +++ b/src/main/kotlin/com/cycode/plugin/services/CliService.kt @@ -125,10 +125,10 @@ class CliService(private val project: Project) { showErrorNotification(CycodeBundle.message("checkAuthErrorNotification")) } - SentryInit.setupScope( - processedResult.result.data.userId, - processedResult.result.data.tenantId, - ) + val sentryData = processedResult.result.data + if (sentryData != null) { + SentryInit.setupScope(sentryData.userId, sentryData.tenantId) + } return pluginState.cliAuthed } diff --git a/src/main/kotlin/com/cycode/plugin/services/CycodeService.kt b/src/main/kotlin/com/cycode/plugin/services/CycodeService.kt index 8a99ae7..caecaed 100755 --- a/src/main/kotlin/com/cycode/plugin/services/CycodeService.kt +++ b/src/main/kotlin/com/cycode/plugin/services/CycodeService.kt @@ -46,8 +46,8 @@ class CycodeService(val project: Project) : Disposable { object : Task.Backgroundable(project, CycodeBundle.message("authProcessing"), true) { override fun run(indicator: ProgressIndicator) { if (!pluginState.cliAuthed) { - val successLogin = cliService.doAuth { indicator.isCanceled } - pluginState.cliAuthed = successLogin + cliService.doAuth { indicator.isCanceled } + cliService.checkAuth() updateToolWindowStateForAllProjects() } diff --git a/src/main/kotlin/com/cycode/plugin/utils/Plugin.kt b/src/main/kotlin/com/cycode/plugin/utils/Plugin.kt index ecb447c..9fef262 100644 --- a/src/main/kotlin/com/cycode/plugin/utils/Plugin.kt +++ b/src/main/kotlin/com/cycode/plugin/utils/Plugin.kt @@ -1,8 +1,14 @@ package com.cycode.plugin.utils +import com.cycode.plugin.Consts +import com.cycode.plugin.services.pluginSettings import com.intellij.ide.plugins.PluginManagerCore import com.intellij.openapi.extensions.PluginId fun getPluginVersion(): String { return PluginManagerCore.getPlugin(PluginId.getId("com.cycode.plugin"))?.version ?: "unknown" } + +fun isOnPremiseInstallation(): Boolean { + return !pluginSettings().cliApiUrl.endsWith(Consts.CYCODE_DOMAIN) +} From c2a4fef36d87e63ed3c576c73ade444b94e79e46 Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Thu, 25 Jul 2024 12:28:44 +0200 Subject: [PATCH 2/2] bump cli version; remove beta label from sca --- CHANGELOG.md | 2 +- src/main/kotlin/com/cycode/plugin/Consts.kt | 2 +- src/main/resources/messages/CycodeBundle.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a25222..d096baf 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ## [Unreleased] -## [1.9.4] - 2024-07-24 +## [1.9.4] - 2024-07-25 - Disable Sentry for on-premise installations - Fix deserialization errors diff --git a/src/main/kotlin/com/cycode/plugin/Consts.kt b/src/main/kotlin/com/cycode/plugin/Consts.kt index 5828748..e61b85f 100644 --- a/src/main/kotlin/com/cycode/plugin/Consts.kt +++ b/src/main/kotlin/com/cycode/plugin/Consts.kt @@ -27,7 +27,7 @@ class Consts { companion object { val PLUGIN_PATH = PathManager.getPluginsPath() + "/cycode-intellij-platform-plugin" val DEFAULT_CLI_PATH = getDefaultCliPath() - const val REQUIRED_CLI_VERSION = "1.10.3" + const val REQUIRED_CLI_VERSION = "1.10.7" const val CYCODE_DOMAIN = "cycode.com" diff --git a/src/main/resources/messages/CycodeBundle.properties b/src/main/resources/messages/CycodeBundle.properties index f389d20..23a7259 100755 --- a/src/main/resources/messages/CycodeBundle.properties +++ b/src/main/resources/messages/CycodeBundle.properties @@ -85,7 +85,7 @@ settingsCliAppUrlLabel=APP URL: settingsCliAdditionalParamsLabel=Additional parameters: # scan types display names secretDisplayName=Hardcoded Secrets -scaDisplayName=Open Source Threat (beta) +scaDisplayName=Open Source Threat sastDisplayName=Code Security iacDisplayName=Infrastructure As Code # tree view nodes summaries