From 8a7f08e2c8508642c7cc862715cd1bbb0f6e6759 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mon, 3 Jun 2024 10:18:52 -0400 Subject: [PATCH] Use redhat as namespace for redhat rpms (#2914) The namespace value of `redhat` signifies this as an RPM package produced and distributed by Red Hat. Using "rhel" in the namespace is not correct. Signed-off-by: Ralph Bean --- syft/pkg/cataloger/redhat/package.go | 3 +++ syft/pkg/cataloger/redhat/package_test.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/syft/pkg/cataloger/redhat/package.go b/syft/pkg/cataloger/redhat/package.go index 23954991a..8bbcfe9a0 100644 --- a/syft/pkg/cataloger/redhat/package.go +++ b/syft/pkg/cataloger/redhat/package.go @@ -89,6 +89,9 @@ func packageURL(name, arch string, epoch *int, srpm string, version, release str if distro != nil { namespace = distro.ID } + if namespace == "rhel" { + namespace = "redhat" + } qualifiers := map[string]string{} diff --git a/syft/pkg/cataloger/redhat/package_test.go b/syft/pkg/cataloger/redhat/package_test.go index b5459717a..cc24d7d48 100644 --- a/syft/pkg/cataloger/redhat/package_test.go +++ b/syft/pkg/cataloger/redhat/package_test.go @@ -28,7 +28,7 @@ func Test_packageURL(t *testing.T) { Release: "r", Epoch: nil, }, - expected: "pkg:rpm/rhel/p@v-r?distro=rhel-8.4", + expected: "pkg:rpm/redhat/p@v-r?distro=rhel-8.4", }, { name: "with arch and epoch", @@ -67,7 +67,7 @@ func Test_packageURL(t *testing.T) { Release: "r", SourceRpm: "sourcerpm", }, - expected: "pkg:rpm/rhel/p@v-r?upstream=sourcerpm&distro=rhel-8.4", + expected: "pkg:rpm/redhat/p@v-r?upstream=sourcerpm&distro=rhel-8.4", }, }