Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(redhat): include arch in PURL qualifiers #7654

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/fanal/analyzer/pkg/rpm/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ func (a *rpmArchiveAnalyzer) generatePURL(pkg *types.Package) *packageurl.Packag
case strings.Contains(vendor, "suse"):
ns = "suse"
}
return packageurl.NewPackageURL(packageurl.TypeRPM, ns, pkg.Name, utils.FormatVersion(*pkg), nil, "")
return packageurl.NewPackageURL(packageurl.TypeRPM, ns, pkg.Name, utils.FormatVersion(*pkg),
packageurl.Qualifiers{
{
Key: "arch",
Value: pkg.Arch,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure - does the Arch field always exist?
I'm worried about the case when pkg.Arch is missing. Then we'll see a case like pkg:rpm/redhat/[email protected]?arch="

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it doesn't happen, but I added a check just in case.

},
}, "")
}

func (a *rpmArchiveAnalyzer) unexpectedError(err error) error {
Expand Down
6 changes: 6 additions & 0 deletions pkg/fanal/analyzer/pkg/rpm/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ func Test_rpmArchiveAnalyzer_Analyze(t *testing.T) {
Namespace: "redhat",
Name: "socat",
Version: "1.7.3.2-2.el7",
Qualifiers: packageurl.Qualifiers{
{
Key: "arch",
Value: "x86_64",
},
},
},
},
},
Expand Down
Loading