Skip to content

Commit 2dd8c5d

Browse files
authored
CM-40222 - Fix empty IaC scan results on Windows (#78)
1 parent 23bf675 commit 2dd8c5d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

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+
- Fix empty IaC scan results on Windows
8+
79
## [2.0.0] - 2024-08-20
810

911
- Add support for IDEs 2024.2

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.cycode.plugin.cli.models.scanResult.secret.SecretScanResult
1414
import com.cycode.plugin.components.toolWindow.updateToolWindowState
1515
import com.cycode.plugin.sentry.SentryInit
1616
import com.cycode.plugin.utils.CycodeNotifier
17+
import com.cycode.plugin.utils.isValidExistedFilePath
1718
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
1819
import com.intellij.openapi.components.Service
1920
import com.intellij.openapi.diagnostic.thisLogger
@@ -268,7 +269,7 @@ class CliService(private val project: Project) {
268269
// TF plans are virtual files what is not exist in the file system
269270
// "file_name": "1711298252-/Users/ilyasiamionau/projects/cycode/ilya-siamionau-payloads/tfplan.tf",
270271
// skip such detections
271-
return@filter filePath.startsWith("/")
272+
return@filter isValidExistedFilePath(filePath)
272273
}
273274
}
274275

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.cycode.plugin.utils
2+
3+
import java.io.File
4+
import java.io.IOException
5+
6+
fun isValidExistedFilePath(path: String): Boolean {
7+
val file = File(path)
8+
return try {
9+
file.canonicalPath
10+
file.exists()
11+
} catch (e: IOException) {
12+
false
13+
}
14+
}

0 commit comments

Comments
 (0)