Fix RPM DB license handling (#1184)

This commit is contained in:
Keith Zantow 2022-08-30 14:38:12 -04:00 committed by GitHub
parent ccc5a89226
commit a17ff7b555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -322,13 +322,17 @@ func extractMetadata(p *spdx.Package2_2, info pkgInfo) (pkg.MetadataType, interf
} else {
epoch = &converted
}
license := p.PackageLicenseDeclared
if license == "" {
license = p.PackageLicenseConcluded
}
return pkg.RpmdbMetadataType, pkg.RpmdbMetadata{
Name: p.PackageName,
Version: p.PackageVersion,
Epoch: epoch,
Arch: arch,
SourceRpm: upstreamValue,
License: p.PackageLicenseConcluded,
License: license,
Vendor: p.PackageOriginatorOrganization,
}
case pkg.DebPkg:

View File

@ -92,6 +92,10 @@ func newPkg(resolver source.FilePathResolver, dbLocation source.Location, entry
Metadata: metadata,
}
if entry.License != "" {
p.Licenses = append(p.Licenses, entry.License)
}
p.SetID()
return &p, nil
}

View File

@ -75,6 +75,7 @@ func TestParseRpmDB(t *testing.T) {
FoundBy: catalogerName,
Type: pkg.RpmPkg,
MetadataType: pkg.RpmdbMetadataType,
Licenses: []string{"MIT"},
Metadata: pkg.RpmdbMetadata{
Name: "dive",
Epoch: nil,
@ -102,6 +103,7 @@ func TestParseRpmDB(t *testing.T) {
FoundBy: catalogerName,
Type: pkg.RpmPkg,
MetadataType: pkg.RpmdbMetadataType,
Licenses: []string{"MIT"},
Metadata: pkg.RpmdbMetadata{
Name: "dive",
Epoch: nil,