@@ -15,7 +15,7 @@ TEST_CASE ("spdx maximum serialization", "[spdx]")
15
15
cpgh.name = " zlib" ;
16
16
cpgh.summary = {" summary" };
17
17
cpgh.description = {" description" };
18
- cpgh.homepage = " homepage " ;
18
+ cpgh.homepage = " https://www.zlib.net/ " ;
19
19
cpgh.license = " MIT" ;
20
20
cpgh.version_scheme = VersionScheme::Relaxed;
21
21
cpgh.version = Version{" 1.0" , 5 };
@@ -100,13 +100,25 @@ TEST_CASE ("spdx maximum serialization", "[spdx]")
100
100
"SPDXID": "SPDXRef-port",
101
101
"versionInfo": "1.0#5",
102
102
"downloadLocation": "git://some-vcs-url",
103
- "homepage": "homepage ",
103
+ "homepage": "https://www.zlib.net/ ",
104
104
"licenseConcluded": "MIT",
105
105
"licenseDeclared": "NOASSERTION",
106
106
"copyrightText": "NOASSERTION",
107
107
"summary": "summary",
108
108
"description": "description",
109
- "comment": "This is the port (recipe) consumed by vcpkg."
109
+ "comment": "This is the port (recipe) consumed by vcpkg.",
110
+ "externalRefs": [
111
+ {
112
+ "referenceCategory": "PACKAGE_MANAGER",
113
+ "referenceLocator": "pkg:vcpkg/[email protected] ",
114
+ "referenceType": "purl"
115
+ },
116
+ {
117
+ "referenceCategory": "SECURITY",
118
+ "referenceLocator": "cpe:2.3:a:zlib:zlib:1.0",
119
+ "referenceType": "cpe23Type"
120
+ }
121
+ ]
110
122
},
111
123
{
112
124
"name": "zlib:arm-uwp",
@@ -247,7 +259,19 @@ TEST_CASE ("spdx minimum serialization", "[spdx]")
247
259
"licenseConcluded": "NOASSERTION",
248
260
"licenseDeclared": "NOASSERTION",
249
261
"copyrightText": "NOASSERTION",
250
- "comment": "This is the port (recipe) consumed by vcpkg."
262
+ "comment": "This is the port (recipe) consumed by vcpkg.",
263
+ "externalRefs": [
264
+ {
265
+ "referenceCategory": "PACKAGE_MANAGER",
266
+ "referenceLocator": "pkg:vcpkg/[email protected] ",
267
+ "referenceType": "purl"
268
+ },
269
+ {
270
+ "referenceCategory": "SECURITY",
271
+ "referenceLocator": "cpe:2.3:a:zlib:zlib:1.0",
272
+ "referenceType": "cpe23Type"
273
+ }
274
+ ]
251
275
},
252
276
{
253
277
"name": "zlib:arm-uwp",
@@ -366,7 +390,19 @@ TEST_CASE ("spdx concat resources", "[spdx]")
366
390
"licenseConcluded": "NOASSERTION",
367
391
"licenseDeclared": "NOASSERTION",
368
392
"copyrightText": "NOASSERTION",
369
- "comment": "This is the port (recipe) consumed by vcpkg."
393
+ "comment": "This is the port (recipe) consumed by vcpkg.",
394
+ "externalRefs": [
395
+ {
396
+ "referenceCategory": "PACKAGE_MANAGER",
397
+ "referenceLocator": "pkg:vcpkg/[email protected] ",
398
+ "referenceType": "purl"
399
+ },
400
+ {
401
+ "referenceCategory": "SECURITY",
402
+ "referenceLocator": "cpe:2.3:a:zlib:zlib:1.0",
403
+ "referenceType": "cpe23Type"
404
+ }
405
+ ]
370
406
},
371
407
{
372
408
"name": "zlib:arm-uwp",
@@ -396,3 +432,146 @@ TEST_CASE ("spdx concat resources", "[spdx]")
396
432
auto doc = Json::parse (sbom, " test" ).value (VCPKG_LINE_INFO);
397
433
Test::check_json_eq (expected.value , doc.value );
398
434
}
435
+
436
+ TEST_CASE (" spdx github source" , " [spdx]" )
437
+ {
438
+ PackageSpec spec{" glew" , Test::ARM_UWP};
439
+ SourceControlFileAndLocation scfl;
440
+ auto & scf = *(scfl.source_control_file = std::make_unique<SourceControlFile>());
441
+ auto & cpgh = *(scf.core_paragraph = std::make_unique<SourceParagraph>());
442
+ cpgh.name = " glew" ;
443
+ cpgh.homepage = " https://github.com/nigels-com/glew" ;
444
+ cpgh.version_scheme = VersionScheme::String;
445
+ cpgh.version = Version{" 2.2.0" , 3 };
446
+
447
+ InstallPlanAction ipa (
448
+ spec, scfl, " test_packages_root" , RequestType::USER_REQUESTED, UseHeadVersion::No, Editable::No, {}, {}, {});
449
+ auto & abi = *(ipa.abi_info = AbiInfo{}).get ();
450
+ abi.package_abi = " deadbeef" ;
451
+
452
+ const auto sbom = create_spdx_sbom (ipa,
453
+ std::vector<Path>{" vcpkg.json" , " portfile.cmake" },
454
+ std::vector<std::string>{" hash-vcpkg.json" , " hash-portfile.cmake" },
455
+ " now+1" ,
456
+ " https://test-document-namespace-2" ,
457
+ {});
458
+
459
+ auto expected = Json::parse (R"json(
460
+ {
461
+ "$schema": "https://raw.githubusercontent.com/spdx/spdx-spec/v2.2.1/schemas/spdx-schema.json",
462
+ "spdxVersion": "SPDX-2.2",
463
+ "dataLicense": "CC0-1.0",
464
+ "SPDXID": "SPDXRef-DOCUMENT",
465
+ "documentNamespace": "https://test-document-namespace-2",
466
+ "name": "glew:[email protected] #3 deadbeef",
467
+ "creationInfo": {
468
+ "creators": [
469
+ "Tool: vcpkg-2999-12-31-unknownhash"
470
+ ],
471
+ "created": "now+1"
472
+ },
473
+ "relationships": [
474
+ {
475
+ "spdxElementId": "SPDXRef-port",
476
+ "relationshipType": "GENERATES",
477
+ "relatedSpdxElement": "SPDXRef-binary"
478
+ },
479
+ {
480
+ "spdxElementId": "SPDXRef-port",
481
+ "relationshipType": "CONTAINS",
482
+ "relatedSpdxElement": "SPDXRef-file-0"
483
+ },
484
+ {
485
+ "spdxElementId": "SPDXRef-port",
486
+ "relationshipType": "CONTAINS",
487
+ "relatedSpdxElement": "SPDXRef-file-1"
488
+ },
489
+ {
490
+ "spdxElementId": "SPDXRef-binary",
491
+ "relationshipType": "GENERATED_FROM",
492
+ "relatedSpdxElement": "SPDXRef-port"
493
+ },
494
+ {
495
+ "spdxElementId": "SPDXRef-file-0",
496
+ "relationshipType": "CONTAINED_BY",
497
+ "relatedSpdxElement": "SPDXRef-port"
498
+ },
499
+ {
500
+ "spdxElementId": "SPDXRef-file-0",
501
+ "relationshipType": "DEPENDENCY_MANIFEST_OF",
502
+ "relatedSpdxElement": "SPDXRef-port"
503
+ },
504
+ {
505
+ "spdxElementId": "SPDXRef-file-1",
506
+ "relationshipType": "CONTAINED_BY",
507
+ "relatedSpdxElement": "SPDXRef-port"
508
+ }
509
+ ],
510
+ "packages": [
511
+ {
512
+ "name": "glew",
513
+ "SPDXID": "SPDXRef-port",
514
+ "versionInfo": "2.2.0#3",
515
+ "downloadLocation": "NOASSERTION",
516
+ "homepage": "https://github.com/nigels-com/glew",
517
+ "licenseConcluded": "NOASSERTION",
518
+ "licenseDeclared": "NOASSERTION",
519
+ "copyrightText": "NOASSERTION",
520
+ "comment": "This is the port (recipe) consumed by vcpkg.",
521
+ "externalRefs": [
522
+ {
523
+ "referenceCategory": "PACKAGE_MANAGER",
524
+ "referenceLocator": "pkg:vcpkg/[email protected] ",
525
+ "referenceType": "purl"
526
+ },
527
+ {
528
+ "referenceCategory": "SECURITY",
529
+ "referenceLocator": "cpe:2.3:a:glew:glew:2.2.0",
530
+ "referenceType": "cpe23Type"
531
+ }
532
+ ]
533
+ },
534
+ {
535
+ "name": "glew:arm-uwp",
536
+ "SPDXID": "SPDXRef-binary",
537
+ "versionInfo": "deadbeef",
538
+ "downloadLocation": "NONE",
539
+ "licenseConcluded": "NOASSERTION",
540
+ "licenseDeclared": "NOASSERTION",
541
+ "copyrightText": "NOASSERTION",
542
+ "comment": "This is a binary package built by vcpkg."
543
+ }
544
+ ],
545
+ "files": [
546
+ {
547
+ "fileName": "./vcpkg.json",
548
+ "SPDXID": "SPDXRef-file-0",
549
+ "checksums": [
550
+ {
551
+ "algorithm": "SHA256",
552
+ "checksumValue": "hash-vcpkg.json"
553
+ }
554
+ ],
555
+ "licenseConcluded": "NOASSERTION",
556
+ "copyrightText": "NOASSERTION"
557
+ },
558
+ {
559
+ "fileName": "./portfile.cmake",
560
+ "SPDXID": "SPDXRef-file-1",
561
+ "checksums": [
562
+ {
563
+ "algorithm": "SHA256",
564
+ "checksumValue": "hash-portfile.cmake"
565
+ }
566
+ ],
567
+ "licenseConcluded": "NOASSERTION",
568
+ "copyrightText": "NOASSERTION"
569
+ }
570
+ ]
571
+ })json" ,
572
+ " test" )
573
+ .value (VCPKG_LINE_INFO);
574
+
575
+ auto doc = Json::parse (sbom, " test" ).value (VCPKG_LINE_INFO);
576
+ Test::check_json_eq (expected.value , doc.value );
577
+ }
0 commit comments