Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ All notable changes to this project will be documented in this file.
* Fixed
* No longer omit components' version's buildID ([#551] via [#597])
Only affects NPM>=7. NPM6 omits this information in the first place, still.
* Misc
* Utilize SerialNumber generator from [`@cyclonedx/cyclonedx-library@^1.13`](https://github.com/CycloneDX/cyclonedx-javascript-library/releases/tag/v1.13.0) (via [#599])
The previously used _internal_ code was donated to that library.

[#551]: https://github.com/CycloneDX/cyclonedx-node-npm/issues/551
[#597]: https://github.com/CycloneDX/cyclonedx-node-npm/pull/597
[#599]: https://github.com/CycloneDX/cyclonedx-node-npm/pull/599

## 1.9.1 - 2023-03-15

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}
],
"dependencies": {
"@cyclonedx/cyclonedx-library": "^1.4.0",
"@cyclonedx/cyclonedx-library": "^1.13.0",
"commander": "^10.0.0",
"normalize-package-data": "^3||^4||^5",
"xmlbuilder2": "^3.0.2"
Expand Down
20 changes: 2 additions & 18 deletions src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
Copyright (c) OWASP Foundation. All Rights Reserved.
*/

import { type Builders, Enums, type Factories, Models } from '@cyclonedx/cyclonedx-library'
import { type Builders, Enums, type Factories, Models, Utils } from '@cyclonedx/cyclonedx-library'
import { existsSync } from 'fs'
import normalizePackageData from 'normalize-package-data'
import { type PackageURL } from 'packageurl-js'
Expand Down Expand Up @@ -225,7 +225,7 @@ export class BomBuilder {
}

if (!this.reproducible) {
bom.serialNumber = this.makeRandomSerialNumber()
bom.serialNumber = Utils.BomUtility.randomSerialNumber()
bom.metadata.timestamp = new Date()
}

Expand Down Expand Up @@ -491,22 +491,6 @@ export class BomBuilder {
}
}

private makeRandomSerialNumber (): string {
const b = [
Math.round(Math.random() * 0xFFFF),
Math.round(Math.random() * 0xFFFF),
Math.round(Math.random() * 0xFFFF),
// UUID version 4
Math.round(Math.random() * 0x0FFF) | 0x4000,
// UUID version 4 variant 1
Math.round(Math.random() * 0x3FFF) | 0x8000,
Math.round(Math.random() * 0xFFFF),
Math.round(Math.random() * 0xFFFF),
Math.round(Math.random() * 0xFFFF)
].map(n => n.toString(16).padStart(4, '0'))
return `urn:uuid:${b[0]}${b[1]}-${b[2]}-${b[3]}-${b[4]}-${b[5]}${b[6]}${b[7]}`
}

private * makeTools (): Generator<Models.Tool> {
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
const packageJsonPaths = ['../package.json']
Expand Down