Skip to content

Commit f5f8c6f

Browse files
authored
CM-42037 - Add AI remediations for IaC and SAST (#81)
1 parent a4d7848 commit f5f8c6f

File tree

38 files changed

+383
-368
lines changed

38 files changed

+383
-368
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
## [2.2.0] - 2024-12-11
8+
9+
- Add AI remediations for IaC and SAST
10+
- Fix "Path to executable" field applying in the settings
11+
712
## [2.1.0] - 2024-10-07
813

914
- Add sync flow for Secrets and IaC
@@ -125,6 +130,8 @@
125130

126131
The first public release of the plugin.
127132

133+
[2.2.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.2.0
134+
128135
[2.1.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.1.0
129136

130137
[2.0.1]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.0.1
@@ -175,4 +182,4 @@ The first public release of the plugin.
175182

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

178-
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.1.0...HEAD
185+
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.2.0...HEAD

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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.1.0
7+
pluginVersion = 2.2.0
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 231

src/main/kotlin/com/cycode/plugin/Consts.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Consts {
2727
companion object {
2828
val PLUGIN_PATH = PathManager.getPluginsPath() + "/cycode-intellij-platform-plugin"
2929
val DEFAULT_CLI_PATH = getDefaultCliPath()
30-
const val REQUIRED_CLI_VERSION = "1.11.0"
30+
const val REQUIRED_CLI_VERSION = "2.1.0"
3131

3232
const val CYCODE_DOMAIN = "cycode.com"
3333

src/main/kotlin/com/cycode/plugin/cli/CliWrapper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CliOSProcessHandler(commandLine: GeneralCommandLine) : OSProcessHandler(co
2727
}
2828

2929

30-
class CliWrapper(val executablePath: String, val workDirectory: String? = null) {
30+
class CliWrapper(val workDirectory: String? = null) {
3131
val pluginSettings = pluginSettings()
3232

3333
var mapper: ObjectMapper = jacksonObjectMapper()
@@ -42,7 +42,7 @@ class CliWrapper(val executablePath: String, val workDirectory: String? = null)
4242
): CliResult<T> {
4343
val commandLine = GeneralCommandLine()
4444
commandLine.charset = Charset.forName("UTF-8")
45-
commandLine.exePath = executablePath
45+
commandLine.exePath = pluginSettings.cliPath
4646

4747
if (workDirectory != null) {
4848
commandLine.workDirectory = File(workDirectory)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.cycode.plugin.cli.models
2+
3+
data class AiRemediationResult(
4+
val result: Boolean,
5+
val message: String,
6+
val data: AiRemediationResultData? = null,
7+
)
8+
9+
data class AiRemediationResultData(
10+
val remediation: String,
11+
val isFixAvailable: Boolean,
12+
)

src/main/kotlin/com/cycode/plugin/cli/models/AuthCheckResult.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.cycode.plugin.cli.models
2+
3+
data class SupportedModulesStatus(
4+
// TODO(MarshalX): respect enabled/disabled scanning modules
5+
val secretScanning: Boolean,
6+
val scaScanning: Boolean,
7+
val iacScanning: Boolean,
8+
val sastScanning: Boolean,
9+
val aiLargeLanguageModel: Boolean,
10+
)
11+
12+
data class StatusResult(
13+
val program: String,
14+
val version: String,
15+
val isAuthenticated: Boolean,
16+
val userId: String?,
17+
val tenantId: String?,
18+
val supportedModules: SupportedModulesStatus,
19+
)

src/main/kotlin/com/cycode/plugin/cli/models/VersionResult.kt

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cycode.plugin.cli.models.scanResult
22

33
interface DetectionBase {
4+
val id: String
45
val severity: String
56
val detectionDetails: ScanDetectionDetailsBase
67

src/main/kotlin/com/cycode/plugin/cli/models/scanResult/iac/IacDetection.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import com.cycode.plugin.CycodeBundle
44
import com.cycode.plugin.cli.models.scanResult.DetectionBase
55

66
data class IacDetection(
7-
val message: String,
8-
override val detectionDetails: IacDetectionDetails,
7+
override val id: String,
98
override val severity: String,
9+
override val detectionDetails: IacDetectionDetails,
10+
val message: String,
1011
val type: String,
1112
val detectionRuleId: String, // UUID
1213
val detectionTypeId: String, // UUID

src/main/kotlin/com/cycode/plugin/cli/models/scanResult/sast/SastDetection.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import com.cycode.plugin.CycodeBundle
44
import com.cycode.plugin.cli.models.scanResult.DetectionBase
55

66
data class SastDetection(
7-
val message: String,
8-
override val detectionDetails: SastDetectionDetails,
7+
override val id: String,
98
override val severity: String,
9+
override val detectionDetails: SastDetectionDetails,
10+
val message: String,
1011
val type: String,
1112
val detectionRuleId: String, // UUID
1213
val detectionTypeId: String, // UUID

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import com.cycode.plugin.CycodeBundle
44
import com.cycode.plugin.cli.models.scanResult.DetectionBase
55

66
data class ScaDetection(
7-
val message: String,
8-
override val detectionDetails: ScaDetectionDetails,
7+
override val id: String,
98
override val severity: String,
9+
override val detectionDetails: ScaDetectionDetails,
10+
val message: String,
1011
val type: String,
1112
val detectionRuleId: String,
1213
val detectionTypeId: String,

src/main/kotlin/com/cycode/plugin/cli/models/scanResult/secret/SecretDetection.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import com.cycode.plugin.cli.models.scanResult.DetectionBase
66
const val IDE_ENTRY_LINE_NUMBER = 1
77

88
data class SecretDetection(
9-
val message: String,
10-
override val detectionDetails: SecretDetectionDetails,
9+
override val id: String,
1110
override val severity: String,
11+
override val detectionDetails: SecretDetectionDetails,
12+
val message: String,
1213
val type: String,
1314
val detectionRuleId: String, // UUID
1415
val detectionTypeId: String, // UUID

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/authContentTab/AuthContentTab.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,20 @@ class AuthContentTab : Component<CycodeService>() {
1818
return BorderedPanel().apply {
1919
add(JPanel().apply {
2020
layout = GridBagLayout()
21-
add(add(JPanel().apply {
22-
add(createClickableLabel(CycodeBundle.message("cliReqInfoLabel")))
23-
}), GridBagConstraints().apply {
24-
gridy = 0
25-
insets = JBUI.insetsBottom(10)
26-
anchor = GridBagConstraints.NORTHWEST
27-
})
2821
add(JButton(CycodeBundle.message("authBtn")).apply {
2922
addActionListener {
3023
this.setEnabled(false)
3124
service.startAuth()
3225
}
3326
}, GridBagConstraints().apply {
34-
gridy = 1
27+
gridy = 0
3528
insets = JBUI.insetsBottom(10)
3629
fill = GridBagConstraints.HORIZONTAL
3730
})
3831
add(add(JPanel().apply {
3932
add(createClickableLabel(CycodeBundle.message("howToUseLabel")))
4033
}), GridBagConstraints().apply {
41-
gridy = 2
34+
gridy = 1
4235
anchor = GridBagConstraints.NORTHWEST
4336
})
4437
}, BorderLayout.NORTH)

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/cycodeActionToolBar/actions/RunAllAction.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cycode.plugin.components.toolWindow.components.cycodeActionToolBar.actions
22

33
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.CliScanType
45
import com.cycode.plugin.services.cycode
56
import com.cycode.plugin.services.pluginState
67
import com.intellij.icons.AllIcons
@@ -27,10 +28,10 @@ class RunAllAction :
2728
val project = e.project ?: return
2829
val service = cycode(project)
2930

30-
service.startSecretScanForCurrentProject()
31-
service.startScaScanForCurrentProject()
32-
service.startIacScanForCurrentProject()
33-
service.startSastScanForCurrentProject()
31+
service.startScanForCurrentProject(CliScanType.Secret)
32+
service.startScanForCurrentProject(CliScanType.Sca)
33+
service.startScanForCurrentProject(CliScanType.Iac)
34+
service.startScanForCurrentProject(CliScanType.Sast)
3435
}
3536

3637
override fun update(e: AnActionEvent) {

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/scanContentTab/ScanContentTab.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cycode.plugin.components.toolWindow.components.scanContentTab
22

33
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.CliScanType
45
import com.cycode.plugin.components.Component
56
import com.cycode.plugin.components.common.createClickableLabel
67
import com.cycode.plugin.services.CycodeService
@@ -29,22 +30,22 @@ class ScanContentTab : Component<CycodeService>() {
2930
addComponentToPanel(createClickableLabel(CycodeBundle.message("scanTabTitleLabel")))
3031
addComponentToPanel(
3132
JButton(CycodeBundle.message("scanTabSecretsBtn")).apply {
32-
addActionListener { service.startSecretScanForCurrentProject() }
33+
addActionListener { service.startScanForCurrentProject(CliScanType.Secret) }
3334
},
3435
)
3536
addComponentToPanel(
3637
JButton(CycodeBundle.message("scanTabScaBtn")).apply {
37-
addActionListener { service.startScaScanForCurrentProject() }
38+
addActionListener { service.startScanForCurrentProject(CliScanType.Sca) }
3839
},
3940
)
4041
addComponentToPanel(
4142
JButton(CycodeBundle.message("scanTabIacBtn")).apply {
42-
addActionListener { service.startIacScanForCurrentProject() }
43+
addActionListener { service.startScanForCurrentProject(CliScanType.Iac) }
4344
},
4445
)
4546
addComponentToPanel(
4647
JButton(CycodeBundle.message("scanTabSastBtn")).apply {
47-
addActionListener { service.startSastScanForCurrentProject() }
48+
addActionListener { service.startScanForCurrentProject(CliScanType.Sast) }
4849
},
4950
)
5051

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/treeView/TreeView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class TreeView(
123123
val card = when (detection) {
124124
is SecretDetection -> SecretViolationCardContentTab(project).getContent(detection)
125125
is ScaDetection -> ScaViolationCardContentTab().getContent(detection)
126-
is IacDetection -> IacViolationCardContentTab().getContent(detection)
127-
is SastDetection -> SastViolationCardContentTab().getContent(detection)
126+
is IacDetection -> IacViolationCardContentTab(project).getContent(detection)
127+
is SastDetection -> SastViolationCardContentTab(project).getContent(detection)
128128
else -> return
129129
}
130130

src/main/kotlin/com/cycode/plugin/components/toolWindow/components/treeView/components/detectionNodeContextMenu/DetectionNodeContextMenu.kt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cycode.plugin.components.toolWindow.components.treeView.components.detectionNodeContextMenu
22

33
import com.cycode.plugin.CycodeBundle
4+
import com.cycode.plugin.cli.CliScanType
45
import com.cycode.plugin.components.toolWindow.components.treeView.TreeView
56
import com.cycode.plugin.components.toolWindow.components.treeView.nodes.*
67
import com.cycode.plugin.components.toolWindow.components.treeView.openDetectionInFile
@@ -69,33 +70,33 @@ class DetectionNodeContextMenu(
6970

7071
// FIXME(MarshalX): add some key field instead of abusing name?
7172
when (node.name) {
72-
CycodeBundle.message("secretDisplayName") -> service.startSecretScanForCurrentProject()
73-
CycodeBundle.message("scaDisplayName") -> service.startScaScanForCurrentProject()
74-
CycodeBundle.message("iacDisplayName") -> service.startIacScanForCurrentProject()
75-
CycodeBundle.message("sastDisplayName") -> service.startSastScanForCurrentProject()
73+
CycodeBundle.message("secretDisplayName") -> service.startScanForCurrentProject(CliScanType.Secret)
74+
CycodeBundle.message("scaDisplayName") -> service.startScanForCurrentProject(CliScanType.Sca)
75+
CycodeBundle.message("iacDisplayName") -> service.startScanForCurrentProject(CliScanType.Iac)
76+
CycodeBundle.message("sastDisplayName") -> service.startScanForCurrentProject(CliScanType.Sast)
7677
}
7778
}
7879

7980
private fun onRescanOptionClicked() {
8081
when (val node = getUnknownNode()) {
81-
is SecretDetectionNode -> service.startPathSecretScan(
82-
node.detection.detectionDetails.getFilepath(),
83-
onDemand = true
82+
is SecretDetectionNode -> service.startScan(
83+
CliScanType.Secret,
84+
listOf(node.detection.detectionDetails.getFilepath()),
8485
)
8586

86-
is ScaDetectionNode -> service.startPathScaScan(
87-
node.detection.detectionDetails.getFilepath(),
88-
onDemand = true
87+
is ScaDetectionNode -> service.startScan(
88+
CliScanType.Sca,
89+
listOf(node.detection.detectionDetails.getFilepath()),
8990
)
9091

91-
is IacDetectionNode -> service.startPathIacScan(
92-
node.detection.detectionDetails.getFilepath(),
93-
onDemand = true
92+
is IacDetectionNode -> service.startScan(
93+
CliScanType.Iac,
94+
listOf(node.detection.detectionDetails.getFilepath()),
9495
)
9596

96-
is SastDetectionNode -> service.startPathSastScan(
97-
node.detection.detectionDetails.getFilepath(),
98-
onDemand = true
97+
is SastDetectionNode -> service.startScan(
98+
CliScanType.Sast,
99+
listOf(node.detection.detectionDetails.getFilepath()),
99100
)
100101
}
101102
}

0 commit comments

Comments
 (0)