mirror of
https://github.com/anchore/syft.git
synced 2026-02-13 19:16:43 +01:00
Fix RPM DB license handling (#1184)
This commit is contained in:
parent
ccc5a89226
commit
a17ff7b555
@ -322,13 +322,17 @@ func extractMetadata(p *spdx.Package2_2, info pkgInfo) (pkg.MetadataType, interf
|
|||||||
} else {
|
} else {
|
||||||
epoch = &converted
|
epoch = &converted
|
||||||
}
|
}
|
||||||
|
license := p.PackageLicenseDeclared
|
||||||
|
if license == "" {
|
||||||
|
license = p.PackageLicenseConcluded
|
||||||
|
}
|
||||||
return pkg.RpmdbMetadataType, pkg.RpmdbMetadata{
|
return pkg.RpmdbMetadataType, pkg.RpmdbMetadata{
|
||||||
Name: p.PackageName,
|
Name: p.PackageName,
|
||||||
Version: p.PackageVersion,
|
Version: p.PackageVersion,
|
||||||
Epoch: epoch,
|
Epoch: epoch,
|
||||||
Arch: arch,
|
Arch: arch,
|
||||||
SourceRpm: upstreamValue,
|
SourceRpm: upstreamValue,
|
||||||
License: p.PackageLicenseConcluded,
|
License: license,
|
||||||
Vendor: p.PackageOriginatorOrganization,
|
Vendor: p.PackageOriginatorOrganization,
|
||||||
}
|
}
|
||||||
case pkg.DebPkg:
|
case pkg.DebPkg:
|
||||||
|
|||||||
@ -92,6 +92,10 @@ func newPkg(resolver source.FilePathResolver, dbLocation source.Location, entry
|
|||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if entry.License != "" {
|
||||||
|
p.Licenses = append(p.Licenses, entry.License)
|
||||||
|
}
|
||||||
|
|
||||||
p.SetID()
|
p.SetID()
|
||||||
return &p, nil
|
return &p, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,6 +75,7 @@ func TestParseRpmDB(t *testing.T) {
|
|||||||
FoundBy: catalogerName,
|
FoundBy: catalogerName,
|
||||||
Type: pkg.RpmPkg,
|
Type: pkg.RpmPkg,
|
||||||
MetadataType: pkg.RpmdbMetadataType,
|
MetadataType: pkg.RpmdbMetadataType,
|
||||||
|
Licenses: []string{"MIT"},
|
||||||
Metadata: pkg.RpmdbMetadata{
|
Metadata: pkg.RpmdbMetadata{
|
||||||
Name: "dive",
|
Name: "dive",
|
||||||
Epoch: nil,
|
Epoch: nil,
|
||||||
@ -102,6 +103,7 @@ func TestParseRpmDB(t *testing.T) {
|
|||||||
FoundBy: catalogerName,
|
FoundBy: catalogerName,
|
||||||
Type: pkg.RpmPkg,
|
Type: pkg.RpmPkg,
|
||||||
MetadataType: pkg.RpmdbMetadataType,
|
MetadataType: pkg.RpmdbMetadataType,
|
||||||
|
Licenses: []string{"MIT"},
|
||||||
Metadata: pkg.RpmdbMetadata{
|
Metadata: pkg.RpmdbMetadata{
|
||||||
Name: "dive",
|
Name: "dive",
|
||||||
Epoch: nil,
|
Epoch: nil,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user