Skip to content

Commit a7b2a6d

Browse files
authored
CM-31957 - Fix scan results sharing between projects (#42)
1 parent 20262c7 commit a7b2a6d

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
## [1.1.4] - 2024-01-31
8+
9+
- Fix scan results sharing across projects
10+
711
## [1.1.3] - 2024-01-30
812

913
- Fix work with many opened projects
@@ -30,6 +34,8 @@
3034

3135
The first public release of the plugin.
3236

37+
[1.1.4]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.1.4
38+
3339
[1.1.3]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.1.3
3440

3541
[1.1.2]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.1.2
@@ -42,4 +48,4 @@ The first public release of the plugin.
4248

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

45-
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.1.3...HEAD
51+
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.1.4...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 = 1.1.3
7+
pluginVersion = 1.1.4
88

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

src/main/kotlin/com/cycode/plugin/annotators/CycodeAnnotator.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.cycode.plugin.cli.getPackageFileForLockFile
77
import com.cycode.plugin.cli.isSupportedLockFile
88
import com.cycode.plugin.intentions.CycodeIgnoreIntentionQuickFix
99
import com.cycode.plugin.intentions.CycodeIgnoreType
10+
import com.cycode.plugin.services.ScanResultsService
1011
import com.cycode.plugin.services.scanResults
1112
import com.intellij.lang.annotation.AnnotationHolder
1213
import com.intellij.lang.annotation.ExternalAnnotator
@@ -17,7 +18,9 @@ import com.intellij.openapi.util.TextRange
1718
import com.intellij.psi.PsiFile
1819

1920
class CycodeAnnotator : DumbAware, ExternalAnnotator<PsiFile, Unit>() {
20-
private val scanResults = scanResults()
21+
private fun getScanResults(psiFile: PsiFile): ScanResultsService {
22+
return scanResults(psiFile.project)
23+
}
2124

2225
override fun collectInformation(file: PsiFile): PsiFile = file
2326
override fun doAnnotate(psiFile: PsiFile?) {}
@@ -38,6 +41,7 @@ class CycodeAnnotator : DumbAware, ExternalAnnotator<PsiFile, Unit>() {
3841
}
3942

4043
private fun validateSecretTextRange(textRange: TextRange, psiFile: PsiFile): Boolean {
44+
val scanResults = getScanResults(psiFile)
4145
val detectedSubstr = psiFile.text.substring(textRange.startOffset, textRange.endOffset)
4246
val detectedSegment = scanResults.getDetectedSegment(CliScanType.Secret, textRange)
4347
if (detectedSegment == null) {
@@ -83,6 +87,7 @@ class CycodeAnnotator : DumbAware, ExternalAnnotator<PsiFile, Unit>() {
8387
}
8488

8589
private fun applyAnnotationsForSecrets(psiFile: PsiFile, holder: AnnotationHolder) {
90+
val scanResults = getScanResults(psiFile)
8691
val latestScanResult = scanResults.getSecretResults()
8792
if (latestScanResult !is CliResult.Success) {
8893
return
@@ -153,6 +158,7 @@ class CycodeAnnotator : DumbAware, ExternalAnnotator<PsiFile, Unit>() {
153158
}
154159

155160
private fun applyAnnotationsForSca(psiFile: PsiFile, holder: AnnotationHolder) {
161+
val scanResults = getScanResults(psiFile)
156162
val latestScanResult = scanResults.getScaResults()
157163
if (latestScanResult !is CliResult.Success) {
158164
return

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ data class SecretDetectionDetails(
1212
val committedAt: String, // TODO(MarshalX): actually DateTime. annotate?
1313
val filePath: String,
1414
val fileName: String,
15-
val fileExtension: String,
15+
val fileExtension: String?,
1616
val customRemediationGuidelines: String?,
1717
var detectedValue: String? = null, // custom field out of CLI JSON schema. TODO(MarshalX): add from CLI side?
1818
) : ScanDetectionDetailsBase {

src/main/kotlin/com/cycode/plugin/intentions/CycodeIgnoreIntentionQuickFix.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class CycodeIgnoreIntentionQuickFix(
2626
private val value: String
2727
) :
2828
BaseIntentionAction(), PriorityAction, Iconable {
29-
private val scanResults = scanResults()
30-
3129
override fun getText(): String {
3230
with(type) {
3331
return when (this) {
@@ -57,6 +55,7 @@ class CycodeIgnoreIntentionQuickFix(
5755
private fun applyIgnoreInUi(project: Project) {
5856
// exclude results from the local DB and restart the code analyzer
5957

58+
val scanResults = scanResults(project)
6059
when (type) {
6160
CycodeIgnoreType.VALUE -> scanResults.excludeResults(byValue = value)
6261
CycodeIgnoreType.RULE -> scanResults.excludeResults(byRuleId = value)

src/main/kotlin/com/cycode/plugin/services/CliService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CliService(private val project: Project) {
2222
private val pluginState = pluginState()
2323
private val pluginSettings = pluginSettings()
2424

25-
private val scanResults = scanResults()
25+
private val scanResults = scanResults(project)
2626

2727
private val cli = CliWrapper(pluginSettings.cliPath, getProjectRootDirectory())
2828

0 commit comments

Comments
 (0)