mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 17:06:32 +01:00
feat: improve dpkg cataloger license recognition for "license agreements" (#3888)
This commit is contained in:
@@ -118,17 +118,24 @@ func addLicenses(ctx context.Context, resolver file.Resolver, dbLocation file.Lo
|
||||
|
||||
// get license information from the copyright file
|
||||
copyrightReader, copyrightLocation := fetchCopyrightContents(resolver, dbLocation, metadata)
|
||||
|
||||
var licenseStrs []string
|
||||
if copyrightReader != nil && copyrightLocation != nil {
|
||||
defer internal.CloseAndLogError(copyrightReader, copyrightLocation.AccessPath)
|
||||
// attach the licenses
|
||||
licenseStrs := parseLicensesFromCopyright(copyrightReader)
|
||||
licenseStrs = parseLicensesFromCopyright(copyrightReader)
|
||||
for _, licenseStr := range licenseStrs {
|
||||
p.Licenses.Add(pkg.NewLicenseFromLocationsWithContext(ctx, licenseStr, copyrightLocation.WithoutAnnotations()))
|
||||
}
|
||||
// keep a record of the file where this was discovered
|
||||
p.Locations.Add(*copyrightLocation)
|
||||
}
|
||||
// try to use the license classifier if parsing the copyright file failed
|
||||
if len(licenseStrs) == 0 {
|
||||
sr, sl := fetchCopyrightContents(resolver, dbLocation, metadata)
|
||||
if sr != nil && sl != nil {
|
||||
p.Licenses.Add(pkg.NewLicensesFromReadCloserWithContext(ctx, file.NewLocationReadCloser(*sl, sr))...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mergeFileListing(resolver file.Resolver, dbLocation file.Location, p *pkg.Package) {
|
||||
|
||||
Reference in New Issue
Block a user