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

CM-38373 - Disable Sentry for on-premise installations; fix deserialization errors; fix auth check #75

Merged
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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## [Unreleased]

## [1.9.4] - 2024-07-25

- Disable Sentry for on-premise installations
- Fix deserialization errors
- Fix auth check

## [1.9.3] - 2024-07-15

- Disable unhandled exceptions logging
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/com/cycode/plugin/Consts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ 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"

const val CLI_GITHUB_ORG = "cycodehq"
const val CLI_GITHUB_REPO = "cycode-cli"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 13 additions & 0 deletions src/main/kotlin/com/cycode/plugin/sentry/SentryInit.kt
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}
}
}

Expand All @@ -26,4 +35,8 @@ object SentryInit {
}
}
}

private fun isSentryDisabled(): Boolean {
return isOnPremiseInstallation()
}
}
8 changes: 4 additions & 4 deletions src/main/kotlin/com/cycode/plugin/services/CliService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/cycode/plugin/services/CycodeService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/com/cycode/plugin/utils/Plugin.kt
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion src/main/resources/messages/CycodeBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading