Skip to content

Commit b313d77

Browse files
authored
CM-40433 - Fix missed markdown blocks on violation cards (#79)
1 parent 2dd8c5d commit b313d77

File tree

20 files changed

+153
-24
lines changed

20 files changed

+153
-24
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
## [Unreleased]
66

7+
## [2.0.1] - 2024-09-25
8+
79
- Fix empty IaC scan results on Windows
10+
- Fix missed markdown blocks on violation cards
811

912
## [2.0.0] - 2024-08-20
1013

@@ -118,6 +121,8 @@
118121

119122
The first public release of the plugin.
120123

124+
[2.0.1]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.0.1
125+
121126
[2.0.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.0.0
122127

123128
[1.9.5]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.9.5
@@ -164,4 +169,4 @@ The first public release of the plugin.
164169

165170
[1.0.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.0.0
166171

167-
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.0.0...HEAD
172+
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.0.1...HEAD

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ pluginGroup = com.cycode.plugin
44
pluginName = Cycode
55
pluginRepositoryUrl = https://github.com/cycodehq/intellij-platform-plugin
66
# SemVer format -> https://semver.org
7-
pluginVersion = 2.0.0
7+
pluginVersion = 2.0.1
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 231
11-
pluginUntilBuild = 242.*
11+
pluginUntilBuild = 243.*
1212

1313
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
1414
platformType = IC

src/main/kotlin/com/cycode/plugin/cli/models/scanResult/sca/ScaDetectionDetails.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ data class ScaDetectionDetails(
1515
val vulnerabilityDescription: String?,
1616
val vulnerabilityId: String?,
1717
val alert: ScaDetectionDetailsAlert?,
18+
val description: String?,
19+
val remediationGuidelines: String?,
20+
val customRemediationGuidelines: String?,
21+
val policyDisplayName: String?,
1822
) : ScanDetectionDetailsBase {
1923
override fun getFilepath(): String {
2024
return fileName

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/iacViolationCardContentTab/IacViolationCardContentTab.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IacViolationCardContentTab : CommonViolationCardContentTab() {
2626
headerContentPanel,
2727
summaryPanel,
2828
companyGuidelines,
29-
cycodeGuidelines
29+
cycodeGuidelines,
3030
)
3131
)
3232
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/iacViolationCardContentTab/components/companyGuidelines/IacCompanyGuidelines.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class IacCompanyGuidelines : CardHtmlSummary() {
1414

1515
fun getContent(detection: IacDetection): JComponent {
1616
return getContent(
17-
CycodeBundle.message("iacViolationCardCompanyGuidelinesTitle"),
17+
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
1818
getCustomGuidelines(detection)
1919
)
2020
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/iacViolationCardContentTab/components/cycodeGuidelines/IacCycodeGuidelines.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class IacCycodeGuidelines : CardHtmlSummary() {
1414

1515
fun getContent(detection: IacDetection): JComponent {
1616
return getContent(
17-
CycodeBundle.message("iacViolationCardCycodeGuidelinesTitle"),
17+
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
1818
getCycodeGuidelines(detection)
1919
)
2020
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/iacViolationCardContentTab/components/summary/IacSummary.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import javax.swing.JComponent
77

88
class IacSummary : CardSummary() {
99
fun getContent(detection: IacDetection): JComponent {
10-
val title = CycodeBundle.message("iacViolationCardSummaryTitle")
10+
val title = CycodeBundle.message("violationCardSummaryTitle")
1111
val message = detection.detectionDetails.description ?: detection.message
1212

1313
return getContent(title, message)

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/sastViolationCardContentTab/SastViolationCardContentTab.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package com.cycode.plugin.components.toolWindow.components.violationCardContentT
22

33
import com.cycode.plugin.cli.models.scanResult.sast.SastDetection
44
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.CommonViolationCardContentTab
5+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.companyGuidelines.SastCompanyGuidelines
6+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.cycodeGuidelines.SastCycodeGuidelines
57
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.header.SastHeader
68
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.shortSummary.SastShortSummary
79
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.summary.SastSummary
@@ -14,13 +16,17 @@ class SastViolationCardContentTab : CommonViolationCardContentTab() {
1416
val shortSummaryPanel = SastShortSummary().getContent(detection)
1517
val headerContentPanel = SastHeader().addContent(detection)
1618
val summaryPanel = SastSummary().getContent(detection)
19+
val companyGuidelines = SastCompanyGuidelines().getContent(detection)
20+
val cycodeGuidelines = SastCycodeGuidelines().getContent(detection)
1721

1822
return getContent(
1923
listOf(
2024
titlePanel,
2125
shortSummaryPanel,
2226
headerContentPanel,
2327
summaryPanel,
28+
companyGuidelines,
29+
cycodeGuidelines,
2430
)
2531
)
2632
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.companyGuidelines
2+
3+
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.models.scanResult.sast.SastDetection
5+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
6+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
7+
import javax.swing.JComponent
8+
9+
class SastCompanyGuidelines : CardHtmlSummary() {
10+
private fun getCustomGuidelines(detection: SastDetection): String? {
11+
val descriptionMarkdown = detection.detectionDetails.customRemediationGuidelines ?: return null
12+
return convertMarkdownToHtml(descriptionMarkdown)
13+
}
14+
15+
fun getContent(detection: SastDetection): JComponent {
16+
return getContent(
17+
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
18+
getCustomGuidelines(detection)
19+
)
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.sastViolationCardContentTab.components.cycodeGuidelines
2+
3+
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.models.scanResult.sast.SastDetection
5+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
6+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
7+
import javax.swing.JComponent
8+
9+
class SastCycodeGuidelines : CardHtmlSummary() {
10+
private fun getCycodeGuidelines(detection: SastDetection): String? {
11+
val descriptionMarkdown = detection.detectionDetails.remediationGuidelines ?: return null
12+
return convertMarkdownToHtml(descriptionMarkdown)
13+
}
14+
15+
fun getContent(detection: SastDetection): JComponent {
16+
return getContent(
17+
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
18+
getCycodeGuidelines(detection)
19+
)
20+
}
21+
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/sastViolationCardContentTab/components/summary/SastSummary.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class SastSummary : CardHtmlSummary() {
1212
}
1313

1414
fun getContent(detection: SastDetection): JComponent {
15-
return getContent(CycodeBundle.message("sastViolationCardSummaryTitle"), getSummary(detection))
15+
return getContent(CycodeBundle.message("violationCardSummaryTitle"), getSummary(detection))
1616
}
1717
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/scaViolationCardContentTab/ScaViolationCardContentTab.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package com.cycode.plugin.components.toolWindow.components.violationCardContentT
22

33
import com.cycode.plugin.cli.models.scanResult.sca.ScaDetection
44
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.CommonViolationCardContentTab
5+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.companyGuidelines.ScaCompanyGuidelines
6+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.cycodeGuidelines.ScaCycodeGuidelines
57
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.header.ScaHeader
68
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.shortSummary.ScaShortSummary
79
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.summary.ScaSummary
@@ -13,8 +15,19 @@ class ScaViolationCardContentTab : CommonViolationCardContentTab() {
1315
val titlePanel = ScaTitle().getContent(detection)
1416
val shortSummaryPanel = ScaShortSummary().getContent(detection)
1517
val headerContentPanel = ScaHeader().addContent(detection)
18+
val companyGuidelines = ScaCompanyGuidelines().getContent(detection)
19+
val cycodeGuidelines = ScaCycodeGuidelines().getContent(detection)
1620
val summaryPanel = ScaSummary().getContent(detection)
1721

18-
return getContent(listOf(titlePanel, shortSummaryPanel, headerContentPanel, summaryPanel))
22+
return getContent(
23+
listOf(
24+
titlePanel,
25+
shortSummaryPanel,
26+
headerContentPanel,
27+
summaryPanel,
28+
companyGuidelines,
29+
cycodeGuidelines,
30+
)
31+
)
1932
}
2033
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.companyGuidelines
2+
3+
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.models.scanResult.sca.ScaDetection
5+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
6+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
7+
import javax.swing.JComponent
8+
9+
class ScaCompanyGuidelines : CardHtmlSummary() {
10+
private fun getCustomGuidelines(detection: ScaDetection): String? {
11+
val descriptionMarkdown = detection.detectionDetails.customRemediationGuidelines ?: return null
12+
return convertMarkdownToHtml(descriptionMarkdown)
13+
}
14+
15+
fun getContent(detection: ScaDetection): JComponent {
16+
return getContent(
17+
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
18+
getCustomGuidelines(detection)
19+
)
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.scaViolationCardContentTab.components.cycodeGuidelines
2+
3+
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.models.scanResult.sca.ScaDetection
5+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
6+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
7+
import javax.swing.JComponent
8+
9+
class ScaCycodeGuidelines : CardHtmlSummary() {
10+
private fun getCycodeGuidelines(detection: ScaDetection): String? {
11+
val descriptionMarkdown = detection.detectionDetails.remediationGuidelines ?: return null
12+
return convertMarkdownToHtml(descriptionMarkdown)
13+
}
14+
15+
fun getContent(detection: ScaDetection): JComponent {
16+
return getContent(
17+
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
18+
getCycodeGuidelines(detection)
19+
)
20+
}
21+
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/scaViolationCardContentTab/components/summary/ScaSummary.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ScaSummary : CardHtmlSummary() {
1414

1515
fun getContent(detection: ScaDetection): JComponent {
1616
return getContent(
17-
CycodeBundle.message("scaViolationCardSummaryTitle"),
17+
CycodeBundle.message("violationCardSummaryTitle"),
1818
getDescription(detection)
1919
)
2020
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/secretViolationCardContentTab/SecretViolationCardContentTab.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.cycode.plugin.cli.models.scanResult.secret.SecretDetection
44
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.CommonViolationCardContentTab
55
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.actions.SecretActions
66
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.companyGuidelines.SecretCompanyGuidelines
7+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.cycodeGuidelines.SecretCycodeGuidelines
78
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.header.SecretHeader
89
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.shortSummary.SecretShortSummary
910
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.summary.SecretSummary
@@ -18,6 +19,7 @@ class SecretViolationCardContentTab(val project: Project) : CommonViolationCardC
1819
val headerContentPanel = SecretHeader().addContent(detection)
1920
val summaryPanel = SecretSummary().getContent(detection)
2021
val companyGuidelines = SecretCompanyGuidelines().getContent(detection)
22+
val cycodeGuidelines = SecretCycodeGuidelines().getContent(detection)
2123
val actionsPanel = SecretActions(project).addContent(detection)
2224

2325
return getContent(
@@ -27,6 +29,7 @@ class SecretViolationCardContentTab(val project: Project) : CommonViolationCardC
2729
headerContentPanel,
2830
summaryPanel,
2931
companyGuidelines,
32+
cycodeGuidelines,
3033
actionsPanel,
3134
)
3235
)

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/secretViolationCardContentTab/components/companyGuidelines/SecretCompanyGuidelines.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SecretCompanyGuidelines : CardHtmlSummary() {
1414

1515
fun getContent(detection: SecretDetection): JComponent {
1616
return getContent(
17-
CycodeBundle.message("secretViolationCardCompanyGuidelinesTitle"),
17+
CycodeBundle.message("violationCardCompanyGuidelinesTitle"),
1818
getCustomGuidelines(detection)
1919
)
2020
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.cycode.plugin.components.toolWindow.components.violationCardContentTab.secretViolationCardContentTab.components.cycodeGuidelines
2+
3+
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.models.scanResult.secret.SecretDetection
5+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.common.htmlSummary.CardHtmlSummary
6+
import com.cycode.plugin.components.toolWindow.components.violationCardContentTab.convertMarkdownToHtml
7+
import javax.swing.JComponent
8+
9+
class SecretCycodeGuidelines : CardHtmlSummary() {
10+
private fun getCycodeGuidelines(detection: SecretDetection): String? {
11+
val descriptionMarkdown = detection.detectionDetails.remediationGuidelines ?: return null
12+
return convertMarkdownToHtml(descriptionMarkdown)
13+
}
14+
15+
fun getContent(detection: SecretDetection): JComponent {
16+
return getContent(
17+
CycodeBundle.message("violationCardCycodeGuidelinesTitle"),
18+
getCycodeGuidelines(detection)
19+
)
20+
}
21+
}

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/violationCardContentTab/secretViolationCardContentTab/components/summary/SecretSummary.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ import javax.swing.JComponent
77

88
class SecretSummary : CardSummary() {
99
fun getContent(detection: SecretDetection): JComponent {
10-
val title = CycodeBundle.message("secretViolationCardSummaryTitle")
11-
val fixedMessage = detection.message.replace(
12-
"within '' repository", // BE bug
13-
""
14-
)
15-
val message = detection.detectionDetails.description ?: fixedMessage
10+
val title = CycodeBundle.message("violationCardSummaryTitle")
11+
val message = detection.detectionDetails.description ?: detection.getFormattedMessage()
1612

1713
return getContent(title, message)
1814
}

src/main/resources/messages/CycodeBundle.properties

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ runOption=Run
9999
rescanOption=Rescan
100100
openInEditorOption=Open in Editor
101101
openViolationCardOption=Open Violation Card
102+
# common violation card
103+
violationCardSummaryTitle=Summary
104+
violationCardCompanyGuidelinesTitle=Company Guidelines
105+
violationCardCycodeGuidelinesTitle=Cycode Guidelines
102106
# sca violation card
103107
scaViolationCardShortSummary=<html>{0} | {1}</html>
104108
scaViolationCardHeaderPackageField=Package:
@@ -108,30 +112,23 @@ scaViolationCardHeaderPatchedVersionDefaultValue=Not fixed
108112
scaViolationCardHeaderDependencyPathField=Dependency path:
109113
scaViolationCardHeaderLicenseField=License:
110114
scaViolationCardHeaderLicenseDefaultValue=Unknown
111-
scaViolationCardSummaryTitle=Summary
112115
# secret violation card
113116
secretViolationCardTitle=Hardcoded {0} is used
114117
secretViolationCardHeaderRuleIdField=Rule ID:
115118
secretViolationCardHeaderFileField=In file:
116119
secretViolationCardHeaderShaField=Secret SHA:
117-
secretViolationCardSummaryTitle=Summary
118-
secretViolationCardCompanyGuidelinesTitle=Company Guidelines
119120
secretViolationCardIgnoreViolationBtn=Ignore this violation
120121
# iac violation card
121122
iacViolationCardHeaderRuleIdField=Rule ID:
122123
iacViolationCardHeaderFileField=In file:
123124
iacViolationCardHeaderProviderField=IaC Provider:
124-
iacViolationCardSummaryTitle=Summary
125-
iacViolationCardCompanyGuidelinesTitle=Company Guidelines
126-
iacViolationCardCycodeGuidelinesTitle=Cycode Guidelines
127125
# sast violation card
128126
sastViolationCardShortSummary=<html>{0} | {1}</html>
129127
sastViolationCardHeaderRuleIdField=Rule ID:
130128
sastViolationCardHeaderFileField=In file:
131129
sastViolationCardHeaderCategoryField=Subcategory:
132130
sastViolationCardHeaderLanguageField=Language:
133131
sastViolationCardHeaderEngineField=Security Tool:
134-
sastViolationCardSummaryTitle=Summary
135132
# toolbar
136133
toolbarId=CycodeToolbar
137134
toolbarSettingsAction=Cycode Settings

0 commit comments

Comments
 (0)