Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ij_kotlin_packages_to_use_import_on_demand = ^
ij_kotlin_name_count_to_use_star_import = 999
ij_kotlin_name_count_to_use_star_import_for_members = 999
ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^
ktlint_standard = disabled
ktlint_official = disabled
ktlint_experimental = disabled

[*.java]
ij_java_names_count_to_use_import_on_demand = 999
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,14 @@ class SnykToolWindowPanel(
securityIssuesCount: Int?,
addHMLPostfix: String
) = when {
getSnykCachedResults(project)?.currentSnykCodeError != null -> "$CODE_SECURITY_ROOT_TEXT (error)"
getSnykCachedResults(project)?.currentSnykCodeError != null -> {
val errorMessage = getSnykCachedResults(project)?.currentSnykCodeError?.message
val errorSuffix = when {
errorMessage?.contains("not enabled", ignoreCase = true) == true -> "(disabled at Snyk)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put the whole string or send another param from ls

else -> "(error)"
}
"$CODE_SECURITY_ROOT_TEXT $errorSuffix"
}
isSnykCodeRunning(project) &&
settings.snykCodeSecurityIssuesScanEnable -> "$CODE_SECURITY_ROOT_TEXT (scanning...)"

Expand Down Expand Up @@ -762,6 +769,9 @@ class SnykToolWindowPanel(
@TestOnly
fun getRootOssIssuesTreeNode() = rootOssTreeNode

@TestOnly
fun getRootSecurityIssuesTreeNode() = rootSecurityIssuesTreeNode

fun getTree() = vulnerabilitiesTree

@TestOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ class SnykToolWindowSnykScanListener(

override fun scanningStarted(snykScan: SnykScanParams) {
if (disposed) return
ApplicationManager.getApplication().invokeLater {
this.snykToolWindowPanel.cleanUiAndCaches()
this.snykToolWindowPanel.updateTreeRootNodesPresentation()
this.snykToolWindowPanel.displayScanningMessage()
}

this.snykToolWindowPanel.cleanUiAndCaches()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add TODO to clear cache per product

this.snykToolWindowPanel.updateTreeRootNodesPresentation()
this.snykToolWindowPanel.displayScanningMessage()
}

override fun scanningSnykCodeFinished() {
Expand Down Expand Up @@ -108,25 +107,26 @@ class SnykToolWindowSnykScanListener(
}

override fun scanningError(snykScan: SnykScanParams) {
when (LsProduct.getFor(snykScan.product)) {
LsProduct.OpenSource -> {
removeChildrenAndRefresh(rootOssIssuesTreeNode)
this.rootOssIssuesTreeNode.userObject = "$OSS_ROOT_TEXT (error)"
}
if (disposed) return
ApplicationManager.getApplication().invokeLater {
when (LsProduct.getFor(snykScan.product)) {
LsProduct.OpenSource -> {
removeChildrenAndRefresh(rootOssIssuesTreeNode)
}

LsProduct.Code -> {
removeChildrenAndRefresh(rootSecurityIssuesTreeNode)
rootSecurityIssuesTreeNode.userObject = "$CODE_SECURITY_ROOT_TEXT (error)"
}
LsProduct.Code -> {
removeChildrenAndRefresh(rootSecurityIssuesTreeNode)
}

LsProduct.InfrastructureAsCode -> {
removeChildrenAndRefresh(rootIacIssuesTreeNode)
rootIacIssuesTreeNode.userObject = "$IAC_ROOT_TEXT (error)"
}
LsProduct.InfrastructureAsCode -> {
removeChildrenAndRefresh(rootIacIssuesTreeNode)
}

LsProduct.Unknown -> Unit
LsProduct.Unknown -> Unit
}
snykToolWindowPanel.updateTreeRootNodesPresentation()
refreshAnnotationsForOpenFiles(project)
}
refreshAnnotationsForOpenFiles(project)
}

private fun removeChildrenAndRefresh(node: DefaultMutableTreeNode) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/snyk/common/SnykCachedResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class SnykCachedResults(
}

val errorMessage = snykScan.errorMessage ?: "Scanning error for project ${project.name}. Data: $snykScan"
SnykBalloonNotificationHelper.showError(errorMessage, project)
if (snykScan.showNotification) {
SnykBalloonNotificationHelper.showError(errorMessage, project)
}
}

override fun onPublishDiagnostics(
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/snyk/common/lsp/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data class SnykScanParams(
val issues: List<ScanIssue>, // Issues contain the scan results in the common issues model
val errorMessage: String? = null, // Error Message if applicable
val cliError: CliError? = null, // Structured error information if applicable
val showNotification: Boolean
)

data class SnykScanSummaryParams(
Expand Down
Loading