mirror of
https://github.com/anchore/syft.git
synced 2026-11-26 13:44:11 +01:00
fix(java): preserve Eclipse Classpath license expressions (#5080)
* fix(java): preserve Eclipse Classpath license expressions Signed-off-by: Eljees <yurytumanov.r@yandex.ru> * chore: use tagged switch for quote handling in splitUnquoted Signed-off-by: Eljees <3.14hell@gmail.com> * Fix unquoted Apache license names in Java manifests Recognize the FreeMarker Bundle-License name as Apache-2.0 while preserving neighboring license clauses and parameters. Assisted-by: OpenAI Codex Signed-off-by: Eljees <3.14hell@gmail.com> --------- Signed-off-by: Eljees <yurytumanov.r@yandex.ru> Signed-off-by: Eljees <3.14hell@gmail.com>
This commit is contained in:
@@ -14,8 +14,15 @@ import (
|
||||
|
||||
const (
|
||||
LicenseRefPrefix = "LicenseRef-" // prefix for non-standard licenses
|
||||
epl2LicenseID = "EPL-2.0"
|
||||
)
|
||||
|
||||
var licenseExpressionsByURL = map[string]string{
|
||||
"projects.eclipse.org/license/secondary-gpl-2.0-cp": "GPL-2.0-only WITH Classpath-exception-2.0",
|
||||
"www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt": epl2LicenseID,
|
||||
"www.gnu.org/software/classpath/license.html": "GPL-2.0-only WITH Classpath-exception-2.0",
|
||||
}
|
||||
|
||||
//go:generate go run ./generate
|
||||
|
||||
// ID returns the canonical license ID for the given license ID
|
||||
@@ -53,6 +60,11 @@ func LicenseByURL(url string) (LicenseInfo, bool) {
|
||||
ID: id,
|
||||
}, true
|
||||
}
|
||||
if expression, exists := licenseExpressionsByURL[url]; exists {
|
||||
return LicenseInfo{
|
||||
ID: expression,
|
||||
}, true
|
||||
}
|
||||
if normalized, ok := normalizeOpenSourceOrgURL(url); ok {
|
||||
if id, exists := openSourceOrgURLToLicense[normalized]; exists {
|
||||
return LicenseInfo{
|
||||
|
||||
@@ -41,6 +41,24 @@ func TestLicenseByURL(t *testing.T) {
|
||||
wantID: "BSD-3-Clause",
|
||||
wantFound: true,
|
||||
},
|
||||
{
|
||||
name: "GNU Classpath Exception URL",
|
||||
url: "https://www.gnu.org/software/classpath/license.html",
|
||||
wantID: "GPL-2.0-only WITH Classpath-exception-2.0",
|
||||
wantFound: true,
|
||||
},
|
||||
{
|
||||
name: "Eclipse secondary GPL Classpath URL",
|
||||
url: "https://projects.eclipse.org/license/secondary-gpl-2.0-cp",
|
||||
wantID: "GPL-2.0-only WITH Classpath-exception-2.0",
|
||||
wantFound: true,
|
||||
},
|
||||
{
|
||||
name: "Eclipse Public License legacy URL",
|
||||
url: "https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt",
|
||||
wantID: "EPL-2.0",
|
||||
wantFound: true,
|
||||
},
|
||||
{
|
||||
name: "URL with trailing whitespace",
|
||||
url: " http://opensource.org/licenses/MIT ",
|
||||
|
||||
Reference in New Issue
Block a user