Skip to content

Commit

Permalink
Fix RPM DB license handling (anchore#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
kzantow authored and aiwantaozi committed Oct 20, 2022
1 parent dbd4d42 commit 8e5e441
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/formats/common/spdxhelpers/to_syft_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions syft/pkg/cataloger/rpmdb/parse_rpmdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions syft/pkg/cataloger/rpmdb/parse_rpmdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8e5e441

Please # to comment.