feat: detect when full license text has been provided and preserve as separate field (#3450)

* feat: add full text field to syft license struct
---------
Signed-off-by: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
Christopher Angelo Phillips
2025-05-01 15:00:46 -04:00
committed by GitHub
parent 4999de4114
commit 94e63eb367
23 changed files with 3282 additions and 426 deletions
+9 -8
View File
@@ -50,15 +50,16 @@ func (s *LicenseSet) Add(licenses ...License) {
s.set = make(map[artifact.ID]License)
}
for _, l := range licenses {
// we only want to add licenses that have a value
// we only want to add licenses that are not empty
if l.Empty() {
continue
}
// note, this check should be moved to the license constructor in the future
if l.Value != "" {
if id, merged, err := s.addToExisting(l); err == nil && !merged {
// doesn't exist, add it
s.set[id] = l
} else if err != nil {
log.Trace("license set failed to add license %#v: %+v", l, err)
}
if id, merged, err := s.addToExisting(l); err == nil && !merged {
// doesn't exist, add it
s.set[id] = l
} else if err != nil {
log.WithFields("error", err, "license", l).Trace("failed to add license to license set")
}
}
}