Skip to content

Commit

Permalink
fix(redhat): include arch in PURL qualifiers (aquasecurity#7654)
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <knqyf263@gmail.com>
  • Loading branch information
knqyf263 authored Oct 7, 2024
1 parent 015bb88 commit a585e95
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 a585e95

Please sign in to comment.