Skip to content

Commit

Permalink
fix: SnykToolWindowPanelIntegTest
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Sep 22, 2023
1 parent 7781982 commit 2916b88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import io.snyk.plugin.ui.getDisabledIcon
import io.snyk.plugin.ui.snykCodeAvailabilityPostfix
import io.snyk.plugin.ui.toolwindow.nodes.leaf.SuggestionTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.leaf.VulnerabilityTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.root.*
import io.snyk.plugin.ui.toolwindow.nodes.root.RootContainerIssuesTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.root.RootIacIssuesTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.root.RootOssTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.root.RootQualityIssuesTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.root.RootSecurityIssuesTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.secondlevel.ErrorTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.secondlevel.FileTreeNode
import io.snyk.plugin.ui.toolwindow.nodes.secondlevel.SnykCodeFileTreeNode
Expand Down Expand Up @@ -66,9 +70,13 @@ class SnykTreeCellRenderer : ColoredTreeCellRenderer() {
is FileTreeNode -> {
val fileVulns = value.userObject as OssVulnerabilitiesForFile
nodeIcon = PackageManagerIconProvider.getIcon(fileVulns.packageManager.lowercase(Locale.getDefault()))
toolTipText = GotoFileCellRenderer.getRelativePath(
fileVulns.virtualFile, value.project
) + fileVulns.sanitizedTargetFile + ProductType.OSS.getCountText(value.childCount)
val relativePath = fileVulns.virtualFile?.let {
GotoFileCellRenderer.getRelativePath(
fileVulns.virtualFile, value.project
)
} ?: ""
toolTipText =
relativePath + fileVulns.sanitizedTargetFile + ProductType.OSS.getCountText(value.childCount)

text = toolTipText.letIf(toolTipText.length > MAX_FILE_TREE_NODE_LENGTH) {
"..." + it.substring(
Expand Down Expand Up @@ -126,9 +134,12 @@ class SnykTreeCellRenderer : ColoredTreeCellRenderer() {
nodeIcon = PackageManagerIconProvider.getIcon(
iacVulnerabilitiesForFile.packageManager.lowercase(Locale.getDefault())
)
toolTipText = GotoFileCellRenderer.getRelativePath(
iacVulnerabilitiesForFile.virtualFile, value.project
) + ProductType.IAC.getCountText(value.childCount)
val relativePath = iacVulnerabilitiesForFile.virtualFile?.let {
GotoFileCellRenderer.getRelativePath(
iacVulnerabilitiesForFile.virtualFile, value.project
)
} ?: iacVulnerabilitiesForFile.targetFilePath
toolTipText = relativePath + ProductType.IAC.getCountText(value.childCount)

text = toolTipText.letIf(toolTipText.length > MAX_FILE_TREE_NODE_LENGTH) {
"..." + it.substring(
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/snyk/iac/IacIssuesForFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class IacIssuesForFile(
val ignored: Boolean get() = infrastructureAsCodeIssues.all { it.ignored }
val uniqueCount: Int get() = infrastructureAsCodeIssues.groupBy { it.id }.size

val virtualFile: VirtualFile = LocalFileSystem.getInstance().findFileByPath(this.targetFilePath)!!
val virtualFile: VirtualFile? = LocalFileSystem.getInstance().findFileByPath(this.targetFilePath)
}

/* Real json Example: src/integTest/resources/iac-test-results/infrastructure-as-code-goof.json */

0 comments on commit 2916b88

Please sign in to comment.