Skip to content

Commit

Permalink
root component gets a fallback name
Browse files Browse the repository at this point in the history
fix #252

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Feb 11, 2022
1 parent 26056b0 commit 372600f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion model/Bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ class Bom extends CycloneDXObject {
if (includeSerialNumber) {
this._serialNumber = 'urn:uuid:' + uuid.v4()
}
if (pkg) {
if (pkg && typeof pkg === 'object') {
if (!pkg.name) {
pkg = Object.assign({}, pkg) // work with a modified/fixed clone
pkg.name = 'NO-NAME-PACKAGE'
}
this._metadata = this.createMetadata(pkg, componentType)
this._components = this.listComponents(pkg, lockfile)
} else {
Expand Down
1 change: 1 addition & 0 deletions model/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class Component extends CycloneDXObject {
// bomRef defaults to PURL for backwards compatibility reasons
this.bomRef = this.purl
} else {
this.#name = '' // empty fallback just in case
this.#hashes = new HashList()
this.#externalReferences = new ExternalReferenceList()
}
Expand Down

0 comments on commit 372600f

Please sign in to comment.