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-32696 - Add detections summary in tree view root nodes #48

Merged
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cycode IntelliJ Platform Plugin (beta)
# Cycode IntelliJ Platform Plugin

<!-- Plugin description -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ class TreeView(
}
}

private fun getDetectionSummary(sortedDetections: List<DetectionBase>): String {
// detections must be sorted by severity
return sortedDetections.groupBy { it.severity }
.map { (severity, detections) -> "$severity - ${detections.size}" }
.joinToString(" | ")
}

private fun createDetectionNodes(
scanType: CliScanType,
scanResults: ScanResultBase,
Expand All @@ -129,13 +136,17 @@ class TreeView(
val sortedDetections = scanResults.detections.sortedByDescending { getSeverityWeight(it.severity) }
val detectionsByFile = sortedDetections.groupBy { it.detectionDetails.getFilepath() }

rootNodes.setNodeSummary(scanType, getDetectionSummary(sortedDetections))

for ((filePath, detections) in detectionsByFile) {
val fileName = File(filePath).name
val summary = CycodeBundle.message("fileNodeSummary", detections.size)

val fileNode = createNode(FileNode(fileName, summary))
for (detection in detections) {
fileNode.add(createNodeCallback(detection))
}

rootNodes.getScanTypeNode(scanType).add(fileNode)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

<extensions defaultExtensionNs="com.intellij">
<postStartupActivity implementation="com.cycode.plugin.activities.PostStartupActivity"/>
<toolWindow factoryClass="com.cycode.plugin.components.toolWindow.CycodeToolWindowFactory" id="Cycode (beta)"
<toolWindow factoryClass="com.cycode.plugin.components.toolWindow.CycodeToolWindowFactory" id="Cycode"
anchor="bottom"/>
<projectConfigurable instance="com.cycode.plugin.settings.ApplicationSettingsConfigurable" groupId="tools"
displayName="Cycode (beta)"/>
displayName="Cycode"/>
<notificationGroup id="Cycode" displayType="BALLOON"/>
</extensions>

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/messages/CycodeBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ scanFileResultNotification=Cycode has detected {0} {1} issues in your file. Chec
scanFileNoResultNotification=No {0} issues were found.
openProblemsTabAction=Open "Cycode" tab
# tool window
toolWindowId=Cycode (beta)
toolWindowId=Cycode
howToUseLabel=<html>To learn more about how to use Cycode in the IDE by JetBrains, please visit <a href="https://github.com/cycodehq/intellij-platform-plugin/blob/main/README.md">our docs</a>.</html>
# auth content tab
authBtn=Authenticate
Expand Down Expand Up @@ -56,12 +56,12 @@ settingsCliAppUrlLabel=APP URL:
settingsCliAdditionalParamsLabel=Additional parameters:
# scan types display names
secretDisplayName=Hardcoded Secrets
scaDisplayName=Open Source Threat
scaDisplayName=Open Source Threat (beta)
sastDisplayName=Code Security
iacDisplayName=Infrastructure As Code
# tree view nodes summaries
fileNodeSummary={0} vulnerabilities
secretNodeSummary=
scaNodeSummary=(beta)
scaNodeSummary=
sastNodeSummary=(coming soon)
iacNodeSummary=(coming soon)
Loading