Skip to content

Commit a5d7ece

Browse files
authored
CM-48118 - Add detection sorting by line number in addition to severity (#87)
1 parent 1bec428 commit a5d7ece

17 files changed

Lines changed: 55 additions & 25 deletions

File tree

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+
## [2.6.0] - 2025-05-12
8+
9+
- Add detection sorting by line number in addition to severity
10+
711
## [2.5.0] - 2025-02-24
812

913
- Add proper support for disabled modules
@@ -147,6 +151,8 @@
147151

148152
The first public release of the plugin.
149153

154+
[2.6.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.6.0
155+
150156
[2.5.0]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.5.0
151157

152158
[2.4.1]: https://github.com/cycodehq/intellij-platform-plugin/releases/tag/v2.4.1
@@ -207,4 +213,4 @@ The first public release of the plugin.
207213

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

210-
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.5.0...HEAD
216+
[Unreleased]: https://github.com/cycodehq/intellij-platform-plugin/compare/v2.6.0...HEAD

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @MarshalX @MichalBor @MaorDavidzon @artem-fedorov @elsapet @gotbadger @cfabianski
1+
* @MarshalX @elsapet @gotbadger @cfabianski

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.5.0
7+
pluginVersion = 2.6.0
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 = 251.*
11+
pluginUntilBuild = 252.*
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/annotators/annotationAppliers/IacApplier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class IacApplier(private val scanResults: ScanResultsService) : AnnotationApplie
3434
val severity = convertSeverity(detection.severity)
3535

3636
// IaC doesn't provide start and end positions, so we have to calculate them from the line number
37-
val line = detection.detectionDetails.lineInFile - 1
37+
val line = detection.detectionDetails.getLineNumber() - 1
3838
val startOffset = psiFile.text.lines().take(line).sumOf { it.length + 1 }
3939
val endOffset = startOffset + psiFile.text.lines()[line].length
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SastApplier(private val scanResults: ScanResultsService) : AnnotationAppli
3333
val severity = convertSeverity(detection.severity)
3434

3535
// SAST doesn't provide start and end positions, so we have to calculate them from the line number
36-
val line = detection.detectionDetails.lineInFile - 1
36+
val line = detection.detectionDetails.getLineNumber() - 1
3737
val startOffset = psiFile.text.lines().take(line).sumOf { it.length + 1 }
3838
val endOffset = startOffset + psiFile.text.lines()[line].length
3939

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ScaApplier(private val scanResults: ScanResultsService) : AnnotationApplie
4444
val severity = convertSeverity(detection.severity)
4545

4646
// SCA doesn't provide start and end positions, so we have to calculate them from the line number
47-
val line = detection.detectionDetails.lineInFile - 1
47+
val line = detection.detectionDetails.getLineNumber() - 1
4848
val startOffset = psiFile.text.lines().take(line).sumOf { it.length + 1 }
4949
val endOffset = startOffset + psiFile.text.lines()[line].length
5050

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ package com.cycode.plugin.cli.models.scanResult
22

33
interface ScanDetectionDetailsBase {
44
fun getFilepath(): String
5+
/**
6+
* Gets the line number.
7+
* @return The 1-based line number (first line is 1, not 0)
8+
*/
9+
fun getLineNumber(): Int
510
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ data class IacDetection(
2121
}
2222

2323
override fun getFormattedNodeTitle(): String {
24-
return CycodeBundle.message("iacNodeTitle", detectionDetails.lineInFile, getFormattedMessage())
24+
return CycodeBundle.message("iacNodeTitle", detectionDetails.getLineNumber(), getFormattedMessage())
2525
}
2626
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ data class IacDetectionDetails(
1919
override fun getFilepath(): String {
2020
return fileName
2121
}
22+
23+
override fun getLineNumber(): Int {
24+
return lineInFile
25+
}
2226
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ data class SastDetection(
2121
}
2222

2323
override fun getFormattedNodeTitle(): String {
24-
return CycodeBundle.message("sastNodeTitle", detectionDetails.lineInFile, getFormattedMessage())
24+
return CycodeBundle.message("sastNodeTitle", detectionDetails.getLineNumber(), getFormattedMessage())
2525
}
2626
}

0 commit comments

Comments
 (0)