diff --git a/internal/spdxlicense/license_list.go b/internal/spdxlicense/license_list.go index 0eba01eee..a32a0578b 100644 --- a/internal/spdxlicense/license_list.go +++ b/internal/spdxlicense/license_list.go @@ -1426,6 +1426,8 @@ var licenseIDs = map[string]string{ var urlToLicense = map[string]string{ "ftp://ftp.tin.org/pub/news/utils/newsx/newsx-1.6.tar.gz": "Zeeff", "http://apache.org/licenses/LICENSE-1.1": "Apache-1.1", + "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html": "LGPL-2.1-only", + "http://www.eclipse.org/org/documents/edl-v10.php": "BSD-3-Clause", "http://artlibre.org/licence/lal/licence-art-libre-12/": "LAL-1.2", "http://bits.netizen.com.au/licenses/NOSL/nosl.txt": "NOSL", "http://bzip.org/1.0.5/bzip2-manual-1.0.5.html": "bzip2-1.0.6", diff --git a/internal/spdxlicense/license_url_test.go b/internal/spdxlicense/license_url_test.go index be84e88f3..d4c8e92f7 100644 --- a/internal/spdxlicense/license_url_test.go +++ b/internal/spdxlicense/license_url_test.go @@ -53,6 +53,18 @@ func TestLicenseByURL(t *testing.T) { wantID: "", wantFound: false, }, + { + name: "EPL-1.0 license URL", + url: "http://www.eclipse.org/legal/epl-v10.html", + wantID: "EPL-1.0", + wantFound: true, + }, + { + name: "LGPL-2.1-only license URL", + url: "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html", + wantID: "LGPL-2.1-only", + wantFound: true, + }, { name: "Empty URL", url: "", diff --git a/syft/pkg/cataloger/java/archive_parser.go b/syft/pkg/cataloger/java/archive_parser.go index 382414d83..ffe731d89 100644 --- a/syft/pkg/cataloger/java/archive_parser.go +++ b/syft/pkg/cataloger/java/archive_parser.go @@ -25,6 +25,7 @@ import ( "github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg/cataloger/generic" "github.com/anchore/syft/syft/pkg/cataloger/java/internal/maven" + "github.com/anchore/syft/internal/spdxlicense" ) var archiveFormatGlobs = []string{ @@ -375,6 +376,11 @@ func toPkgLicenses(ctx context.Context, location *file.Location, licenses []mave if name == "" && url == "" { continue } + if licInfo, ok := spdxlicense.LicenseByURL(url); ok { + if name == "" { + name = licInfo.ID // use detected license ID if no name given + } + } out = append(out, pkg.NewLicenseFromFieldsWithContext(ctx, name, url, location)) } return out