Skip to content

Commit b80eb1b

Browse files
committed
feat(spdx-reporter): Report detected root licenses for packages
The SPDX `licenseDeclared` field for a package [1] is not a declared license in the ORT sense (which means that it must originate from package metadata only), but should list any "licenses that have been declared by the authors of the package" in any way, including as part of a `LICENSE` file, which in the ORT sense would be a detected license. To account for that, also use licenses detected in root license files as licenses "declared" for the package. This solves the concrete case for Go packages that so far did not have any `licenseDeclared` set, as they are just pointers to Git repositories which have no metadata associated. [1]: https://spdx.github.io/spdx-spec/v2.2.2/package-information/#715-declared-license-field Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent b4b43cf commit b80eb1b

File tree

4 files changed

+66
-57
lines changed

4 files changed

+66
-57
lines changed

plugins/reporters/spdx/src/funTest/assets/disclosure-cli-expected-output.spdx.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ packages:
3232
filesAnalyzed: false
3333
homepage: "NONE"
3434
licenseConcluded: "NOASSERTION"
35-
licenseDeclared: "NOASSERTION"
35+
licenseDeclared: "MIT"
3636
name: "github.com/mercedes-benz/disclosure-cli"
3737
summary: "NONE"
3838
versionInfo: "388ae2bdf6032a3d5b0ed06ac45267dfc0376a3d"
@@ -46,7 +46,7 @@ packages:
4646
filesAnalyzed: false
4747
homepage: "NONE"
4848
licenseConcluded: "NOASSERTION"
49-
licenseDeclared: "NOASSERTION"
49+
licenseDeclared: "(Apache-2.0 OR MIT) AND MIT"
5050
name: "github.com/BurntSushi/toml"
5151
summary: "NONE"
5252
versionInfo: "1.4.0"
@@ -60,7 +60,7 @@ packages:
6060
filesAnalyzed: false
6161
homepage: "NONE"
6262
licenseConcluded: "NOASSERTION"
63-
licenseDeclared: "NOASSERTION"
63+
licenseDeclared: "(Apache-2.0 OR MIT) AND MIT"
6464
name: "github.com/BurntSushi/toml"
6565
summary: "NONE"
6666
versionInfo: "1.4.0"
@@ -74,7 +74,7 @@ packages:
7474
filesAnalyzed: false
7575
homepage: "NONE"
7676
licenseConcluded: "NOASSERTION"
77-
licenseDeclared: "NOASSERTION"
77+
licenseDeclared: "ISC"
7878
name: "github.com/davecgh/go-spew"
7979
summary: "NONE"
8080
versionInfo: "1.1.1"
@@ -88,7 +88,7 @@ packages:
8888
filesAnalyzed: false
8989
homepage: "NONE"
9090
licenseConcluded: "NOASSERTION"
91-
licenseDeclared: "NOASSERTION"
91+
licenseDeclared: "ISC"
9292
name: "github.com/davecgh/go-spew"
9393
summary: "NONE"
9494
versionInfo: "1.1.1"
@@ -102,7 +102,7 @@ packages:
102102
filesAnalyzed: false
103103
homepage: "NONE"
104104
licenseConcluded: "NOASSERTION"
105-
licenseDeclared: "NOASSERTION"
105+
licenseDeclared: "Apache-2.0"
106106
name: "github.com/inconshreveable/mousetrap"
107107
summary: "NONE"
108108
versionInfo: "1.1.0"
@@ -116,7 +116,7 @@ packages:
116116
filesAnalyzed: false
117117
homepage: "NONE"
118118
licenseConcluded: "NOASSERTION"
119-
licenseDeclared: "NOASSERTION"
119+
licenseDeclared: "Apache-2.0"
120120
name: "github.com/inconshreveable/mousetrap"
121121
summary: "NONE"
122122
versionInfo: "1.1.0"
@@ -130,7 +130,7 @@ packages:
130130
filesAnalyzed: false
131131
homepage: "NONE"
132132
licenseConcluded: "NOASSERTION"
133-
licenseDeclared: "NOASSERTION"
133+
licenseDeclared: "MIT"
134134
name: "github.com/jinzhu/configor"
135135
summary: "NONE"
136136
versionInfo: "1.2.2"
@@ -144,7 +144,7 @@ packages:
144144
filesAnalyzed: false
145145
homepage: "NONE"
146146
licenseConcluded: "NOASSERTION"
147-
licenseDeclared: "NOASSERTION"
147+
licenseDeclared: "MIT"
148148
name: "github.com/jinzhu/configor"
149149
summary: "NONE"
150150
versionInfo: "1.2.2"
@@ -158,7 +158,7 @@ packages:
158158
filesAnalyzed: false
159159
homepage: "NONE"
160160
licenseConcluded: "NOASSERTION"
161-
licenseDeclared: "NOASSERTION"
161+
licenseDeclared: "BSD-3-Clause"
162162
name: "github.com/pmezard/go-difflib"
163163
summary: "NONE"
164164
versionInfo: "1.0.0"
@@ -172,7 +172,7 @@ packages:
172172
filesAnalyzed: false
173173
homepage: "NONE"
174174
licenseConcluded: "NOASSERTION"
175-
licenseDeclared: "NOASSERTION"
175+
licenseDeclared: "BSD-3-Clause"
176176
name: "github.com/pmezard/go-difflib"
177177
summary: "NONE"
178178
versionInfo: "1.0.0"
@@ -186,7 +186,7 @@ packages:
186186
filesAnalyzed: false
187187
homepage: "NONE"
188188
licenseConcluded: "NOASSERTION"
189-
licenseDeclared: "NOASSERTION"
189+
licenseDeclared: "Apache-2.0"
190190
name: "github.com/spf13/cobra"
191191
summary: "NONE"
192192
versionInfo: "1.8.1"
@@ -200,7 +200,7 @@ packages:
200200
filesAnalyzed: false
201201
homepage: "NONE"
202202
licenseConcluded: "NOASSERTION"
203-
licenseDeclared: "NOASSERTION"
203+
licenseDeclared: "Apache-2.0"
204204
name: "github.com/spf13/cobra"
205205
summary: "NONE"
206206
versionInfo: "1.8.1"
@@ -215,7 +215,7 @@ packages:
215215
filesAnalyzed: false
216216
homepage: "NONE"
217217
licenseConcluded: "NOASSERTION"
218-
licenseDeclared: "NOASSERTION"
218+
licenseDeclared: "BSD-3-Clause"
219219
name: "github.com/spf13/pflag"
220220
summary: "NONE"
221221
versionInfo: "1.0.5"
@@ -230,7 +230,7 @@ packages:
230230
filesAnalyzed: false
231231
homepage: "NONE"
232232
licenseConcluded: "NOASSERTION"
233-
licenseDeclared: "NOASSERTION"
233+
licenseDeclared: "BSD-3-Clause"
234234
name: "github.com/spf13/pflag"
235235
summary: "NONE"
236236
versionInfo: "1.0.5"
@@ -244,7 +244,7 @@ packages:
244244
filesAnalyzed: false
245245
homepage: "NONE"
246246
licenseConcluded: "NOASSERTION"
247-
licenseDeclared: "NOASSERTION"
247+
licenseDeclared: "MIT"
248248
name: "github.com/stretchr/testify"
249249
summary: "NONE"
250250
versionInfo: "1.8.2"
@@ -258,7 +258,7 @@ packages:
258258
filesAnalyzed: false
259259
homepage: "NONE"
260260
licenseConcluded: "NOASSERTION"
261-
licenseDeclared: "NOASSERTION"
261+
licenseDeclared: "MIT"
262262
name: "github.com/stretchr/testify"
263263
summary: "NONE"
264264
versionInfo: "1.8.2"
@@ -273,7 +273,7 @@ packages:
273273
filesAnalyzed: false
274274
homepage: "NONE"
275275
licenseConcluded: "NOASSERTION"
276-
licenseDeclared: "NOASSERTION"
276+
licenseDeclared: "Apache-2.0 AND Apache-2.0 AND Apache-2.0 AND MIT AND MIT AND MIT"
277277
name: "gopkg.in/yaml.v3"
278278
summary: "NONE"
279279
versionInfo: "3.0.1"
@@ -288,7 +288,7 @@ packages:
288288
filesAnalyzed: false
289289
homepage: "NONE"
290290
licenseConcluded: "NOASSERTION"
291-
licenseDeclared: "NOASSERTION"
291+
licenseDeclared: "Apache-2.0 AND Apache-2.0 AND Apache-2.0 AND MIT AND MIT AND MIT"
292292
name: "gopkg.in/yaml.v3"
293293
summary: "NONE"
294294
versionInfo: "3.0.1"

plugins/reporters/spdx/src/funTest/assets/spdx-document-reporter-expected-output.spdx.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"filesAnalyzed" : false,
4747
"homepage" : "first package's homepage URL",
4848
"licenseConcluded" : "BSD-2-Clause AND BSD-3-Clause AND MIT",
49-
"licenseDeclared" : "BSD-3-Clause AND (MIT OR GPL-2.0-only)",
49+
"licenseDeclared" : "Apache-2.0 AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only OR MIT) AND MIT AND MIT AND MIT",
5050
"name" : "first-package",
5151
"summary" : "A package with all supported attributes set, with a VCS URL containing a user name, and with two scan results for the VCS containing copyright findings matched to a license finding.",
5252
"versionInfo" : "0.0.1"
@@ -63,7 +63,7 @@
6363
"hasFiles" : [ "SPDXRef-File-1" ],
6464
"homepage" : "first package's homepage URL",
6565
"licenseConcluded" : "NOASSERTION",
66-
"licenseDeclared" : "BSD-3-Clause AND (MIT OR GPL-2.0-only)",
66+
"licenseDeclared" : "Apache-2.0 AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only OR MIT) AND MIT AND MIT AND MIT",
6767
"licenseInfoFromFiles" : [ "Apache-2.0", "BSD-2-Clause" ],
6868
"name" : "first-package",
6969
"packageVerificationCode" : {
@@ -87,7 +87,7 @@
8787
"filesAnalyzed" : false,
8888
"homepage" : "first package's homepage URL",
8989
"licenseConcluded" : "NOASSERTION",
90-
"licenseDeclared" : "BSD-3-Clause AND (MIT OR GPL-2.0-only)",
90+
"licenseDeclared" : "Apache-2.0 AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only OR MIT) AND MIT AND MIT AND MIT",
9191
"name" : "first-package",
9292
"summary" : "A package with all supported attributes set, with a VCS URL containing a user name, and with two scan results for the VCS containing copyright findings matched to a license finding.",
9393
"versionInfo" : "0.0.1"
@@ -103,7 +103,7 @@
103103
"filesAnalyzed" : false,
104104
"homepage" : "NONE",
105105
"licenseConcluded" : "NOASSERTION",
106-
"licenseDeclared" : "MIT AND NOASSERTION",
106+
"licenseDeclared" : "MIT",
107107
"name" : "fourth-package",
108108
"summary" : "A package with partially mapped declared license.",
109109
"versionInfo" : "0.0.1"
@@ -119,7 +119,7 @@
119119
"filesAnalyzed" : false,
120120
"homepage" : "NONE",
121121
"licenseConcluded" : "NOASSERTION",
122-
"licenseDeclared" : "NOASSERTION",
122+
"licenseDeclared" : "NONE",
123123
"name" : "second-package",
124124
"summary" : "A package with minimal attributes set.",
125125
"versionInfo" : "0.0.1"
@@ -135,7 +135,7 @@
135135
"filesAnalyzed" : false,
136136
"homepage" : "NONE",
137137
"licenseConcluded" : "NOASSERTION",
138-
"licenseDeclared" : "NOASSERTION",
138+
"licenseDeclared" : "GPL-3.0-only",
139139
"name" : "seventh-package",
140140
"summary" : "A package with a source artifact scan result.",
141141
"versionInfo" : "0.0.1"
@@ -156,7 +156,7 @@
156156
"hasFiles" : [ "SPDXRef-File-2", "SPDXRef-File-3" ],
157157
"homepage" : "NONE",
158158
"licenseConcluded" : "NOASSERTION",
159-
"licenseDeclared" : "NOASSERTION",
159+
"licenseDeclared" : "GPL-3.0-only",
160160
"licenseInfoFromFiles" : [ "GPL-3.0-only" ],
161161
"name" : "seventh-package",
162162
"packageVerificationCode" : {
@@ -192,7 +192,7 @@
192192
"filesAnalyzed" : false,
193193
"homepage" : "NONE",
194194
"licenseConcluded" : "NOASSERTION",
195-
"licenseDeclared" : "NOASSERTION",
195+
"licenseDeclared" : "NONE",
196196
"name" : "third-package",
197197
"summary" : "A package with only unmapped declared license.",
198198
"versionInfo" : "0.0.1"

plugins/reporters/spdx/src/funTest/assets/spdx-document-reporter-expected-output.spdx.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ packages:
5555
filesAnalyzed: false
5656
homepage: "first package's homepage URL"
5757
licenseConcluded: "BSD-2-Clause AND BSD-3-Clause AND MIT"
58-
licenseDeclared: "BSD-3-Clause AND (MIT OR GPL-2.0-only)"
58+
licenseDeclared: "Apache-2.0 AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause\
59+
\ AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause\
60+
\ AND BSD-3-Clause AND BSD-3-Clause AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only\
61+
\ OR MIT) AND (GPL-2.0-only OR MIT) AND MIT AND MIT AND MIT"
5962
name: "first-package"
6063
summary: "A package with all supported attributes set, with a VCS URL containing\
6164
\ a user name, and with two scan results for the VCS containing copyright findings\
@@ -75,7 +78,10 @@ packages:
7578
- "SPDXRef-File-1"
7679
homepage: "first package's homepage URL"
7780
licenseConcluded: "NOASSERTION"
78-
licenseDeclared: "BSD-3-Clause AND (MIT OR GPL-2.0-only)"
81+
licenseDeclared: "Apache-2.0 AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause\
82+
\ AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause\
83+
\ AND BSD-3-Clause AND BSD-3-Clause AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only\
84+
\ OR MIT) AND (GPL-2.0-only OR MIT) AND MIT AND MIT AND MIT"
7985
licenseInfoFromFiles:
8086
- "Apache-2.0"
8187
- "BSD-2-Clause"
@@ -101,7 +107,10 @@ packages:
101107
filesAnalyzed: false
102108
homepage: "first package's homepage URL"
103109
licenseConcluded: "NOASSERTION"
104-
licenseDeclared: "BSD-3-Clause AND (MIT OR GPL-2.0-only)"
110+
licenseDeclared: "Apache-2.0 AND BSD-2-Clause AND BSD-2-Clause AND BSD-2-Clause\
111+
\ AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause AND BSD-3-Clause\
112+
\ AND BSD-3-Clause AND BSD-3-Clause AND (GPL-2.0-only OR MIT) AND (GPL-2.0-only\
113+
\ OR MIT) AND (GPL-2.0-only OR MIT) AND MIT AND MIT AND MIT"
105114
name: "first-package"
106115
summary: "A package with all supported attributes set, with a VCS URL containing\
107116
\ a user name, and with two scan results for the VCS containing copyright findings\
@@ -117,7 +126,7 @@ packages:
117126
filesAnalyzed: false
118127
homepage: "NONE"
119128
licenseConcluded: "NOASSERTION"
120-
licenseDeclared: "MIT AND NOASSERTION"
129+
licenseDeclared: "MIT"
121130
name: "fourth-package"
122131
summary: "A package with partially mapped declared license."
123132
versionInfo: "0.0.1"
@@ -131,7 +140,7 @@ packages:
131140
filesAnalyzed: false
132141
homepage: "NONE"
133142
licenseConcluded: "NOASSERTION"
134-
licenseDeclared: "NOASSERTION"
143+
licenseDeclared: "NONE"
135144
name: "second-package"
136145
summary: "A package with minimal attributes set."
137146
versionInfo: "0.0.1"
@@ -145,7 +154,7 @@ packages:
145154
filesAnalyzed: false
146155
homepage: "NONE"
147156
licenseConcluded: "NOASSERTION"
148-
licenseDeclared: "NOASSERTION"
157+
licenseDeclared: "GPL-3.0-only"
149158
name: "seventh-package"
150159
summary: "A package with a source artifact scan result."
151160
versionInfo: "0.0.1"
@@ -165,7 +174,7 @@ packages:
165174
- "SPDXRef-File-3"
166175
homepage: "NONE"
167176
licenseConcluded: "NOASSERTION"
168-
licenseDeclared: "NOASSERTION"
177+
licenseDeclared: "GPL-3.0-only"
169178
licenseInfoFromFiles:
170179
- "GPL-3.0-only"
171180
name: "seventh-package"
@@ -197,7 +206,7 @@ packages:
197206
filesAnalyzed: false
198207
homepage: "NONE"
199208
licenseConcluded: "NOASSERTION"
200-
licenseDeclared: "NOASSERTION"
209+
licenseDeclared: "NONE"
201210
name: "third-package"
202211
summary: "A package with only unmapped declared license."
203212
versionInfo: "0.0.1"

0 commit comments

Comments
 (0)