Skip to content

Commit 13b24d6

Browse files
committed
feat(spdx-utils)!: Remove simple license mappings without matching digits
But tolerate differences in trailing zeros. This makes simple license mapping more trustworthy by removing cases that were already identified to be ambiguous with one exception: `ALv2: Apache-2.0` is accepted as non-ambiguous now. However, 12 other licenses are removed for beign ambiguous now, as they do not contain sufficient indicators for the version of the license or variant. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 2722702 commit 13b24d6

File tree

5 files changed

+24
-48
lines changed

5 files changed

+24
-48
lines changed

plugins/package-managers/node/src/funTest/assets/projects/synthetic/npm/project-with-lockfile-expected-output.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,8 @@ packages:
311311
declared_licenses:
312312
- "BSD-like"
313313
declared_licenses_processed:
314-
spdx_expression: "BSD-3-Clause"
315-
mapped:
316-
BSD-like: "BSD-3-Clause"
314+
unmapped:
315+
- "BSD-like"
317316
description: "a CSS selector compiler/engine"
318317
homepage_url: "https://github.com/fb55/css-select#readme"
319318
binary_artifact:

plugins/package-managers/node/src/funTest/assets/projects/synthetic/npm/shrinkwrap-expected-output.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,8 @@ packages:
300300
declared_licenses:
301301
- "BSD-like"
302302
declared_licenses_processed:
303-
spdx_expression: "BSD-3-Clause"
304-
mapped:
305-
BSD-like: "BSD-3-Clause"
303+
unmapped:
304+
- "BSD-like"
306305
description: "a CSS selector compiler/engine"
307306
homepage_url: "https://github.com/fb55/css-select#readme"
308307
binary_artifact:

plugins/package-managers/node/src/funTest/assets/projects/synthetic/npm/shrinkwrap-skip-excluded-scopes-expected-output.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,8 @@ packages:
172172
declared_licenses:
173173
- "BSD-like"
174174
declared_licenses_processed:
175-
spdx_expression: "BSD-3-Clause"
176-
mapped:
177-
BSD-like: "BSD-3-Clause"
175+
unmapped:
176+
- "BSD-like"
178177
description: "a CSS selector compiler/engine"
179178
homepage_url: "https://github.com/fb55/css-select#readme"
180179
binary_artifact:

utils/spdx/src/main/resources/simple-license-mapping.yml

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,8 @@
2222
# Sort the entries below via IntelliJ's "Edit" -> "Sort Lines".
2323
---
2424

25-
# Ambiguous mappings (mapping reason not obvious without additional information)
26-
ALv2: Apache-2.0
27-
ASL: Apache-2.0
28-
Apache-style: Apache-2.0
29-
Apache: Apache-2.0
30-
BSD-like: BSD-3-Clause
31-
BSD-style: BSD-3-Clause
32-
BSD: BSD-3-Clause
33-
GPL: GPL-2.0-or-later
34-
MPL: MPL-2.0
35-
afl: AFL-3.0
36-
agpl: AGPL-3.0-or-later
37-
apache-license: Apache-2.0
38-
bsd-license: BSD-3-Clause
39-
bsd-licensed: BSD-3-Clause
40-
cddl: CDDL-1.0
41-
efl: EFL-2.0
42-
epl: EPL-1.0
43-
eupl: EUPL-1.0
44-
fdl: GFDL-1.3-or-later
45-
gfdl: GFDL-1.3-or-later
46-
gpl-license: GPL-2.0-or-later
47-
psf: PSF-2.0
48-
psfl: PSF-2.0
49-
python: Python-2.0
50-
51-
# Non-ambiguous mappings
5225
AFLv2.1: AFL-2.1
26+
ALv2: Apache-2.0
5327
APACHEv2: Apache-2.0
5428
APL2: Apache-2.0
5529
APLv2.0: Apache-2.0
@@ -59,11 +33,7 @@ Apache2: Apache-2.0
5933
BSD-3: BSD-3-Clause
6034
BSD2: BSD-2-Clause
6135
BSD3: BSD-3-Clause
62-
Boost: BSL-1.0
6336
Bouncy: MIT
64-
CC0: CC0-1.0
65-
CPL: CPL-1.0
66-
CeCILL: CECILL-1.1
6737
EDL-1.0: BSD-3-Clause
6838
FreeBSD: BSD-2-Clause-Views
6939
GPL-2: GPL-2.0-only
@@ -74,31 +44,24 @@ GPLv3+: GPL-3.0-or-later
7444
GPLv3: GPL-3.0-only
7545
ISCL: ISC
7646
LGPL-3: LGPL-3.0-only
77-
LGPL2: LGPL-2.1-only
7847
LGPL3: LGPL-3.0-only
79-
LGPL: LGPL-2.0-or-later
80-
LGPLv2: LGPL-2.1-only
8148
LGPLv3+: LGPL-3.0-or-later
8249
LGPLv3: LGPL-3.0-only
8350
MIT-like: MIT
8451
MIT-style: MIT
8552
MPLv2.0: MPL-2.0
8653
MPLv2: MPL-2.0
87-
ODBL: ODbL-1.0
8854
PSF2: PSF-2.0
8955
UNLICENSED: Unlicense
9056
Unlicence: Unlicense
91-
Vovida: VSL-1.0
9257
afl-2: AFL-2.0
9358
afl2.0: AFL-2.0
9459
afl2.1: AFL-2.1
9560
afl2: AFL-2.0
9661
bouncy-license: MIT
9762
bsl1.0: BSL-1.0
98-
bsl: BSL-1.0
9963
cddl1.0: CDDL-1.0
10064
cddl1.1: CDDL-1.1
101-
cpal: CPAL-1.0
10265
epl1.0: EPL-1.0
10366
epl2.0: EPL-2.0
10467
eupl1.0: EUPL-1.0
@@ -113,4 +76,3 @@ mpl2.0: MPL-2.0
11376
mpl2: MPL-2.0
11477
w3cl: W3C
11578
wtf: WTFPL
116-
zope: ZPL-2.1

utils/spdx/src/test/kotlin/SpdxSimpleLicenseMappingTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ class SpdxSimpleLicenseMappingTest : WordSpec({
5757
if (license.id.endsWith("-only")) key should containADigit()
5858
}
5959
}
60+
61+
"contain matching digits disregarding trailing zeros" {
62+
val exceptions = mapOf(
63+
// See https://www.eclipse.org/org/documents/edl-v10.php.
64+
"EDL-1.0" to SpdxLicense.BSD_3_CLAUSE,
65+
// See https://spdx.org/licenses/BSD-2-Clause-Views.html.
66+
"FreeBSD" to SpdxLicense.BSD_2_CLAUSE_VIEWS
67+
)
68+
69+
SpdxSimpleLicenseMapping.simpleLicenseMapping.filterNot {
70+
it in exceptions.entries
71+
}.forAll { (key, license) ->
72+
val digitsInKey = key.filter { it.isDigit() }.dropLastWhile { it == '0' }
73+
val digitsInLicense = license.id.filter { it.isDigit() }.dropLastWhile { it == '0' }
74+
digitsInKey shouldBe digitsInLicense
75+
}
76+
}
6077
}
6178

6279
"The simple expression mapping" should {

0 commit comments

Comments
 (0)