Skip to content

Commit

Permalink
fix(redhat): include arch in PURL qualifiers [backport: release/v0.56] (
Browse files Browse the repository at this point in the history
#7702)

Signed-off-by: knqyf263 <knqyf263@gmail.com>
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
  • Loading branch information
aqua-bot and knqyf263 authored Oct 10, 2024
1 parent 25d2540 commit f6700ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 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,14 @@ 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, "")
var qualifiers packageurl.Qualifiers
if pkg.Arch != "" {
qualifiers = append(qualifiers, packageurl.Qualifier{
Key: "arch",
Value: pkg.Arch,
})
}
return packageurl.NewPackageURL(packageurl.TypeRPM, ns, pkg.Name, utils.FormatVersion(*pkg), qualifiers, "")
}

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

0 comments on commit f6700ec

Please sign in to comment.