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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.24.1

require (
github.com/Checkmarx/containers-images-extractor v1.0.10
github.com/Checkmarx/containers-syft-packages-extractor v1.0.12
github.com/Checkmarx/containers-syft-packages-extractor v1.0.13
github.com/Checkmarx/containers-types v1.0.4
github.com/rs/zerolog v1.34.0
github.com/stretchr/testify v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Checkmarx/containers-images-extractor v1.0.10 h1:RxXbw03SPkVjvw2XR05RSLh+YTTQ2KshrQhOhTMFey8=
github.com/Checkmarx/containers-images-extractor v1.0.10/go.mod h1:KqOq3DUekL9VbklOVgTdZJC/+KLOYdfEoCSY/SWHdxU=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.12 h1:BgLMkqu0hfoVRoc9/h6Trf6qXoVnAYgOH3Oar78PWPg=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.12/go.mod h1:EFeB4//lO4KMVj9+eMg6z5jnO9F1e1T4jUoIcx0/19M=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.13 h1:9ah0rruMGgRiug/bD/JJDSrDqEqS7sKGVdc5sqbkwk8=
github.com/Checkmarx/containers-syft-packages-extractor v1.0.13/go.mod h1:EFeB4//lO4KMVj9+eMg6z5jnO9F1e1T4jUoIcx0/19M=
github.com/Checkmarx/containers-types v1.0.4 h1:Sa3y7IraZeeppspV0AmqYTNoDEHqn9yZZZq895SkabM=
github.com/Checkmarx/containers-types v1.0.4/go.mod h1:KR0w8XCosq3+6jRCfQrH7i//Nj2u11qaUJM62CREFZA=
github.com/CycloneDX/cyclonedx-go v0.9.2 h1:688QHn2X/5nRezKe2ueIVCt+NRqf7fl3AVQk+vaFcIo=
Expand Down
2 changes: 1 addition & 1 deletion pkg/containerResolver/containerScanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (cr *ContainersResolver) Resolve(scanPath string, resolutionFolderPath stri
}

//4. get images resolution
resolutionResult, err := cr.AnalyzeImages(imagesToAnalyze)
resolutionResult, err := cr.AnalyzeImagesWithPlatform(imagesToAnalyze, "linux/amd64")
if err != nil {
log.Err(err).Msg("Could not analyze images.")
return err
Expand Down
11 changes: 8 additions & 3 deletions pkg/containerResolver/containerScanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func (m *MockSyftPackagesExtractor) AnalyzeImages(images []types.ImageModel) ([]
return args.Get(0).([]*syftPackagesExtractor.ContainerResolution), args.Error(1)
}

func (m *MockSyftPackagesExtractor) AnalyzeImagesWithPlatform(images []types.ImageModel, platform string) ([]*syftPackagesExtractor.ContainerResolution, error) {
args := m.Called(images, platform)
return args.Get(0).([]*syftPackagesExtractor.ContainerResolution), args.Error(1)
}

func createTestFolder(dir string) {
// Create the directory if it doesn't exist
if _, err := os.Stat(dir); os.IsNotExist(err) {
Expand Down Expand Up @@ -130,15 +135,15 @@ func TestResolve(t *testing.T) {
types.ToImageModels(images),
map[string]map[string]string{"settings.json": {"key": "value"}}).
Return([]types.ImageModel{{Name: "image1"}}, nil)
mockSyftPackagesExtractor.On("AnalyzeImages", mock.Anything).Return(expectedResolution, nil)
mockSyftPackagesExtractor.On("AnalyzeImagesWithPlatform", mock.Anything, mock.Anything).Return(expectedResolution, nil)
mockImagesExtractor.On("SaveObjectToFile", checkmarxPath, expectedResolution).Return(nil)

err := resolver.Resolve(scanPath, resolutionFolderPath, images, true)
assert.NoError(t, err)

mockImagesExtractor.AssertCalled(t, "ExtractFiles", scanPath)
mockImagesExtractor.AssertCalled(t, "ExtractAndMergeImagesFromFiles", sampleFileImages, mock.Anything, mock.Anything)
mockSyftPackagesExtractor.AssertCalled(t, "AnalyzeImages", mock.Anything)
mockSyftPackagesExtractor.AssertCalled(t, "AnalyzeImagesWithPlatform", mock.Anything, "linux/amd64")
mockImagesExtractor.AssertCalled(t, "SaveObjectToFile", checkmarxPath, expectedResolution)
})

Expand Down Expand Up @@ -184,7 +189,7 @@ func TestResolve(t *testing.T) {
map[string]map[string]string{"settings.json": {"key": "value"}}).
Return([]types.ImageModel{{Name: "image1"}}, nil)

mockSyftPackagesExtractor.On("AnalyzeImages", mock.Anything).Return(expectedResolution, errors.New("error analyzing images"))
mockSyftPackagesExtractor.On("AnalyzeImagesWithPlatform", mock.Anything, "linux/amd64").Return(expectedResolution, errors.New("error analyzing images"))

err := resolver.Resolve(scanPath, resolutionFolderPath, images, false)
assert.Error(t, err)
Expand Down
Loading