Skip to content

Commit

Permalink
fix: handle empty arch
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <[email protected]>
  • Loading branch information
knqyf263 committed Oct 7, 2024
1 parent f7ecbae commit 5e5f5c1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/fanal/analyzer/pkg/rpm/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +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),
packageurl.Qualifiers{
{
Key: "arch",
Value: pkg.Arch,
},
}, "")
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

0 comments on commit 5e5f5c1

Please sign in to comment.