Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## [Unreleased]

## [1.1.4] - 2024-01-31

- Fix scan results sharing across projects

## [1.1.3] - 2024-01-30

- Fix work with many opened projects
Expand All @@ -30,6 +34,8 @@

The first public release of the plugin.

[1.1.4]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.1.4

[1.1.3]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v1.1.3

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

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

[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.1.3...HEAD
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v1.1.4...HEAD
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.cycode.plugin
pluginName = Cycode
pluginRepositoryUrl = https://github.com/cycodehq/intellij-platform-plugin
# SemVer format -> https://semver.org
pluginVersion = 1.1.3
pluginVersion = 1.1.4

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 211.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.cycode.plugin.cli.getPackageFileForLockFile
import com.cycode.plugin.cli.isSupportedLockFile
import com.cycode.plugin.intentions.CycodeIgnoreIntentionQuickFix
import com.cycode.plugin.intentions.CycodeIgnoreType
import com.cycode.plugin.services.ScanResultsService
import com.cycode.plugin.services.scanResults
import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.ExternalAnnotator
Expand All @@ -17,7 +18,9 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiFile

class CycodeAnnotator : DumbAware, ExternalAnnotator<PsiFile, Unit>() {
private val scanResults = scanResults()
private fun getScanResults(psiFile: PsiFile): ScanResultsService {
return scanResults(psiFile.project)
}

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

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

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

private fun applyAnnotationsForSca(psiFile: PsiFile, holder: AnnotationHolder) {
val scanResults = getScanResults(psiFile)
val latestScanResult = scanResults.getScaResults()
if (latestScanResult !is CliResult.Success) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class SecretDetectionDetails(
val committedAt: String, // TODO(MarshalX): actually DateTime. annotate?
val filePath: String,
val fileName: String,
val fileExtension: String,
val fileExtension: String?,
val customRemediationGuidelines: String?,
var detectedValue: String? = null, // custom field out of CLI JSON schema. TODO(MarshalX): add from CLI side?
) : ScanDetectionDetailsBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class CycodeIgnoreIntentionQuickFix(
private val value: String
) :
BaseIntentionAction(), PriorityAction, Iconable {
private val scanResults = scanResults()

override fun getText(): String {
with(type) {
return when (this) {
Expand Down Expand Up @@ -57,6 +55,7 @@ class CycodeIgnoreIntentionQuickFix(
private fun applyIgnoreInUi(project: Project) {
// exclude results from the local DB and restart the code analyzer

val scanResults = scanResults(project)
when (type) {
CycodeIgnoreType.VALUE -> scanResults.excludeResults(byValue = value)
CycodeIgnoreType.RULE -> scanResults.excludeResults(byRuleId = value)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/cycode/plugin/services/CliService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CliService(private val project: Project) {
private val pluginState = pluginState()
private val pluginSettings = pluginSettings()

private val scanResults = scanResults()
private val scanResults = scanResults(project)

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

Expand Down