Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #113 from bridgecrewio/fix_scan_by_checkov
Browse files Browse the repository at this point in the history
[PCSUP-23839] - bug fix - on windows when scanning via pip, it doesn't work
  • Loading branch information
AdamDev authored Jul 16, 2024
2 parents 7ed1832 + b12e935 commit e931086
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.bridgecrew.results.*
import com.bridgecrew.settings.CheckovGlobalState
import com.bridgecrew.utils.CheckovUtils
import com.bridgecrew.utils.fromDockerFilePath
import com.bridgecrew.utils.isWindows
import com.intellij.openapi.components.Service
import com.intellij.openapi.project.Project
import org.apache.commons.io.FilenameUtils
Expand Down Expand Up @@ -91,6 +92,10 @@ class ResultsCacheService(val project: Project) {
try {
result.file_abs_path = fromDockerFilePath(result.file_abs_path)

if (isWindows()) {
result.file_abs_path = result.file_abs_path.replace("\\", "/");
}

val category: Category = mapCheckovCheckTypeToScanType(result.check_type, result.check_id)
val checkType = this.getCheckType(result.check_type)
val resource: String = CheckovUtils.extractResource(result, category, checkType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ abstract class CheckovScanCommandsService(val project: Project) {
}

private fun getNormalizedExcludePath(excludePath: String): String {
if (System.getProperty("os.name").lowercase().contains("win")) {
if (isWindows()) {
var winExcludePath = StringUtils.removeEnd(excludePath, "\\")
winExcludePath = StringUtils.removeStart(winExcludePath, "**/")
winExcludePath = StringUtils.removeStart(winExcludePath, "*")
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/bridgecrew/utils/OSUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.bridgecrew.utils

fun isWindows(): Boolean {
return System.getProperty("os.name").lowercase().contains("win")
}

0 comments on commit e931086

Please sign in to comment.