Skip to content

Commit 77b0f91

Browse files
authored
CM-44180 - Add proper support for disabled modules (#85)
1 parent dea2db0 commit 77b0f91

File tree

20 files changed

+132
-100
lines changed

20 files changed

+132
-100
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
9090
9191
- name: Upload artifact
92-
uses: actions/upload-artifact@v3
92+
uses: actions/upload-artifact@v4
9393
with:
9494
name: ${{ steps.artifact.outputs.filename }}
9595
path: ./build/distributions/content/*/*
@@ -125,7 +125,7 @@ jobs:
125125
#
126126
# - name: Collect Tests Result
127127
# if: ${{ failure() }}
128-
# uses: actions/upload-artifact@v3
128+
# uses: actions/upload-artifact@v4
129129
# with:
130130
# name: tests-result
131131
# path: ${{ github.workspace }}/build/reports/tests
@@ -205,7 +205,7 @@ jobs:
205205

206206
- name: Collect Plugin Verifier Result
207207
if: ${{ always() }}
208-
uses: actions/upload-artifact@v3
208+
uses: actions/upload-artifact@v4
209209
with:
210210
name: pluginVerifier-result
211211
path: ${{ github.workspace }}/build/reports/pluginVerifier

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## [Unreleased]
66

7+
- Add proper support for disabled modules
8+
79
## [2.4.1] - 2025-01-29
810

911
- Fix usage of internal API in 2025.1

src/main/kotlin/com/cycode/plugin/annotators/annotationAppliers/IacApplier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class IacApplier(private val scanResults: ScanResultsService) : AnnotationApplie
2121
}
2222

2323
override fun apply(psiFile: PsiFile, holder: AnnotationHolder) {
24-
val latestScanResult = scanResults.getIacResults()
24+
val latestScanResult = scanResults.iacResults
2525
if (latestScanResult !is CliResult.Success) {
2626
return
2727
}

src/main/kotlin/com/cycode/plugin/annotators/annotationAppliers/SastApplier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SastApplier(private val scanResults: ScanResultsService) : AnnotationAppli
2020
}
2121

2222
override fun apply(psiFile: PsiFile, holder: AnnotationHolder) {
23-
val latestScanResult = scanResults.getSastResults()
23+
val latestScanResult = scanResults.sastResults
2424
if (latestScanResult !is CliResult.Success) {
2525
return
2626
}

src/main/kotlin/com/cycode/plugin/annotators/annotationAppliers/ScaApplier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ScaApplier(private val scanResults: ScanResultsService) : AnnotationApplie
3131
}
3232

3333
override fun apply(psiFile: PsiFile, holder: AnnotationHolder) {
34-
val latestScanResult = scanResults.getScaResults()
34+
val latestScanResult = scanResults.scaResults
3535
if (latestScanResult !is CliResult.Success) {
3636
return
3737
}

src/main/kotlin/com/cycode/plugin/annotators/annotationAppliers/SecretApplier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SecretApplier(private val scanResults: ScanResultsService) : AnnotationApp
3131
}
3232

3333
override fun apply(psiFile: PsiFile, holder: AnnotationHolder) {
34-
val latestScanResult = scanResults.getSecretResults()
34+
val latestScanResult = scanResults.secretResults
3535
if (latestScanResult !is CliResult.Success) {
3636
return
3737
}

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

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

33
data class SupportedModulesStatus(
4-
// TODO(MarshalX): respect enabled/disabled scanning modules
54
val secretScanning: Boolean,
65
val scaScanning: Boolean,
76
val iacScanning: Boolean,

src/main/kotlin/com/cycode/plugin/components/toolWindow/CycodeToolWindowFactory.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.cycode.plugin.components.toolWindow.components.loadingContentTab.Load
77
import com.cycode.plugin.components.toolWindow.components.scanContentTab.ScanContentTab
88
import com.cycode.plugin.icons.PluginIcons
99
import com.cycode.plugin.services.cycode
10-
import com.cycode.plugin.services.pluginState
10+
import com.cycode.plugin.services.pluginLocalState
1111
import com.intellij.openapi.application.ApplicationManager
1212
import com.intellij.openapi.application.WriteAction
1313
import com.intellij.openapi.project.DumbAware
@@ -75,21 +75,21 @@ private fun createToolWindowContent(component: JPanel): Content {
7575

7676
fun getRightPanelDependingOnState(project: Project): JPanel {
7777
val service = cycode(project)
78-
val pluginState = pluginState()
78+
val pluginLocalState = pluginLocalState(project)
7979

80-
if (!pluginState.cliInstalled) {
80+
if (!pluginLocalState.cliInstalled) {
8181
return LoadingContentTab().getContent(service)
8282
}
8383

84-
return if (pluginState.cliAuthed) {
84+
return if (pluginLocalState.cliAuthed) {
8585
ScanContentTab().getContent(service)
8686
} else {
8787
AuthContentTab().getContent(service)
8888
}
8989
}
9090

9191
fun updateToolWindowStateForAllProjects() {
92-
// we are using this method to sync the state of the tool window for all open projects
92+
// we are using this method to sync the state of the tool window for all open projects,
9393
// for example, after changing the auth state
9494
ApplicationManager.getApplication().runReadAction {
9595
val projects = ProjectManager.getInstance().openProjects

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.cycode.plugin.components.toolWindow.components.cycodeActionToolBar.a
33
import com.cycode.plugin.CycodeBundle
44
import com.cycode.plugin.cli.CliScanType
55
import com.cycode.plugin.services.cycode
6-
import com.cycode.plugin.services.pluginState
6+
import com.cycode.plugin.services.pluginLocalState
77
import com.intellij.icons.AllIcons
88
import com.intellij.openapi.actionSystem.ActionUpdateThread
99
import com.intellij.openapi.actionSystem.AnActionEvent
@@ -27,16 +27,25 @@ class RunAllAction :
2727
// we can provide "stop" action only after that
2828
val project = e.project ?: return
2929
val service = cycode(project)
30+
val pluginLocalState = pluginLocalState(project)
3031

31-
service.startScanForCurrentProject(CliScanType.Secret)
32-
service.startScanForCurrentProject(CliScanType.Sca)
33-
service.startScanForCurrentProject(CliScanType.Iac)
34-
service.startScanForCurrentProject(CliScanType.Sast)
32+
if (pluginLocalState.isSecretScanningEnabled) {
33+
service.startScanForCurrentProject(CliScanType.Secret)
34+
}
35+
if (pluginLocalState.isScaScanningEnabled) {
36+
service.startScanForCurrentProject(CliScanType.Sca)
37+
}
38+
if (pluginLocalState.isIacScanningEnabled) {
39+
service.startScanForCurrentProject(CliScanType.Iac)
40+
}
41+
if (pluginLocalState.isSastScanningEnabled) {
42+
service.startScanForCurrentProject(CliScanType.Sast)
43+
}
3544
}
3645

3746
override fun update(e: AnActionEvent) {
3847
e.presentation.isEnabled = e.project != null &&
3948
!e.project!!.isDisposed &&
40-
pluginState().cliAuthed
49+
pluginLocalState(e.project).cliAuthed
4150
}
4251
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.cycode.plugin.cli.CliScanType
55
import com.cycode.plugin.components.Component
66
import com.cycode.plugin.components.common.createClickableLabel
77
import com.cycode.plugin.services.CycodeService
8+
import com.cycode.plugin.services.pluginLocalState
89
import com.intellij.util.ui.JBUI
910
import java.awt.GridBagConstraints
1011
import java.awt.GridBagLayout
@@ -27,24 +28,31 @@ class ScanContentTab : Component<CycodeService>() {
2728
}
2829

2930
override fun getContent(service: CycodeService): JPanel {
31+
// do not get local state on class level because will be outdated
32+
val pluginLocalState = pluginLocalState(service.project)
33+
3034
addComponentToPanel(createClickableLabel(CycodeBundle.message("scanTabTitleLabel")))
3135
addComponentToPanel(
3236
JButton(CycodeBundle.message("scanTabSecretsBtn")).apply {
37+
isEnabled = pluginLocalState.isSecretScanningEnabled
3338
addActionListener { service.startScanForCurrentProject(CliScanType.Secret) }
3439
},
3540
)
3641
addComponentToPanel(
3742
JButton(CycodeBundle.message("scanTabScaBtn")).apply {
43+
isEnabled = pluginLocalState.isScaScanningEnabled
3844
addActionListener { service.startScanForCurrentProject(CliScanType.Sca) }
3945
},
4046
)
4147
addComponentToPanel(
4248
JButton(CycodeBundle.message("scanTabIacBtn")).apply {
49+
isEnabled = pluginLocalState.isIacScanningEnabled
4350
addActionListener { service.startScanForCurrentProject(CliScanType.Iac) }
4451
},
4552
)
4653
addComponentToPanel(
4754
JButton(CycodeBundle.message("scanTabSastBtn")).apply {
55+
isEnabled = pluginLocalState.isSastScanningEnabled
4856
addActionListener { service.startScanForCurrentProject(CliScanType.Sast) }
4957
},
5058
)

0 commit comments

Comments
 (0)