Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions pkg/containerResolver/containerScanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,10 @@ func cleanup(originalPath string, outputPath string, checkmarxPath string) error
}
}

// Clean up containers folder inside .checkmarx if checkmarxPath is provided
if checkmarxPath != "" {
// checkmarxPath points to .checkmarx/containers, so we delete this directory
cxErr := imagesExtractor.DeleteDirectory(checkmarxPath)
if cxErr != nil {
log.Warn().Err(cxErr).Msg("Could not delete containers directory inside .checkmarx folder")
}
}
// The cleanup of .checkmarx/containers should be handled by the caller after it has
// processed the resolution file.

// Only return error from output directory cleanup, not from .checkmarx cleanup
// Only return error from output directory cleanup
return err
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/containerResolver/containerScanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ func TestResolve(t *testing.T) {
mockImagesExtractor.AssertCalled(t, "ExtractAndMergeImagesFromFiles", sampleFileImages, mock.Anything, mock.Anything)
mockSyftPackagesExtractor.AssertCalled(t, "AnalyzeImagesWithPlatform", mock.Anything, "linux/amd64")
mockImagesExtractor.AssertCalled(t, "SaveObjectToFile", checkmarxPath, expectedResolution)

// Verify that the containers directory still exists after Resolve completes
// This tests the fix for the cleanup bug where the directory was being deleted too early
if _, err := os.Stat(checkmarxPath); os.IsNotExist(err) {
t.Errorf("Expected containers directory to exist after Resolve completes, but it was deleted")
}
})

t.Run("ScanPath Validation failure", func(t *testing.T) {
Expand Down
Loading