Skip to content

Commit 030edbd

Browse files
only containers folder deleted
1 parent f1bc80d commit 030edbd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

internal/commands/scan.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ func getUploadURLFromSource(cmd *cobra.Command, uploadsWrapper wrappers.UploadsW
19421942
if unzip {
19431943
_ = cleanTempUnzipDirectory(directoryPath)
19441944
}
1945-
// Clean up .checkmarx directory on container scan error
1945+
// Clean up .checkmarx/containers directory on container scan error
19461946
_ = cleanCheckmarxContainersDirectory(directoryPath)
19471947
return "", "", containerResolverError
19481948
}
@@ -1953,7 +1953,7 @@ func getUploadURLFromSource(cmd *cobra.Command, uploadsWrapper wrappers.UploadsW
19531953
containerResolutionFilePath := filepath.Join(directoryPath, ".checkmarx", "containers", containerResolutionFileName)
19541954
zipFilePath, dirPathErr = util.CompressFile(containerResolutionFilePath, containerResolutionFileName, directoryCreationPrefix)
19551955

1956-
// Clean up .checkmarx directory after successful container scan compression
1956+
// Clean up .checkmarx/containers directory after successful container scan compression
19571957
if dirPathErr == nil {
19581958
_ = cleanCheckmarxContainersDirectory(directoryPath)
19591959
}
@@ -1962,13 +1962,13 @@ func getUploadURLFromSource(cmd *cobra.Command, uploadsWrapper wrappers.UploadsW
19621962
zipFilePath, dirPathErr = compressFolder(directoryPath, sourceDirFilter, userIncludeFilter, scaResolver)
19631963
}
19641964

1965-
// Clean up .checkmarx directory after successful mixed scan (including containers) compression
1965+
// Clean up .checkmarx/containers directory after successful mixed scan (including containers) compression
19661966
if dirPathErr == nil && containerScanTriggered && containerResolveLocally {
19671967
_ = cleanCheckmarxContainersDirectory(directoryPath)
19681968
}
19691969
}
19701970
if dirPathErr != nil {
1971-
// Clean up .checkmarx directory on compression error if container scan was involved
1971+
// Clean up .checkmarx/containers directory on compression error if container scan was involved
19721972
if containerScanTriggered && containerResolveLocally {
19731973
_ = cleanCheckmarxContainersDirectory(directoryPath)
19741974
}
@@ -1991,21 +1991,21 @@ func getUploadURLFromSource(cmd *cobra.Command, uploadsWrapper wrappers.UploadsW
19911991
return preSignedURL, zipFilePath, nil
19921992
}
19931993

1994-
// cleanCheckmarxContainersDirectory removes the .checkmarx/containers directory after container scan completion
1994+
// cleanCheckmarxContainersDirectory removes only the .checkmarx/containers directory after container scan completion
19951995
func cleanCheckmarxContainersDirectory(directoryPath string) error {
1996-
checkmarxPath := filepath.Join(directoryPath, ".checkmarx")
1997-
if _, err := os.Stat(checkmarxPath); os.IsNotExist(err) {
1998-
logger.PrintIfVerbose("No .checkmarx directory found to clean up")
1996+
containersPath := filepath.Join(directoryPath, ".checkmarx", "containers")
1997+
if _, err := os.Stat(containersPath); os.IsNotExist(err) {
1998+
logger.PrintIfVerbose("No .checkmarx/containers directory found to clean up")
19991999
return nil
20002000
}
20012001

2002-
logger.PrintIfVerbose("Cleaning up .checkmarx directory after container scan")
2003-
err := os.RemoveAll(checkmarxPath)
2002+
logger.PrintIfVerbose("Cleaning up .checkmarx/containers directory after container scan")
2003+
err := os.RemoveAll(containersPath)
20042004
if err != nil {
2005-
logger.PrintIfVerbose(fmt.Sprintf("Warning: Failed to clean up .checkmarx directory: %s", err.Error()))
2006-
return errors.Wrapf(err, "Failed to clean up .checkmarx directory")
2005+
logger.PrintIfVerbose(fmt.Sprintf("Warning: Failed to clean up .checkmarx/containers directory: %s", err.Error()))
2006+
return errors.Wrapf(err, "Failed to clean up .checkmarx/containers directory")
20072007
}
2008-
logger.PrintIfVerbose("Successfully cleaned up .checkmarx directory")
2008+
logger.PrintIfVerbose("Successfully cleaned up .checkmarx/containers directory")
20092009
return nil
20102010
}
20112011

0 commit comments

Comments
 (0)