From 72616db81f46d0fa4673649e77c18b10c5f86452 Mon Sep 17 00:00:00 2001 From: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:21:29 -0400 Subject: [PATCH] fix: "or-later" suffix updated to consider deprecated "+" operator (#1907) * fix: or-later suffix has been updated to consider deprecated + If a given license has the suffix "or-later" it previously could have been considered or represented with a "+". Example "GFDL-1.0-or-later" could have been represented as "GFDL-1.0+". This PR allows the license list generation to consider "or-later" as == to "+" when generating permutations for upgrading deprecated licenses. --------- Signed-off-by: Christopher Phillips --- .../generate/generate_license_list_test.go | 27 +++++++++++++++++ internal/spdxlicense/generate/license.go | 7 ++++- internal/spdxlicense/generate/license_test.go | 3 ++ internal/spdxlicense/license_list.go | 29 ++++++++++++++++++- internal/spdxlicense/license_list_test.go | 1 + 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/internal/spdxlicense/generate/generate_license_list_test.go b/internal/spdxlicense/generate/generate_license_list_test.go index 92ded1d48df..978f5eaf60f 100644 --- a/internal/spdxlicense/generate/generate_license_list_test.go +++ b/internal/spdxlicense/generate/generate_license_list_test.go @@ -81,8 +81,11 @@ func Test_processSPDXLicense(t *testing.T) { "afl3.0.0": "AFL-3.0", "afmparse": "Afmparse", "agpl1": "AGPL-1.0-only", + "agpl1+": "AGPL-1.0-or-later", "agpl1.0": "AGPL-1.0-only", + "agpl1.0+": "AGPL-1.0-or-later", "agpl1.0.0": "AGPL-1.0-only", + "agpl1.0.0+": "AGPL-1.0-or-later", "agpl1.0.0only": "AGPL-1.0-only", "agpl1.0.0orlater": "AGPL-1.0-or-later", "agpl1.0only": "AGPL-1.0-only", @@ -90,8 +93,11 @@ func Test_processSPDXLicense(t *testing.T) { "agpl1only": "AGPL-1.0-only", "agpl1orlater": "AGPL-1.0-or-later", "agpl3": "AGPL-3.0-only", + "agpl3+": "AGPL-3.0-or-later", "agpl3.0": "AGPL-3.0-only", + "agpl3.0+": "AGPL-3.0-or-later", "agpl3.0.0": "AGPL-3.0-only", + "agpl3.0.0+": "AGPL-3.0-or-later", "agpl3.0.0only": "AGPL-3.0-only", "agpl3.0.0orlater": "AGPL-3.0-or-later", "agpl3.0only": "AGPL-3.0-only", @@ -548,8 +554,17 @@ func Test_processSPDXLicense(t *testing.T) { "ftl": "FTL", "gd": "GD", "gfdl1": "GFDL-1.1-only", + "gfdl1+": "GFDL-1.1-or-later", + "gfdl1+invariants": "GFDL-1.1-invariants-or-later", + "gfdl1+noinvariants": "GFDL-1.1-no-invariants-or-later", "gfdl1.1": "GFDL-1.1-only", + "gfdl1.1+": "GFDL-1.1-or-later", + "gfdl1.1+invariants": "GFDL-1.1-invariants-or-later", + "gfdl1.1+noinvariants": "GFDL-1.1-no-invariants-or-later", "gfdl1.1.0": "GFDL-1.1-only", + "gfdl1.1.0+": "GFDL-1.1-or-later", + "gfdl1.1.0+invariants": "GFDL-1.1-invariants-or-later", + "gfdl1.1.0+noinvariants": "GFDL-1.1-no-invariants-or-later", "gfdl1.1.0invariantsonly": "GFDL-1.1-invariants-only", "gfdl1.1.0invariantsorlater": "GFDL-1.1-invariants-or-later", "gfdl1.1.0noinvariantsonly": "GFDL-1.1-no-invariants-only", @@ -563,7 +578,13 @@ func Test_processSPDXLicense(t *testing.T) { "gfdl1.1only": "GFDL-1.1-only", "gfdl1.1orlater": "GFDL-1.1-or-later", "gfdl1.2": "GFDL-1.2-only", + "gfdl1.2+": "GFDL-1.2-or-later", + "gfdl1.2+invariants": "GFDL-1.2-invariants-or-later", + "gfdl1.2+noinvariants": "GFDL-1.2-no-invariants-or-later", "gfdl1.2.0": "GFDL-1.2-only", + "gfdl1.2.0+": "GFDL-1.2-or-later", + "gfdl1.2.0+invariants": "GFDL-1.2-invariants-or-later", + "gfdl1.2.0+noinvariants": "GFDL-1.2-no-invariants-or-later", "gfdl1.2.0invariantsonly": "GFDL-1.2-invariants-only", "gfdl1.2.0invariantsorlater": "GFDL-1.2-invariants-or-later", "gfdl1.2.0noinvariantsonly": "GFDL-1.2-no-invariants-only", @@ -577,7 +598,13 @@ func Test_processSPDXLicense(t *testing.T) { "gfdl1.2only": "GFDL-1.2-only", "gfdl1.2orlater": "GFDL-1.2-or-later", "gfdl1.3": "GFDL-1.3-only", + "gfdl1.3+": "GFDL-1.3-or-later", + "gfdl1.3+invariants": "GFDL-1.3-invariants-or-later", + "gfdl1.3+noinvariants": "GFDL-1.3-no-invariants-or-later", "gfdl1.3.0": "GFDL-1.3-only", + "gfdl1.3.0+": "GFDL-1.3-or-later", + "gfdl1.3.0+invariants": "GFDL-1.3-invariants-or-later", + "gfdl1.3.0+noinvariants": "GFDL-1.3-no-invariants-or-later", "gfdl1.3.0invariantsonly": "GFDL-1.3-invariants-only", "gfdl1.3.0invariantsorlater": "GFDL-1.3-invariants-or-later", "gfdl1.3.0noinvariantsonly": "GFDL-1.3-no-invariants-only", diff --git a/internal/spdxlicense/generate/license.go b/internal/spdxlicense/generate/license.go index d61b1a6906b..43806740822 100644 --- a/internal/spdxlicense/generate/license.go +++ b/internal/spdxlicense/generate/license.go @@ -77,11 +77,16 @@ func (l License) canReplace(deprecated License) bool { func buildLicenseIDPermutations(cleanID string) (perms []string) { lv := findLicenseVersion(cleanID) + addPlusPermutation := strings.HasSuffix(cleanID, "orlater") vp := versionPermutations(lv) - permSet := strset.New() version := strings.Join(lv, ".") for _, p := range vp { + if addPlusPermutation { + base := strings.TrimSuffix(cleanID, "orlater") + plus := p + "+" + permSet.Add(strings.Replace(base, version, plus, 1)) + } permSet.Add(strings.Replace(cleanID, version, p, 1)) } diff --git a/internal/spdxlicense/generate/license_test.go b/internal/spdxlicense/generate/license_test.go index 50a4dbacfcb..410478170d9 100644 --- a/internal/spdxlicense/generate/license_test.go +++ b/internal/spdxlicense/generate/license_test.go @@ -94,6 +94,9 @@ func TestLicensePermutations(t *testing.T) { "gpl3orlater", "gpl3.0orlater", "gpl3.0.0orlater", + "gpl3.0.0+", + "gpl3.0+", + "gpl3+", }, }, { diff --git a/internal/spdxlicense/license_list.go b/internal/spdxlicense/license_list.go index 29db460f8da..8ffa768c188 100644 --- a/internal/spdxlicense/license_list.go +++ b/internal/spdxlicense/license_list.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// This file was generated by robots at 2023-06-20 11:37:07.979104 -0400 EDT m=+0.478800893 +// This file was generated by robots at 2023-07-11 11:55:35.533815 -0400 EDT m=+0.695308614 // using data from https://spdx.org/licenses/licenses.json package spdxlicense @@ -30,8 +30,11 @@ var licenseIDs = map[string]string{ "afl3.0.0": "AFL-3.0", "afmparse": "Afmparse", "agpl1": "AGPL-1.0-only", + "agpl1+": "AGPL-1.0-or-later", "agpl1.0": "AGPL-1.0-only", + "agpl1.0+": "AGPL-1.0-or-later", "agpl1.0.0": "AGPL-1.0-only", + "agpl1.0.0+": "AGPL-1.0-or-later", "agpl1.0.0only": "AGPL-1.0-only", "agpl1.0.0orlater": "AGPL-1.0-or-later", "agpl1.0only": "AGPL-1.0-only", @@ -39,8 +42,11 @@ var licenseIDs = map[string]string{ "agpl1only": "AGPL-1.0-only", "agpl1orlater": "AGPL-1.0-or-later", "agpl3": "AGPL-3.0-only", + "agpl3+": "AGPL-3.0-or-later", "agpl3.0": "AGPL-3.0-only", + "agpl3.0+": "AGPL-3.0-or-later", "agpl3.0.0": "AGPL-3.0-only", + "agpl3.0.0+": "AGPL-3.0-or-later", "agpl3.0.0only": "AGPL-3.0-only", "agpl3.0.0orlater": "AGPL-3.0-or-later", "agpl3.0only": "AGPL-3.0-only", @@ -507,8 +513,17 @@ var licenseIDs = map[string]string{ "ftl": "FTL", "gd": "GD", "gfdl1": "GFDL-1.1-only", + "gfdl1+": "GFDL-1.1-or-later", + "gfdl1+invariants": "GFDL-1.1-invariants-or-later", + "gfdl1+noinvariants": "GFDL-1.1-no-invariants-or-later", "gfdl1.1": "GFDL-1.1-only", + "gfdl1.1+": "GFDL-1.1-or-later", + "gfdl1.1+invariants": "GFDL-1.1-invariants-or-later", + "gfdl1.1+noinvariants": "GFDL-1.1-no-invariants-or-later", "gfdl1.1.0": "GFDL-1.1-only", + "gfdl1.1.0+": "GFDL-1.1-or-later", + "gfdl1.1.0+invariants": "GFDL-1.1-invariants-or-later", + "gfdl1.1.0+noinvariants": "GFDL-1.1-no-invariants-or-later", "gfdl1.1.0invariantsonly": "GFDL-1.1-invariants-only", "gfdl1.1.0invariantsorlater": "GFDL-1.1-invariants-or-later", "gfdl1.1.0noinvariantsonly": "GFDL-1.1-no-invariants-only", @@ -522,7 +537,13 @@ var licenseIDs = map[string]string{ "gfdl1.1only": "GFDL-1.1-only", "gfdl1.1orlater": "GFDL-1.1-or-later", "gfdl1.2": "GFDL-1.2-only", + "gfdl1.2+": "GFDL-1.2-or-later", + "gfdl1.2+invariants": "GFDL-1.2-invariants-or-later", + "gfdl1.2+noinvariants": "GFDL-1.2-no-invariants-or-later", "gfdl1.2.0": "GFDL-1.2-only", + "gfdl1.2.0+": "GFDL-1.2-or-later", + "gfdl1.2.0+invariants": "GFDL-1.2-invariants-or-later", + "gfdl1.2.0+noinvariants": "GFDL-1.2-no-invariants-or-later", "gfdl1.2.0invariantsonly": "GFDL-1.2-invariants-only", "gfdl1.2.0invariantsorlater": "GFDL-1.2-invariants-or-later", "gfdl1.2.0noinvariantsonly": "GFDL-1.2-no-invariants-only", @@ -536,7 +557,13 @@ var licenseIDs = map[string]string{ "gfdl1.2only": "GFDL-1.2-only", "gfdl1.2orlater": "GFDL-1.2-or-later", "gfdl1.3": "GFDL-1.3-only", + "gfdl1.3+": "GFDL-1.3-or-later", + "gfdl1.3+invariants": "GFDL-1.3-invariants-or-later", + "gfdl1.3+noinvariants": "GFDL-1.3-no-invariants-or-later", "gfdl1.3.0": "GFDL-1.3-only", + "gfdl1.3.0+": "GFDL-1.3-or-later", + "gfdl1.3.0+invariants": "GFDL-1.3-invariants-or-later", + "gfdl1.3.0+noinvariants": "GFDL-1.3-no-invariants-or-later", "gfdl1.3.0invariantsonly": "GFDL-1.3-invariants-only", "gfdl1.3.0invariantsorlater": "GFDL-1.3-invariants-or-later", "gfdl1.3.0noinvariantsonly": "GFDL-1.3-no-invariants-only", diff --git a/internal/spdxlicense/license_list_test.go b/internal/spdxlicense/license_list_test.go index e50111023f9..a0723cb5973 100644 --- a/internal/spdxlicense/license_list_test.go +++ b/internal/spdxlicense/license_list_test.go @@ -12,5 +12,6 @@ func TestLicenceListIDs(t *testing.T) { assert.Equal(t, "ZPL-2.1", licenseIDs["zpl2.1"]) assert.Equal(t, "GPL-2.0-only", licenseIDs["gpl2"]) assert.Equal(t, "GPL-2.0-or-later", licenseIDs["gpl2+"]) + assert.Equal(t, "GFDL-1.2-or-later", licenseIDs["gfdl1.2+"]) assert.NotEmpty(t, Version) }