From b5db145b3975b09afdb8b47564d45b6e0e7d9d40 Mon Sep 17 00:00:00 2001 From: Anatolii Stadnichuk <134394882+anatolii-paloaltonetworks@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:09:59 +0000 Subject: [PATCH] no fail for customers without sast module (#105) * sast no fail for customers without sast module * sast no fail for customers without sast module --- gradle.properties | 2 +- .../CheckovScanCommandsService.kt | 10 ++++++++++ .../com/bridgecrew/services/scan/CheckovScanService.kt | 4 ++++ .../com/bridgecrew/services/scan/FullScanState.kt | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ed7c4fb..44ceadd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ pluginGroup = com.github.bridgecrewio.prismajetbrainsidea pluginName = prismacloud-jetbrains-idea -pluginVersion = 1.0.11 +pluginVersion = 1.0.13 pluginSinceBuild = 203 # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions diff --git a/src/main/kotlin/com/bridgecrew/services/checkovScanCommandsService/CheckovScanCommandsService.kt b/src/main/kotlin/com/bridgecrew/services/checkovScanCommandsService/CheckovScanCommandsService.kt index d342d7a..63598b7 100644 --- a/src/main/kotlin/com/bridgecrew/services/checkovScanCommandsService/CheckovScanCommandsService.kt +++ b/src/main/kotlin/com/bridgecrew/services/checkovScanCommandsService/CheckovScanCommandsService.kt @@ -34,11 +34,21 @@ abstract class CheckovScanCommandsService(val project: Project) { val cmdByFramework = arrayListOf() cmdByFramework.addAll(baseCmds) cmdByFramework.addAll(getCheckovCliArgsForExecCommand(getOutputFilePath(outputFilePath))) + cmdByFramework.addAll(getCheckovNoFailOnCrash(framework)) + cmdByFramework.add("--framework") cmdByFramework.add(framework) return cmdByFramework } + private fun getCheckovNoFailOnCrash(framework: String): ArrayList { + val command = ArrayList() + if (framework === "sast") { + command.add("--no-fail-on-crash") + } + + return command + } private fun getCheckovCliArgsForExecCommand(outputFilePath: String): ArrayList { val apiToken = settings?.getApiKey() diff --git a/src/main/kotlin/com/bridgecrew/services/scan/CheckovScanService.kt b/src/main/kotlin/com/bridgecrew/services/scan/CheckovScanService.kt index 38fa9d8..89ef2d1 100644 --- a/src/main/kotlin/com/bridgecrew/services/scan/CheckovScanService.kt +++ b/src/main/kotlin/com/bridgecrew/services/scan/CheckovScanService.kt @@ -279,6 +279,10 @@ class CheckovScanService: Disposable { } + if (scanTaskResult.errorReason.contains("ModuleNotEnabledError")) { + return true // skip module not enabled error + } + if (errorCode != 0 || scanTaskResult.errorReason.isNotEmpty()) { project.service().scanningError(scanTaskResult, scanningSource, Exception("Error while scanning $scanningSource, exit code - $errorCode, error reason - ${scanTaskResult.errorReason}"), scanSourceType) return false diff --git a/src/main/kotlin/com/bridgecrew/services/scan/FullScanState.kt b/src/main/kotlin/com/bridgecrew/services/scan/FullScanState.kt index 294d878..bb7fd1a 100644 --- a/src/main/kotlin/com/bridgecrew/services/scan/FullScanState.kt +++ b/src/main/kotlin/com/bridgecrew/services/scan/FullScanState.kt @@ -173,7 +173,7 @@ class FullScanStateService(val project: Project) { return "" } - return "${invalidFilesSize}} files were detected as invalid.\n" + return "${invalidFilesSize} files were detected as invalid.\n" } fun wereAllFrameworksFinished(): Boolean {