Skip to content

Commit a0491f5

Browse files
committed
feat(GoMod): Obtain the VCS info from the Go tooling
Previously, ORT's GoMod integration had a rudimentary (re-)implementation of the Go toolings' logic for resolving the VCS infos for the dependencies, covering only the more common use cases. For example, the implementation is VCS host specific and cannot handle mono repository setups at all, without an ugly workaround in the downloader, see [1]. Furthermore, I expect many not yet known issues in the more uncommon use cases. Avoid all these issues by just relying on the VCS info resolution of the Go tooling. Note that as of Go 1.19, the `.info` files under '$GOPATH/pkg/mod' are guaranteed to contain the VCS info of the modules in case no Go proxy is used [2]. For now that information is only accessible by parsing the files directly, but there are plans to make this information available via the command line tools like `go list -json` [3]. Fixes: #5555. [1]: https://github.com/oss-review-toolkit/ort/blob/1dc5c54de3630f0f1249a7ec56ce0a3ba87ac5f1/downloader/src/main/kotlin/VersionControlSystem.kt#L361-L366 [2]: golang/go#44742 (comment) [3]: golang/go#18387 Signed-off-by: Frank Viernau <[email protected]>
1 parent 25e3bae commit a0491f5

File tree

4 files changed

+104
-182
lines changed

4 files changed

+104
-182
lines changed

analyzer/src/funTest/assets/projects/synthetic/gomod-expected-output.yml

+53-53
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ packages:
136136
algorithm: ""
137137
vcs:
138138
type: "Git"
139-
url: "https://github.com/atomtree/go-spew.git"
140-
revision: "v1.1.0"
139+
url: "https://github.com/atomtree/go-spew"
140+
revision: "346938d642f2ec3594ed81d874461961cd0faa76"
141141
path: ""
142142
vcs_processed:
143143
type: "Git"
144144
url: "https://github.com/atomtree/go-spew.git"
145-
revision: "v1.1.0"
145+
revision: "346938d642f2ec3594ed81d874461961cd0faa76"
146146
path: ""
147147
- id: "Go::github.com/fatih/color:1.13.0"
148148
purl: "pkg:golang/github.com%2Ffatih%[email protected]"
@@ -162,13 +162,13 @@ packages:
162162
algorithm: ""
163163
vcs:
164164
type: "Git"
165-
url: "https://github.com/fatih/color.git"
166-
revision: "v1.13.0"
165+
url: "https://github.com/fatih/color"
166+
revision: "a05da93ebe62ca9fc6791d3376ec4dad01196448"
167167
path: ""
168168
vcs_processed:
169169
type: "Git"
170170
url: "https://github.com/fatih/color.git"
171-
revision: "v1.13.0"
171+
revision: "a05da93ebe62ca9fc6791d3376ec4dad01196448"
172172
path: ""
173173
- id: "Go::github.com/google/uuid:1.0.0"
174174
purl: "pkg:golang/github.com%2Fgoogle%[email protected]"
@@ -188,13 +188,13 @@ packages:
188188
algorithm: ""
189189
vcs:
190190
type: "Git"
191-
url: "https://github.com/google/uuid.git"
192-
revision: "v1.0.0"
191+
url: "https://github.com/google/uuid"
192+
revision: "d460ce9f8df2e77fb1ba55ca87fafed96c607494"
193193
path: ""
194194
vcs_processed:
195195
type: "Git"
196196
url: "https://github.com/google/uuid.git"
197-
revision: "v1.0.0"
197+
revision: "d460ce9f8df2e77fb1ba55ca87fafed96c607494"
198198
path: ""
199199
- id: "Go::github.com/hashicorp/go-secure-stdlib/parseutil:0.1.6"
200200
purl: "pkg:golang/github.com%2Fhashicorp%2Fgo-secure-stdlib%[email protected]"
@@ -214,13 +214,13 @@ packages:
214214
algorithm: ""
215215
vcs:
216216
type: "Git"
217-
url: "https://github.com/hashicorp/go-secure-stdlib.git"
218-
revision: "v0.1.6"
217+
url: "https://github.com/hashicorp/go-secure-stdlib"
218+
revision: "43c607d97e1d4615c5140017131807d1f0b702ff"
219219
path: "parseutil"
220220
vcs_processed:
221221
type: "Git"
222222
url: "https://github.com/hashicorp/go-secure-stdlib.git"
223-
revision: "v0.1.6"
223+
revision: "43c607d97e1d4615c5140017131807d1f0b702ff"
224224
path: "parseutil"
225225
- id: "Go::github.com/hashicorp/go-secure-stdlib/strutil:0.1.1"
226226
purl: "pkg:golang/github.com%2Fhashicorp%2Fgo-secure-stdlib%[email protected]"
@@ -240,13 +240,13 @@ packages:
240240
algorithm: ""
241241
vcs:
242242
type: "Git"
243-
url: "https://github.com/hashicorp/go-secure-stdlib.git"
244-
revision: "v0.1.1"
243+
url: "https://github.com/hashicorp/go-secure-stdlib"
244+
revision: "1b80d53b4662d4b15ea0c23754dd81e3ae21d58b"
245245
path: "strutil"
246246
vcs_processed:
247247
type: "Git"
248248
url: "https://github.com/hashicorp/go-secure-stdlib.git"
249-
revision: "v0.1.1"
249+
revision: "1b80d53b4662d4b15ea0c23754dd81e3ae21d58b"
250250
path: "strutil"
251251
- id: "Go::github.com/hashicorp/go-sockaddr:1.0.2"
252252
purl: "pkg:golang/github.com%2Fhashicorp%[email protected]"
@@ -266,13 +266,13 @@ packages:
266266
algorithm: ""
267267
vcs:
268268
type: "Git"
269-
url: "https://github.com/hashicorp/go-sockaddr.git"
270-
revision: "v1.0.2"
269+
url: "https://github.com/hashicorp/go-sockaddr"
270+
revision: "c7188e74f6acae5a989bdc959aa779f8b9f42faf"
271271
path: ""
272272
vcs_processed:
273273
type: "Git"
274274
url: "https://github.com/hashicorp/go-sockaddr.git"
275-
revision: "v1.0.2"
275+
revision: "c7188e74f6acae5a989bdc959aa779f8b9f42faf"
276276
path: ""
277277
- id: "Go::github.com/mattn/go-colorable:0.1.12"
278278
purl: "pkg:golang/github.com%2Fmattn%[email protected]"
@@ -292,13 +292,13 @@ packages:
292292
algorithm: ""
293293
vcs:
294294
type: "Git"
295-
url: "https://github.com/mattn/go-colorable.git"
296-
revision: "v0.1.12"
295+
url: "https://github.com/mattn/go-colorable"
296+
revision: "e1bb79c8d53c38a60962ad4b8f658226cc983710"
297297
path: ""
298298
vcs_processed:
299299
type: "Git"
300300
url: "https://github.com/mattn/go-colorable.git"
301-
revision: "v0.1.12"
301+
revision: "e1bb79c8d53c38a60962ad4b8f658226cc983710"
302302
path: ""
303303
- id: "Go::github.com/mattn/go-isatty:0.0.14"
304304
purl: "pkg:golang/github.com%2Fmattn%[email protected]"
@@ -318,13 +318,13 @@ packages:
318318
algorithm: ""
319319
vcs:
320320
type: "Git"
321-
url: "https://github.com/mattn/go-isatty.git"
322-
revision: "v0.0.14"
321+
url: "https://github.com/mattn/go-isatty"
322+
revision: "504425e14f742f1f517c4586048b49b37f829c8e"
323323
path: ""
324324
vcs_processed:
325325
type: "Git"
326326
url: "https://github.com/mattn/go-isatty.git"
327-
revision: "v0.0.14"
327+
revision: "504425e14f742f1f517c4586048b49b37f829c8e"
328328
path: ""
329329
- id: "Go::github.com/mitchellh/mapstructure:1.4.1"
330330
purl: "pkg:golang/github.com%2Fmitchellh%[email protected]"
@@ -344,13 +344,13 @@ packages:
344344
algorithm: ""
345345
vcs:
346346
type: "Git"
347-
url: "https://github.com/mitchellh/mapstructure.git"
348-
revision: "v1.4.1"
347+
url: "https://github.com/mitchellh/mapstructure"
348+
revision: "8ebf2d61a8b4adcce25fc9fc9b76e8452a00672f"
349349
path: ""
350350
vcs_processed:
351351
type: "Git"
352352
url: "https://github.com/mitchellh/mapstructure.git"
353-
revision: "v1.4.1"
353+
revision: "8ebf2d61a8b4adcce25fc9fc9b76e8452a00672f"
354354
path: ""
355355
- id: "Go::github.com/pborman/uuid:1.2.1"
356356
purl: "pkg:golang/github.com%2Fpborman%[email protected]"
@@ -370,13 +370,13 @@ packages:
370370
algorithm: ""
371371
vcs:
372372
type: "Git"
373-
url: "https://github.com/pborman/uuid.git"
374-
revision: "v1.2.1"
373+
url: "https://github.com/pborman/uuid"
374+
revision: "5b6091a6a160ee5ce12917b21ab96acec2a4fdc0"
375375
path: ""
376376
vcs_processed:
377377
type: "Git"
378378
url: "https://github.com/pborman/uuid.git"
379-
revision: "v1.2.1"
379+
revision: "5b6091a6a160ee5ce12917b21ab96acec2a4fdc0"
380380
path: ""
381381
- id: "Go::github.com/pmezard/go-difflib:1.0.0"
382382
purl: "pkg:golang/github.com%2Fpmezard%[email protected]"
@@ -396,13 +396,13 @@ packages:
396396
algorithm: ""
397397
vcs:
398398
type: "Git"
399-
url: "https://github.com/pmezard/go-difflib.git"
400-
revision: "v1.0.0"
399+
url: "https://github.com/pmezard/go-difflib"
400+
revision: "792786c7400a136282c1664665ae0a8db921c6c2"
401401
path: ""
402402
vcs_processed:
403403
type: "Git"
404404
url: "https://github.com/pmezard/go-difflib.git"
405-
revision: "v1.0.0"
405+
revision: "792786c7400a136282c1664665ae0a8db921c6c2"
406406
path: ""
407407
- id: "Go::github.com/ryanuber/go-glob:1.0.0"
408408
purl: "pkg:golang/github.com%2Fryanuber%[email protected]"
@@ -422,13 +422,13 @@ packages:
422422
algorithm: ""
423423
vcs:
424424
type: "Git"
425-
url: "https://github.com/ryanuber/go-glob.git"
426-
revision: "v1.0.0"
425+
url: "https://github.com/ryanuber/go-glob"
426+
revision: "51a8f68e6c24dc43f1e371749c89a267de4ebc53"
427427
path: ""
428428
vcs_processed:
429429
type: "Git"
430430
url: "https://github.com/ryanuber/go-glob.git"
431-
revision: "v1.0.0"
431+
revision: "51a8f68e6c24dc43f1e371749c89a267de4ebc53"
432432
path: ""
433433
- id: "Go::github.com/stretchr/testify:1.7.2"
434434
purl: "pkg:golang/github.com%2Fstretchr%[email protected]"
@@ -448,13 +448,13 @@ packages:
448448
algorithm: ""
449449
vcs:
450450
type: "Git"
451-
url: "https://github.com/stretchr/testify.git"
452-
revision: "v1.7.2"
451+
url: "https://github.com/stretchr/testify"
452+
revision: "41453c009af9a942261b7a25a88521d0d6804e7f"
453453
path: ""
454454
vcs_processed:
455455
type: "Git"
456456
url: "https://github.com/stretchr/testify.git"
457-
revision: "v1.7.2"
457+
revision: "41453c009af9a942261b7a25a88521d0d6804e7f"
458458
path: ""
459459
- id: "Go::golang.org/x/sys:0.0.0-20220610221304-9f5ed59c137d"
460460
purl: "pkg:golang/golang.org%2Fx%[email protected]"
@@ -468,19 +468,19 @@ packages:
468468
value: ""
469469
algorithm: ""
470470
source_artifact:
471-
url: "https://proxy.golang.org/golang.org/x/sys/@v/v0.0.0-20220610221304-9f5ed59c137d.zip"
471+
url: ""
472472
hash:
473473
value: ""
474474
algorithm: ""
475475
vcs:
476-
type: ""
477-
url: ""
478-
revision: ""
476+
type: "Git"
477+
url: "https://go.googlesource.com/sys"
478+
revision: "9f5ed59c137dcb0852024edd2e71af63c2d67707"
479479
path: ""
480480
vcs_processed:
481-
type: ""
482-
url: ""
483-
revision: ""
481+
type: "Git"
482+
url: "https://go.googlesource.com/sys"
483+
revision: "9f5ed59c137dcb0852024edd2e71af63c2d67707"
484484
path: ""
485485
- id: "Go::gopkg.in/yaml.v3:3.0.1"
486486
purl: "pkg:golang/gopkg.in%[email protected]"
@@ -494,17 +494,17 @@ packages:
494494
value: ""
495495
algorithm: ""
496496
source_artifact:
497-
url: "https://proxy.golang.org/gopkg.in/yaml.v3/@v/v3.0.1.zip"
497+
url: ""
498498
hash:
499499
value: ""
500500
algorithm: ""
501501
vcs:
502-
type: ""
503-
url: ""
504-
revision: ""
502+
type: "Git"
503+
url: "https://gopkg.in/yaml.v3"
504+
revision: "f6f7691b1fdeb513f56608cd2c32c51f8194bf51"
505505
path: ""
506506
vcs_processed:
507-
type: ""
508-
url: ""
509-
revision: ""
507+
type: "Git"
508+
url: "https://gopkg.in/yaml.v3"
509+
revision: "f6f7691b1fdeb513f56608cd2c32c51f8194bf51"
510510
path: ""

analyzer/src/funTest/assets/projects/synthetic/gomod-subpkg-expected-output.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ packages:
4343
algorithm: ""
4444
vcs:
4545
type: "Git"
46-
url: "https://github.com/fatih/color.git"
47-
revision: "v1.7.0"
46+
url: "https://github.com/fatih/color"
47+
revision: "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4"
4848
path: ""
4949
vcs_processed:
5050
type: "Git"
5151
url: "https://github.com/fatih/color.git"
52-
revision: "v1.7.0"
52+
revision: "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4"
5353
path: ""
5454
- id: "Go::github.com/mattn/go-colorable:0.1.4"
5555
purl: "pkg:golang/github.com%2Fmattn%[email protected]"
@@ -69,13 +69,13 @@ packages:
6969
algorithm: ""
7070
vcs:
7171
type: "Git"
72-
url: "https://github.com/mattn/go-colorable.git"
73-
revision: "v0.1.4"
72+
url: "https://github.com/mattn/go-colorable"
73+
revision: "98ec13f34aabf44cc914c65a1cfb7b9bc815aef1"
7474
path: ""
7575
vcs_processed:
7676
type: "Git"
7777
url: "https://github.com/mattn/go-colorable.git"
78-
revision: "v0.1.4"
78+
revision: "98ec13f34aabf44cc914c65a1cfb7b9bc815aef1"
7979
path: ""
8080
- id: "Go::github.com/mattn/go-isatty:0.0.10"
8181
purl: "pkg:golang/github.com%2Fmattn%[email protected]"
@@ -95,13 +95,13 @@ packages:
9595
algorithm: ""
9696
vcs:
9797
type: "Git"
98-
url: "https://github.com/mattn/go-isatty.git"
99-
revision: "v0.0.10"
98+
url: "https://github.com/mattn/go-isatty"
99+
revision: "88ba11cfdc67c7588b30042edf244b2875f892b6"
100100
path: ""
101101
vcs_processed:
102102
type: "Git"
103103
url: "https://github.com/mattn/go-isatty.git"
104-
revision: "v0.0.10"
104+
revision: "88ba11cfdc67c7588b30042edf244b2875f892b6"
105105
path: ""
106106
- id: "Go::golang.org/x/sys:0.0.0-20191008105621-543471e840be"
107107
purl: "pkg:golang/golang.org%2Fx%[email protected]"
@@ -115,17 +115,17 @@ packages:
115115
value: ""
116116
algorithm: ""
117117
source_artifact:
118-
url: "https://proxy.golang.org/golang.org/x/sys/@v/v0.0.0-20191008105621-543471e840be.zip"
118+
url: ""
119119
hash:
120120
value: ""
121121
algorithm: ""
122122
vcs:
123-
type: ""
124-
url: ""
125-
revision: ""
123+
type: "Git"
124+
url: "https://go.googlesource.com/sys"
125+
revision: "543471e840be449c53d44b32c7adf1261ad67e37"
126126
path: ""
127127
vcs_processed:
128-
type: ""
129-
url: ""
130-
revision: ""
128+
type: "Git"
129+
url: "https://go.googlesource.com/sys"
130+
revision: "543471e840be449c53d44b32c7adf1261ad67e37"
131131
path: ""

0 commit comments

Comments
 (0)