diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 3be5c2d0d..055672b25 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -1399,7 +1399,7 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Version: "5.1.4", Type: "binary", PURL: "pkg:generic/ffmpeg@5.1.4", - Locations: locations("libavcodec"), + Locations: locations("libavcodec-9aae324f.so.59.37.100"), Metadata: metadata("ffmpeg-library"), }, }, diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/ffmpeg-shared-libs/5.1.4/linux-amd64/libavcodec b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/ffmpeg-shared-libs/5.1.4/linux-amd64/libavcodec-9aae324f.so.59.37.100 similarity index 89% rename from syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/ffmpeg-shared-libs/5.1.4/linux-amd64/libavcodec rename to syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/ffmpeg-shared-libs/5.1.4/linux-amd64/libavcodec-9aae324f.so.59.37.100 index f325e222a..632d213f7 100644 Binary files a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/ffmpeg-shared-libs/5.1.4/linux-amd64/libavcodec and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/ffmpeg-shared-libs/5.1.4/linux-amd64/libavcodec-9aae324f.so.59.37.100 differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index aee3ec6b6..c777ff243 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -838,7 +838,4 @@ from-images: platform: linux/amd64 paths: - /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libavcodec-9aae324f.so.59.37.100 - - /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libavformat-3ff1be5b.so.59.27.100 - - /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libavutil-a0a0531e.so.57.28.100 - - /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libswresample-2ec4394e.so.4.7.100 diff --git a/syft/pkg/cataloger/binary/test-fixtures/manager/internal/list_entries.go b/syft/pkg/cataloger/binary/test-fixtures/manager/internal/list_entries.go index 9ecf25440..dca529b8d 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/manager/internal/list_entries.go +++ b/syft/pkg/cataloger/binary/test-fixtures/manager/internal/list_entries.go @@ -2,11 +2,15 @@ package internal import ( "fmt" + "iter" "os" "path/filepath" + "slices" "sort" "strings" + "golang.org/x/exp/maps" + "github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config" ) @@ -195,3 +199,17 @@ func (e Entries) BinaryFromImageHasSnippet(cfg config.BinaryFromImage) bool { } return true } + +func (e Entries) Sorted() iter.Seq2[LogicalEntryKey, EntryInfo] { + keys := maps.Keys(e) + slices.SortFunc(keys, func(a, b LogicalEntryKey) int { + return strings.Compare(a.Path(), b.Path()) + }) + return func(yield func(LogicalEntryKey, EntryInfo) bool) { + for _, k := range keys { + if !yield(k, e[k]) { + return + } + } + } +} diff --git a/syft/pkg/cataloger/binary/test-fixtures/manager/testutil/snippet_or_binary.go b/syft/pkg/cataloger/binary/test-fixtures/manager/testutil/snippet_or_binary.go index d9d1e252e..b2a18aa4b 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/manager/testutil/snippet_or_binary.go +++ b/syft/pkg/cataloger/binary/test-fixtures/manager/testutil/snippet_or_binary.go @@ -42,7 +42,7 @@ func SnippetOrBinary(t *testing.T, path string, requireBinary bool) string { require.NoError(t, err) var fixturePath string - for k, v := range entries { + for k, v := range entries.Sorted() { if filepath.Dir(k.Path()) == path { // prefer the snippet over the binary if !requireBinary {