fix: ensure integer bomref discrimination #926
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The discriminator previously used
str(random())pieces, which could emit scientific notation (e.g..756153012152602e-05) and generate invalid BOM ref fragments.uuid4()gives ~122 bits of entropy (non-crypto), compared to ~53 bits fromrandom.random(), and the prior decimal-string slicing wasted some of those bits while allowing scientific notation.Went with
uuid4after exploring in-memory addresses like the JavaScript CycloneDX library and the PHP CycloneDX library which uses a time based approach.A generalized approach for
BomRefemission would be nice I think. Both from a resulting format and generation standpoint. Specifically:uniqidwhich is time based and results in a timestamp in microseconds expressed in hex suffixed by a random digitmath.random()which emits two dot separated 16 digits integer, sometimes in scientific notationInstead of having custom implementations for each library offering support for CycloneDX, they could all rely on unique identifiers such as
uuid4which is natively supported by each language. This would offer strong guarantees of uniqueness along with a common format.