diff --git a/grype/pkg/package_test.go b/grype/pkg/package_test.go index 2fdccfc6a7d..879cbe94143 100644 --- a/grype/pkg/package_test.go +++ b/grype/pkg/package_test.go @@ -706,6 +706,20 @@ func Test_RemoveBinaryPackagesByOverlap(t *testing.T) { []string{"rpm:node@19.2-r1 -> apk:node@19.2"}), expectedPackages: []string{"apk:node@19.2", "rpm:node@19.2-r1"}, }, + { + name: "does not exclude if OS package owns OS package", + sbom: catalogWithOverlaps( + []string{"rpm:perl@19.2-r1", "rpm:libperl@19.2"}, + []string{"rpm:perl@19.2-r1 -> rpm:libperl@19.2"}), + expectedPackages: []string{"apk:node@19.2", "rpm:node@19.2-r1"}, + }, + { + name: "does not exclude if owning package is non-OS", + sbom: catalogWithOverlaps( + []string{"python:urllib3@1.2.3", "python:otherlib@1.2.3"}, + []string{"python:urllib3@1.2.3 -> python:otherlib@1.2.3"}), + expectedPackages: []string{"apk:node@19.2", "rpm:node@19.2-r1"}, + }, { name: "python bindings for system RPM install", sbom: withDistro(catalogWithOverlaps( @@ -713,6 +727,13 @@ func Test_RemoveBinaryPackagesByOverlap(t *testing.T) { []string{"rpm:python3-rpm@4.14.3-26.el8 -> python:rpm@4.14.3"}), "rhel"), expectedPackages: []string{"rpm:python3-rpm@4.14.3-26.el8"}, }, + { + name: "amzn linux doesn't remove packages in this way", + sbom: withDistro(catalogWithOverlaps( + []string{"rpm:python3-rpm@4.14.3-26.el8", "python:rpm@4.14.3"}, + []string{"rpm:python3-rpm@4.14.3-26.el8 -> python:rpm@4.14.3"}), "amzn"), + expectedPackages: []string{"rpm:python3-rpm@4.14.3-26.el8", "python:rpm@4.14.3"}, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) {