Skip to content

Commit bd5243a

Browse files
Sophie Wigmoreryanmoran
Sophie Wigmore
authored andcommitted
Enables purls in jam update-dependencies
1 parent ebf4741 commit bd5243a

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

cargo/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type ConfigMetadata struct {
4848

4949
type ConfigMetadataDependency struct {
5050
CPE string `toml:"cpe" json:"cpe,omitempty"`
51+
PURL string `toml:"purl" json:"purl,omitempty"`
5152
DeprecationDate *time.Time `toml:"deprecation_date" json:"deprecation_date,omitempty"`
5253
ID string `toml:"id" json:"id,omitempty"`
5354
Licenses []string `toml:"licenses" json:"licenses,omitempty"`

cargo/config_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func testConfig(t *testing.T, context spec.G, it spec.S) {
6363
Dependencies: []cargo.ConfigMetadataDependency{
6464
{
6565
CPE: "some-cpe",
66+
PURL: "some-purl",
6667
DeprecationDate: &deprecationDate,
6768
ID: "some-dependency",
6869
Licenses: []string{"fancy-license", "fancy-license-2"},
@@ -124,6 +125,7 @@ api = "0.2"
124125
125126
[[metadata.dependencies]]
126127
cpe = "some-cpe"
128+
purl = "some-purl"
127129
deprecation_date = "2020-06-01T00:00:00Z"
128130
id = "some-dependency"
129131
licenses = ["fancy-license", "fancy-license-2"]
@@ -223,6 +225,7 @@ api = "0.2"
223225
224226
[[metadata.dependencies]]
225227
cpe = "some-cpe"
228+
purl = "some-purl"
226229
id = "some-dependency"
227230
licenses = ["fancy-license", "fancy-license-2"]
228231
name = "Some Dependency"
@@ -291,6 +294,7 @@ api = "0.2"
291294
Dependencies: []cargo.ConfigMetadataDependency{
292295
{
293296
CPE: "some-cpe",
297+
PURL: "some-purl",
294298
ID: "some-dependency",
295299
Licenses: []string{"fancy-license", "fancy-license-2"},
296300
Name: "Some Dependency",

cargo/jam/internal/dependency.go

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Dependency struct {
2727
CreatedAt string `json:"created_at,omitempty"`
2828
ModifedAt string `json:"modified_at,omitempty"`
2929
CPE string `json:"cpe,omitempty"`
30+
PURL string `json:"purl,omitempty"`
3031
Licenses []string `json:"licenses,omitempty"`
3132
}
3233

@@ -129,6 +130,7 @@ func convertToCargoDependency(dependency Dependency, dependencyName string) carg
129130
}
130131

131132
cargoDependency.CPE = dependency.CPE
133+
cargoDependency.PURL = dependency.PURL
132134
cargoDependency.ID = dependency.ID
133135
cargoDependency.Name = dependencyName
134136
cargoDependency.SHA256 = dependency.SHA256

cargo/jam/internal/dependency_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
3838
CreatedAt: "sometime",
3939
ModifedAt: "another-time",
4040
CPE: "cpe-notation",
41+
PURL: "some-purl",
4142
Licenses: []string{
4243
"fancy-license",
4344
"fancy-license-2",
@@ -59,6 +60,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
5960
CreatedAt: "sometime",
6061
ModifedAt: "another-time",
6162
CPE: "cpe-notation",
63+
PURL: "some-purl",
6264
Licenses: []string{
6365
"fancy-license",
6466
"fancy-license-2",
@@ -80,6 +82,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
8082
CreatedAt: "sometime",
8183
ModifedAt: "another-time",
8284
CPE: "cpe-notation",
85+
PURL: "some-purl",
8386
Licenses: []string{
8487
"fancy-license",
8588
"fancy-license-2",
@@ -101,6 +104,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
101104
CreatedAt: "sometime",
102105
ModifedAt: "another-time",
103106
CPE: "cpe-notation",
107+
PURL: "some-purl",
104108
Licenses: []string{
105109
"fancy-license",
106110
"fancy-license-2",
@@ -122,6 +126,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
122126
CreatedAt: "sometime",
123127
ModifedAt: "another-time",
124128
CPE: "cpe-notation",
129+
PURL: "some-purl",
125130
Licenses: []string{
126131
"fancy-license",
127132
"fancy-license-2",
@@ -162,6 +167,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
162167
"created_at": "sometime",
163168
"modified_at": "another-time",
164169
"cpe": "cpe-notation",
170+
"purl": "some-purl",
165171
"deprecation_date": "",
166172
"licenses": ["fancy-license", "fancy-license-2"]
167173
},
@@ -180,6 +186,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
180186
"created_at": "sometime",
181187
"modified_at": "another-time",
182188
"cpe": "cpe-notation",
189+
"purl": "some-purl",
183190
"licenses": ["fancy-license", "fancy-license-2"]
184191
},
185192
{
@@ -197,6 +204,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
197204
"created_at": "sometime",
198205
"modified_at": "another-time",
199206
"cpe": "cpe-notation",
207+
"purl": "some-purl",
200208
"licenses": ["fancy-license", "fancy-license-2"]
201209
},
202210
{
@@ -214,6 +222,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
214222
"created_at": "sometime",
215223
"modified_at": "another-time",
216224
"cpe": "cpe-notation",
225+
"purl": "some-purl",
217226
"licenses": ["fancy-license", "fancy-license-2"]
218227
},
219228
{
@@ -231,6 +240,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
231240
"created_at": "sometime",
232241
"modified_at": "another-time",
233242
"cpe": "cpe-notation",
243+
"purl": "some-purl",
234244
"licenses": ["fancy-license", "fancy-license-2"]
235245
}
236246
]`)
@@ -302,6 +312,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
302312
Expect(dependencies).To(Equal([]cargo.ConfigMetadataDependency{
303313
{
304314
CPE: "cpe-notation",
315+
PURL: "some-purl",
305316
ID: "some-dep",
306317
Licenses: []string{"fancy-license", "fancy-license-2"},
307318
Version: "1.0.0",
@@ -313,6 +324,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
313324
},
314325
{
315326
CPE: "cpe-notation",
327+
PURL: "some-purl",
316328
ID: "some-dep",
317329
Licenses: []string{"fancy-license", "fancy-license-2"},
318330
Version: "1.1.2",
@@ -324,6 +336,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
324336
},
325337
{
326338
CPE: "cpe-notation",
339+
PURL: "some-purl",
327340
ID: "some-dep",
328341
Licenses: []string{"fancy-license", "fancy-license-2"},
329342
Version: "1.5.6",
@@ -375,6 +388,7 @@ func testDependency(t *testing.T, context spec.G, it spec.S) {
375388
CreatedAt: "sometime",
376389
ModifedAt: "another-time",
377390
CPE: "cpe-notation",
391+
PURL: "some-purl",
378392
Licenses: []string{"fancy-license", "fancy-license-2"},
379393
},
380394
}

cargo/jam/update_dependencies_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
5656
"source": "some-source",
5757
"source_sha256": "some-source-sha",
5858
"cpe": "node-cpe",
59+
"purl": "some-purl",
5960
"licenses": ["MIT", "MIT-2"]
6061
},
6162
{
@@ -71,6 +72,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
7172
"source": "some-source",
7273
"source_sha256": "some-source-sha",
7374
"cpe": "node-cpe",
75+
"purl": "some-purl",
7476
"licenses": ["MIT", "MIT-2"]
7577
},
7678
{
@@ -86,6 +88,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
8688
"source": "some-source",
8789
"source_sha256": "some-source-sha",
8890
"cpe": "node-cpe",
91+
"purl": "some-purl",
8992
"licenses": ["MIT", "MIT-2"]
9093
},
9194
{
@@ -101,6 +104,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
101104
"source": "some-source",
102105
"source_sha256": "some-source-sha",
103106
"cpe": "node-cpe",
107+
"purl": "some-purl",
104108
"licenses": ["MIT", "MIT-2"]
105109
}]`)
106110
}
@@ -131,6 +135,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
131135
132136
[[metadata.dependencies]]
133137
cpe = "node-cpe"
138+
purl = "some-purl"
134139
id = "node"
135140
name = "Node Engine"
136141
sha256 = "some-sha"
@@ -142,6 +147,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
142147
143148
[[metadata.dependencies]]
144149
cpe = "node-cpe"
150+
purl = "some-purl"
145151
id = "node"
146152
name = "Node Engine"
147153
sha256 = "some-sha"
@@ -153,6 +159,7 @@ func testUpdateDependencies(t *testing.T, context spec.G, it spec.S) {
153159
154160
[[metadata.dependencies]]
155161
cpe = "node-cpe"
162+
purl = "some-purl"
156163
id = "node"
157164
name = "Node Engine"
158165
sha256 = "some-sha"
@@ -212,6 +219,7 @@ api = "0.2"
212219
213220
[[metadata.dependencies]]
214221
cpe = "node-cpe"
222+
purl = "some-purl"
215223
id = "node"
216224
licenses = ["MIT", "MIT-2"]
217225
name = "Node Engine"
@@ -224,6 +232,7 @@ api = "0.2"
224232
225233
[[metadata.dependencies]]
226234
cpe = "node-cpe"
235+
purl = "some-purl"
227236
id = "node"
228237
licenses = ["MIT", "MIT-2"]
229238
name = "Node Engine"
@@ -236,6 +245,7 @@ api = "0.2"
236245
237246
[[metadata.dependencies]]
238247
cpe = "node-cpe"
248+
purl = "some-purl"
239249
id = "node"
240250
licenses = ["MIT", "MIT-2"]
241251
name = "Node Engine"
@@ -276,6 +286,7 @@ api = "0.2"
276286
277287
[[metadata.dependencies]]
278288
cpe = "node-cpe"
289+
purl = "some-purl"
279290
id = "node"
280291
licenses = ["MIT", "MIT-2"]
281292
name = "Node Engine"
@@ -330,6 +341,7 @@ api = "0.2"
330341
331342
[[metadata.dependencies]]
332343
cpe = "node-cpe"
344+
purl = "some-purl"
333345
id = "node"
334346
licenses = ["MIT", "MIT-2"]
335347
name = "Node Engine"
@@ -366,6 +378,7 @@ api = "0.2"
366378
367379
[[metadata.dependencies]]
368380
cpe = "node-cpe"
381+
purl = "some-purl"
369382
id = "node"
370383
name = "Node Engine"
371384
licenses = ["MIT", "MIT-2"]
@@ -420,6 +433,7 @@ api = "0.2"
420433
421434
[[metadata.dependencies]]
422435
cpe = "node-cpe"
436+
purl = "some-purl"
423437
id = "node"
424438
licenses = ["MIT", "MIT-2"]
425439
name = "Node Engine"
@@ -510,6 +524,7 @@ api = "0.2"
510524
511525
[[metadata.dependencies]]
512526
cpe = "non-existent-cpe"
527+
purl = "non-existent-purl"
513528
id = "non-existent"
514529
licenses = ["MIT", "MIT-2"]
515530
sha256 = "some-sha"

0 commit comments

Comments
 (0)