forked from npm/cli
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly handle license objects in SBOM generation
As a means to resolve npm#6966, we can tweak the way we handle licenses, where receiving a license object, instead of license string, results in a malformed SPDX JSON SBOM. While working on this, it was noted that CycloneDX also needed to be amended, as it was omitting any license objects. Closes npm#6966.
- Loading branch information
1 parent
002be85
commit e2134d5
Showing
6 changed files
with
149 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 |
---|---|---|
|
@@ -550,6 +550,51 @@ exports[`test/lib/utils/sbom-spdx.js TAP single node - with license expression > | |
} | ||
` | ||
|
||
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", | ||
|
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