github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/pkg/cataloger/redhat/parse_rpm_manifest_test.go (about) 1 package redhat 2 3 import ( 4 "testing" 5 6 "github.com/anchore/syft/syft/file" 7 "github.com/anchore/syft/syft/pkg" 8 "github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest" 9 ) 10 11 func TestParseRpmManifest(t *testing.T) { 12 fixture := "test-fixtures/container-manifest-2" 13 location := file.NewLocation(fixture) 14 expected := []pkg.Package{ 15 { 16 Name: "mariner-release", 17 Version: "2.0-12.cm2", 18 PURL: "pkg:rpm/mariner-release@2.0-12.cm2?arch=noarch&upstream=mariner-release-2.0-12.cm2.src.rpm", 19 Locations: file.NewLocationSet(location), 20 Type: pkg.RpmPkg, 21 Metadata: pkg.RpmDBEntry{ 22 Name: "mariner-release", 23 Epoch: nil, 24 Arch: "noarch", 25 Release: "12.cm2", 26 Version: "2.0", 27 SourceRpm: "mariner-release-2.0-12.cm2.src.rpm", 28 Size: 580, 29 Vendor: "Microsoft Corporation", 30 }, 31 }, 32 { 33 Name: "filesystem", 34 Version: "1.1-9.cm2", 35 PURL: "pkg:rpm/filesystem@1.1-9.cm2?arch=x86_64&upstream=filesystem-1.1-9.cm2.src.rpm", 36 Locations: file.NewLocationSet(location), 37 Type: pkg.RpmPkg, 38 Metadata: pkg.RpmDBEntry{ 39 Name: "filesystem", 40 Epoch: nil, 41 Arch: "x86_64", 42 Release: "9.cm2", 43 Version: "1.1", 44 SourceRpm: "filesystem-1.1-9.cm2.src.rpm", 45 Size: 7596, 46 Vendor: "Microsoft Corporation", 47 }, 48 }, 49 { 50 Name: "glibc", 51 Version: "2.35-2.cm2", 52 PURL: "pkg:rpm/glibc@2.35-2.cm2?arch=x86_64&upstream=glibc-2.35-2.cm2.src.rpm", 53 Locations: file.NewLocationSet(location), 54 Type: pkg.RpmPkg, 55 Metadata: pkg.RpmDBEntry{ 56 Name: "glibc", 57 Epoch: nil, 58 Arch: "x86_64", 59 Release: "2.cm2", 60 Version: "2.35", 61 SourceRpm: "glibc-2.35-2.cm2.src.rpm", 62 Size: 10855265, 63 Vendor: "Microsoft Corporation", 64 }, 65 }, 66 { 67 Name: "openssl-libs", 68 Version: "1.1.1k-15.cm2", 69 PURL: "pkg:rpm/openssl-libs@1.1.1k-15.cm2?arch=x86_64&upstream=openssl-1.1.1k-15.cm2.src.rpm", 70 Locations: file.NewLocationSet(location), 71 Type: pkg.RpmPkg, 72 Metadata: pkg.RpmDBEntry{ 73 Name: "openssl-libs", 74 Epoch: nil, 75 Arch: "x86_64", 76 Release: "15.cm2", 77 Version: "1.1.1k", 78 SourceRpm: "openssl-1.1.1k-15.cm2.src.rpm", 79 Size: 4365048, 80 Vendor: "Microsoft Corporation", 81 }, 82 }, 83 } 84 85 pkgtest.NewCatalogTester(). 86 FromFile(t, fixture). 87 Expects(expected, nil). 88 TestParser(t, parseRpmManifest) 89 90 }