Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-4960): UUID validation too strict #572

Merged
merged 11 commits into from
Apr 24, 2023

Conversation

nbbeeken
Copy link
Contributor

Description

What is changing?

Our UUID class generates UUID v4 instances but it does not need to contain only v4. We lift the validation on the version byte entirely here to support all uuid versions and "empty" uuid.

Is there new documentation needed for these changes?

What is the motivation for this change?

Double check the following

  • Ran npm run lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken changed the title NODE-4960-uuid-validation fix(NODE-4960): UUID validation too strict Apr 20, 2023
@nbbeeken nbbeeken marked this pull request as ready for review April 20, 2023 18:58
src/binary.ts Outdated
@@ -485,6 +471,26 @@ export class UUID extends Binary {
return new UUID(ByteUtils.fromBase64(base64));
}

/** @internal */
static uuidBytesFromString(representation: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming is redundant here since it's a static UUID method

Suggested change
static uuidBytesFromString(representation: string) {
static bytesFromString(representation: string) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM


/**
* A class representation of the BSON UUID type.
* @public
*/
export class UUID extends Binary {
static cacheHexString: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this safely be removed? It's a public property

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, added it back and filed follow ups, we can deprecate it in the subtask I made and remove in v6

test/node/tools/utils.js Outdated Show resolved Hide resolved
test/node/uuid.test.ts Show resolved Hide resolved
test/node/uuid.test.ts Outdated Show resolved Hide resolved
src/binary.ts Outdated Show resolved Hide resolved
src/binary.ts Show resolved Hide resolved
@nbbeeken nbbeeken requested a review from addaleax April 24, 2023 14:58
addaleax
addaleax previously approved these changes Apr 24, 2023
@baileympearson baileympearson added the Team Review Needs review from team label Apr 24, 2023
@baileympearson baileympearson self-assigned this Apr 24, 2023
@baileympearson baileympearson merged commit d239cd1 into main Apr 24, 2023
@baileympearson baileympearson deleted the NODE-4960-uuid-validation branch April 24, 2023 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
3 participants