github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/rpm/parse_rpm_manifest_test.go (about)

     1  package rpm
     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  			MetadataType: pkg.RpmMetadataType,
    22  			Metadata: pkg.RpmMetadata{
    23  				Name:      "mariner-release",
    24  				Epoch:     nil,
    25  				Arch:      "noarch",
    26  				Release:   "12.cm2",
    27  				Version:   "2.0",
    28  				SourceRpm: "mariner-release-2.0-12.cm2.src.rpm",
    29  				Size:      580,
    30  				Vendor:    "Microsoft Corporation",
    31  			},
    32  		},
    33  		{
    34  			Name:         "filesystem",
    35  			Version:      "1.1-9.cm2",
    36  			PURL:         "pkg:rpm/filesystem@1.1-9.cm2?arch=x86_64&upstream=filesystem-1.1-9.cm2.src.rpm",
    37  			Locations:    file.NewLocationSet(location),
    38  			Type:         pkg.RpmPkg,
    39  			MetadataType: pkg.RpmMetadataType,
    40  			Metadata: pkg.RpmMetadata{
    41  				Name:      "filesystem",
    42  				Epoch:     nil,
    43  				Arch:      "x86_64",
    44  				Release:   "9.cm2",
    45  				Version:   "1.1",
    46  				SourceRpm: "filesystem-1.1-9.cm2.src.rpm",
    47  				Size:      7596,
    48  				Vendor:    "Microsoft Corporation",
    49  			},
    50  		},
    51  		{
    52  			Name:         "glibc",
    53  			Version:      "2.35-2.cm2",
    54  			PURL:         "pkg:rpm/glibc@2.35-2.cm2?arch=x86_64&upstream=glibc-2.35-2.cm2.src.rpm",
    55  			Locations:    file.NewLocationSet(location),
    56  			Type:         pkg.RpmPkg,
    57  			MetadataType: pkg.RpmMetadataType,
    58  			Metadata: pkg.RpmMetadata{
    59  				Name:      "glibc",
    60  				Epoch:     nil,
    61  				Arch:      "x86_64",
    62  				Release:   "2.cm2",
    63  				Version:   "2.35",
    64  				SourceRpm: "glibc-2.35-2.cm2.src.rpm",
    65  				Size:      10855265,
    66  				Vendor:    "Microsoft Corporation",
    67  			},
    68  		},
    69  		{
    70  			Name:         "openssl-libs",
    71  			Version:      "1.1.1k-15.cm2",
    72  			PURL:         "pkg:rpm/openssl-libs@1.1.1k-15.cm2?arch=x86_64&upstream=openssl-1.1.1k-15.cm2.src.rpm",
    73  			Locations:    file.NewLocationSet(location),
    74  			Type:         pkg.RpmPkg,
    75  			MetadataType: pkg.RpmMetadataType,
    76  			Metadata: pkg.RpmMetadata{
    77  				Name:      "openssl-libs",
    78  				Epoch:     nil,
    79  				Arch:      "x86_64",
    80  				Release:   "15.cm2",
    81  				Version:   "1.1.1k",
    82  				SourceRpm: "openssl-1.1.1k-15.cm2.src.rpm",
    83  				Size:      4365048,
    84  				Vendor:    "Microsoft Corporation",
    85  			},
    86  		},
    87  	}
    88  
    89  	pkgtest.NewCatalogTester().
    90  		FromFile(t, fixture).
    91  		Expects(expected, nil).
    92  		TestParser(t, parseRpmManifest)
    93  
    94  }