Skip to content

Commit

Permalink
CM-40433 - Fix missed markdown blocks on violation cards
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Sep 23, 2024
1 parent 2dd8c5d commit e63b9f4
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## [Unreleased]

- Fix empty IaC scan results on Windows
- Fix missed markdown blocks on violation cards

## [2.0.0] - 2024-08-20

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ data class ScaDetectionDetails(
val vulnerabilityDescription: String?,
val vulnerabilityId: String?,
val alert: ScaDetectionDetailsAlert?,
val description: String?,
val remediationGuidelines: String?,
val customRemediationGuidelines: String?,
val policyDisplayName: String?,
) : ScanDetectionDetailsBase {
override fun getFilepath(): String {
return fileName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IacViolationCardContentTab : CommonViolationCardContentTab() {
headerContentPanel,
summaryPanel,
companyGuidelines,
cycodeGuidelines
cycodeGuidelines,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class IacCompanyGuidelines : CardHtmlSummary() {

fun getContent(detection: IacDetection): JComponent {
return getContent(
CycodeBundle.message("iacViolationCardCompanyGuidelinesTitle"),
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
getCustomGuidelines(detection)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class IacCycodeGuidelines : CardHtmlSummary() {

fun getContent(detection: IacDetection): JComponent {
return getContent(
CycodeBundle.message("iacViolationCardCycodeGuidelinesTitle"),
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
getCycodeGuidelines(detection)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.swing.JComponent

class IacSummary : CardSummary() {
fun getContent(detection: IacDetection): JComponent {
val title = CycodeBundle.message("iacViolationCardSummaryTitle")
val title = CycodeBundle.message("violationCardSummaryTitle")
val message = detection.detectionDetails.description ?: detection.message

return getContent(title, message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.cycode.plugin.components.toolWindow.components.violationCardContentT

import com.cycode.plugin.cli.models.scanResult.sast.SastDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.CommonViolationCardContentTab
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.companyGuidelines.SastCompanyGuidelines
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.cycodeGuidelines.SastCycodeGuidelines
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.header.SastHeader
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.shortSummary.SastShortSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.summary.SastSummary
Expand All @@ -14,13 +16,17 @@ class SastViolationCardContentTab : CommonViolationCardContentTab() {
val shortSummaryPanel = SastShortSummary().getContent(detection)
val headerContentPanel = SastHeader().addContent(detection)
val summaryPanel = SastSummary().getContent(detection)
val companyGuidelines = SastCompanyGuidelines().getContent(detection)
val cycodeGuidelines = SastCycodeGuidelines().getContent(detection)

return getContent(
listOf(
titlePanel,
shortSummaryPanel,
headerContentPanel,
summaryPanel,
companyGuidelines,
cycodeGuidelines,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.companyGuidelines

import com.cycode.plugin.CycodeBundle
import com.cycode.plugin.cli.models.scanResult.sast.SastDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
import javax.swing.JComponent

class SastCompanyGuidelines : CardHtmlSummary() {
private fun getCustomGuidelines(detection: SastDetection): String? {
val descriptionMarkdown = detection.detectionDetails.customRemediationGuidelines ?: return null
return convertMarkdownToHtml(descriptionMarkdown)
}

fun getContent(detection: SastDetection): JComponent {
return getContent(
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
getCustomGuidelines(detection)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.cycodeGuidelines

import com.cycode.plugin.CycodeBundle
import com.cycode.plugin.cli.models.scanResult.sast.SastDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
import javax.swing.JComponent

class SastCycodeGuidelines : CardHtmlSummary() {
private fun getCycodeGuidelines(detection: SastDetection): String? {
val descriptionMarkdown = detection.detectionDetails.remediationGuidelines ?: return null
return convertMarkdownToHtml(descriptionMarkdown)
}

fun getContent(detection: SastDetection): JComponent {
return getContent(
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
getCycodeGuidelines(detection)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class SastSummary : CardHtmlSummary() {
}

fun getContent(detection: SastDetection): JComponent {
return getContent(CycodeBundle.message("sastViolationCardSummaryTitle"), getSummary(detection))
return getContent(CycodeBundle.message("violationCardSummaryTitle"), getSummary(detection))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.cycode.plugin.components.toolWindow.components.violationCardContentT

import com.cycode.plugin.cli.models.scanResult.sca.ScaDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.CommonViolationCardContentTab
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.companyGuidelines.ScaCompanyGuidelines
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.cycodeGuidelines.ScaCycodeGuidelines
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.header.ScaHeader
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.shortSummary.ScaShortSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.summary.ScaSummary
Expand All @@ -13,8 +15,19 @@ class ScaViolationCardContentTab : CommonViolationCardContentTab() {
val titlePanel = ScaTitle().getContent(detection)
val shortSummaryPanel = ScaShortSummary().getContent(detection)
val headerContentPanel = ScaHeader().addContent(detection)
val companyGuidelines = ScaCompanyGuidelines().getContent(detection)
val cycodeGuidelines = ScaCycodeGuidelines().getContent(detection)
val summaryPanel = ScaSummary().getContent(detection)

return getContent(listOf(titlePanel, shortSummaryPanel, headerContentPanel, summaryPanel))
return getContent(
listOf(
titlePanel,
shortSummaryPanel,
headerContentPanel,
summaryPanel,
companyGuidelines,
cycodeGuidelines,
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.companyGuidelines

import com.cycode.plugin.CycodeBundle
import com.cycode.plugin.cli.models.scanResult.sca.ScaDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
import javax.swing.JComponent

class ScaCompanyGuidelines : CardHtmlSummary() {
private fun getCustomGuidelines(detection: ScaDetection): String? {
val descriptionMarkdown = detection.detectionDetails.customRemediationGuidelines ?: return null
return convertMarkdownToHtml(descriptionMarkdown)
}

fun getContent(detection: ScaDetection): JComponent {
return getContent(
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
getCustomGuidelines(detection)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.cycodeGuidelines

import com.cycode.plugin.CycodeBundle
import com.cycode.plugin.cli.models.scanResult.sca.ScaDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
import javax.swing.JComponent

class ScaCycodeGuidelines : CardHtmlSummary() {
private fun getCycodeGuidelines(detection: ScaDetection): String? {
val descriptionMarkdown = detection.detectionDetails.remediationGuidelines ?: return null
return convertMarkdownToHtml(descriptionMarkdown)
}

fun getContent(detection: ScaDetection): JComponent {
return getContent(
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
getCycodeGuidelines(detection)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ScaSummary : CardHtmlSummary() {

fun getContent(detection: ScaDetection): JComponent {
return getContent(
CycodeBundle.message("scaViolationCardSummaryTitle"),
CycodeBundle.message("violationCardSummaryTitle"),
getDescription(detection)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.cycode.plugin.cli.models.scanResult.secret.SecretDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.CommonViolationCardContentTab
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.actions.SecretActions
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.companyGuidelines.SecretCompanyGuidelines
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.cycodeGuidelines.SecretCycodeGuidelines
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.header.SecretHeader
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.shortSummary.SecretShortSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.summary.SecretSummary
Expand All @@ -18,6 +19,7 @@ class SecretViolationCardContentTab(val project: Project) : CommonViolationCardC
val headerContentPanel = SecretHeader().addContent(detection)
val summaryPanel = SecretSummary().getContent(detection)
val companyGuidelines = SecretCompanyGuidelines().getContent(detection)
val cycodeGuidelines = SecretCycodeGuidelines().getContent(detection)
val actionsPanel = SecretActions(project).addContent(detection)

return getContent(
Expand All @@ -27,6 +29,7 @@ class SecretViolationCardContentTab(val project: Project) : CommonViolationCardC
headerContentPanel,
summaryPanel,
companyGuidelines,
cycodeGuidelines,
actionsPanel,
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SecretCompanyGuidelines : CardHtmlSummary() {

fun getContent(detection: SecretDetection): JComponent {
return getContent(
CycodeBundle.message("secretViolationCardCompanyGuidelinesTitle"),
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
getCustomGuidelines(detection)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.cycodeGuidelines

import com.cycode.plugin.CycodeBundle
import com.cycode.plugin.cli.models.scanResult.secret.SecretDetection
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
import javax.swing.JComponent

class SecretCycodeGuidelines : CardHtmlSummary() {
private fun getCycodeGuidelines(detection: SecretDetection): String? {
val descriptionMarkdown = detection.detectionDetails.remediationGuidelines ?: return null
return convertMarkdownToHtml(descriptionMarkdown)
}

fun getContent(detection: SecretDetection): JComponent {
return getContent(
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
getCycodeGuidelines(detection)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import javax.swing.JComponent

class SecretSummary : CardSummary() {
fun getContent(detection: SecretDetection): JComponent {
val title = CycodeBundle.message("secretViolationCardSummaryTitle")
val fixedMessage = detection.message.replace(
"within '' repository", // BE bug
""
)
val message = detection.detectionDetails.description ?: fixedMessage
val title = CycodeBundle.message("violationCardSummaryTitle")
val message = detection.detectionDetails.description ?: detection.getFormattedMessage()

return getContent(title, message)
}
Expand Down
11 changes: 4 additions & 7 deletions src/main/resources/messages/CycodeBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ runOption=Run
rescanOption=Rescan
openInEditorOption=Open in Editor
openViolationCardOption=Open Violation Card
# common violation card
violationCardSummaryTitle=Summary
violationCardCompanyGuidelinesTitle=Company Guidelines
violationCardCycodeGuidelinesTitle=Cycode Guidelines
# sca violation card
scaViolationCardShortSummary=<html>{0} | {1}</html>
scaViolationCardHeaderPackageField=Package:
Expand All @@ -108,30 +112,23 @@ scaViolationCardHeaderPatchedVersionDefaultValue=Not fixed
scaViolationCardHeaderDependencyPathField=Dependency path:
scaViolationCardHeaderLicenseField=License:
scaViolationCardHeaderLicenseDefaultValue=Unknown
scaViolationCardSummaryTitle=Summary
# secret violation card
secretViolationCardTitle=Hardcoded {0} is used
secretViolationCardHeaderRuleIdField=Rule ID:
secretViolationCardHeaderFileField=In file:
secretViolationCardHeaderShaField=Secret SHA:
secretViolationCardSummaryTitle=Summary
secretViolationCardCompanyGuidelinesTitle=Company Guidelines
secretViolationCardIgnoreViolationBtn=Ignore this violation
# iac violation card
iacViolationCardHeaderRuleIdField=Rule ID:
iacViolationCardHeaderFileField=In file:
iacViolationCardHeaderProviderField=IaC Provider:
iacViolationCardSummaryTitle=Summary
iacViolationCardCompanyGuidelinesTitle=Company Guidelines
iacViolationCardCycodeGuidelinesTitle=Cycode Guidelines
# sast violation card
sastViolationCardShortSummary=<html>{0} | {1}</html>
sastViolationCardHeaderRuleIdField=Rule ID:
sastViolationCardHeaderFileField=In file:
sastViolationCardHeaderCategoryField=Subcategory:
sastViolationCardHeaderLanguageField=Language:
sastViolationCardHeaderEngineField=Security Tool:
sastViolationCardSummaryTitle=Summary
# toolbar
toolbarId=CycodeToolbar
toolbarSettingsAction=Cycode Settings
Expand Down

0 comments on commit e63b9f4

Please sign in to comment.