-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly handle object licenses in SBOM generation (#6969)
- Loading branch information
1 parent
b3a53c6
commit 0f70088
Showing
6 changed files
with
255 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -912,6 +912,61 @@ exports[`test/lib/utils/sbom-cyclonedx.js TAP single node - with license express | |
} | ||
` | ||
|
||
exports[`test/lib/utils/sbom-cyclonedx.js TAP single node - with license object > must match snapshot 1`] = ` | ||
{ | ||
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", | ||
"bomFormat": "CycloneDX", | ||
"specVersion": "1.5", | ||
"serialNumber": "urn:uuid:00000000-0000-0000-0000-000000000000", | ||
"version": 1, | ||
"metadata": { | ||
"timestamp": "2020-01-01T00:00:00.000Z", | ||
"lifecycles": [ | ||
{ | ||
"phase": "build" | ||
} | ||
], | ||
"tools": [ | ||
{ | ||
"vendor": "npm", | ||
"name": "cli", | ||
"version": "10.0.0 " | ||
} | ||
], | ||
"component": { | ||
"bom-ref": "[email protected]", | ||
"type": "library", | ||
"name": "root", | ||
"version": "1.0.0", | ||
"scope": "required", | ||
"author": "Author", | ||
"purl": "pkg:npm/[email protected]", | ||
"properties": [ | ||
{ | ||
"name": "cdx:npm:package:path", | ||
"value": "" | ||
} | ||
], | ||
"externalReferences": [], | ||
"licenses": [ | ||
{ | ||
"license": { | ||
"id": "MIT" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"components": [], | ||
"dependencies": [ | ||
{ | ||
"ref": "[email protected]", | ||
"dependsOn": [] | ||
} | ||
] | ||
} | ||
` | ||
|
||
exports[`test/lib/utils/sbom-cyclonedx.js TAP single node - with repository url > must match snapshot 1`] = ` | ||
{ | ||
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -504,3 +504,138 @@ exports[`test/lib/utils/sbom-spdx.js TAP single node - with integrity > must mat | |
] | ||
} | ||
` | ||
|
||
exports[`test/lib/utils/sbom-spdx.js TAP single node - with license expression > must match snapshot 1`] = ` | ||
{ | ||
"spdxVersion": "SPDX-2.3", | ||
"dataLicense": "CC0-1.0", | ||
"SPDXID": "SPDXRef-DOCUMENT", | ||
"name": "[email protected]", | ||
"documentNamespace": "docns", | ||
"creationInfo": { | ||
"created": "2020-01-01T00:00:00.000Z", | ||
"creators": [ | ||
"Tool: npm/cli-10.0.0 " | ||
] | ||
}, | ||
"documentDescribes": [ | ||
"SPDXRef-Package-root-1.0.0" | ||
], | ||
"packages": [ | ||
{ | ||
"name": "root", | ||
"SPDXID": "SPDXRef-Package-root-1.0.0", | ||
"versionInfo": "1.0.0", | ||
"packageFileName": "", | ||
"downloadLocation": "NOASSERTION", | ||
"filesAnalyzed": false, | ||
"homepage": "NOASSERTION", | ||
"licenseDeclared": "(MIT OR Apache-2.0)", | ||
"externalRefs": [ | ||
{ | ||
"referenceCategory": "PACKAGE-MANAGER", | ||
"referenceType": "purl", | ||
"referenceLocator": "pkg:npm/[email protected]" | ||
} | ||
] | ||
} | ||
], | ||
"relationships": [ | ||
{ | ||
"spdxElementId": "SPDXRef-DOCUMENT", | ||
"relatedSpdxElement": "SPDXRef-Package-root-1.0.0", | ||
"relationshipType": "DESCRIBES" | ||
} | ||
] | ||
} | ||
` | ||
|
||
exports[`test/lib/utils/sbom-spdx.js TAP single node - with license object > must match snapshot 1`] = ` | ||
{ | ||
"spdxVersion": "SPDX-2.3", | ||
"dataLicense": "CC0-1.0", | ||
"SPDXID": "SPDXRef-DOCUMENT", | ||
"name": "[email protected]", | ||
"documentNamespace": "docns", | ||
"creationInfo": { | ||
"created": "2020-01-01T00:00:00.000Z", | ||
"creators": [ | ||
"Tool: npm/cli-10.0.0 " | ||
] | ||
}, | ||
"documentDescribes": [ | ||
"SPDXRef-Package-root-1.0.0" | ||
], | ||
"packages": [ | ||
{ | ||
"name": "root", | ||
"SPDXID": "SPDXRef-Package-root-1.0.0", | ||
"versionInfo": "1.0.0", | ||
"packageFileName": "", | ||
"downloadLocation": "NOASSERTION", | ||
"filesAnalyzed": false, | ||
"homepage": "NOASSERTION", | ||
"licenseDeclared": "MIT", | ||
"externalRefs": [ | ||
{ | ||
"referenceCategory": "PACKAGE-MANAGER", | ||
"referenceType": "purl", | ||
"referenceLocator": "pkg:npm/[email protected]" | ||
} | ||
] | ||
} | ||
], | ||
"relationships": [ | ||
{ | ||
"spdxElementId": "SPDXRef-DOCUMENT", | ||
"relatedSpdxElement": "SPDXRef-Package-root-1.0.0", | ||
"relationshipType": "DESCRIBES" | ||
} | ||
] | ||
} | ||
` | ||
|
||
exports[`test/lib/utils/sbom-spdx.js TAP single node - with single license > must match snapshot 1`] = ` | ||
{ | ||
"spdxVersion": "SPDX-2.3", | ||
"dataLicense": "CC0-1.0", | ||
"SPDXID": "SPDXRef-DOCUMENT", | ||
"name": "[email protected]", | ||
"documentNamespace": "docns", | ||
"creationInfo": { | ||
"created": "2020-01-01T00:00:00.000Z", | ||
"creators": [ | ||
"Tool: npm/cli-10.0.0 " | ||
] | ||
}, | ||
"documentDescribes": [ | ||
"SPDXRef-Package-root-1.0.0" | ||
], | ||
"packages": [ | ||
{ | ||
"name": "root", | ||
"SPDXID": "SPDXRef-Package-root-1.0.0", | ||
"versionInfo": "1.0.0", | ||
"packageFileName": "", | ||
"downloadLocation": "NOASSERTION", | ||
"filesAnalyzed": false, | ||
"homepage": "NOASSERTION", | ||
"licenseDeclared": "ISC", | ||
"externalRefs": [ | ||
{ | ||
"referenceCategory": "PACKAGE-MANAGER", | ||
"referenceType": "purl", | ||
"referenceLocator": "pkg:npm/[email protected]" | ||
} | ||
] | ||
} | ||
], | ||
"relationships": [ | ||
{ | ||
"spdxElementId": "SPDXRef-DOCUMENT", | ||
"relatedSpdxElement": "SPDXRef-Package-root-1.0.0", | ||
"relationshipType": "DESCRIBES" | ||
} | ||
] | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters