generated from 47ng/typescript-library-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 6
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 decryption of strings larger than 4 MiB #411
Merged
franky47
merged 5 commits into
47ng:next
from
aloisklink:fix-decryption-on-larger-strings
Sep 24, 2024
Merged
Fix decryption of strings larger than 4 MiB #411
franky47
merged 5 commits into
47ng:next
from
aloisklink:fix-decryption-on-larger-strings
Sep 24, 2024
Conversation
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
The `cloakedStringRegex` fails to parse ciphertexts larger than about 4 MiB. This is due to [limitations in V8's regex engine][1]. I've adapted the implementation from validatorjs/validator.js#503 under the MIT license, as it solves the error. [1]: https://issues.chromium.org/issues/42207207
This function can be used instead of `cloakedStringRegex` on large strings.
This regex fails on large 4 MiB + strings. `parseCloakedString` should be used instead when possible.
This fails in Node.JS v20.17.0 with @47ng/cloak v1.1.0.
franky47
approved these changes
Sep 24, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: LGTM, thanks for the extra care of adding tests and following SemVer!
franky47
reviewed
Sep 24, 2024
🎉 This PR is included in version 1.2.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
cloakedStringRegex
fails to parse ciphertexts that are somewhere above 4 MiB large on Node.JS v20.17.0. This is due to limitations in V8's regex engine.This causes an error:
I've adapted the
isBase64
function from validatorjs/validator.js#503 under the MIT license, as it solves the error by using a much simpler regex.Implementation details
By the way, I've split up this PR into:
fix:
commit (which fixes the bug), andfeat:
commits:one that exports the
parseCloakedString
function, and another thatdeprecates the
cloakedStringRegex
in favor of the parseCloakedString` function.This isn't actually a "feature", but Semantic Versioning 2.0.0 specifies that:
This should hopefully make a really nice release note in https://github.com/47ng/cloak/releases!
The
parseCloakedString
needs to be exported, so thatprisma-field-encryption
can use it instead of thecloakedStringRegex
: https://github.com/47ng/prisma-field-encryption/blob/c17354c747562857bf73fabe1c4c3a0c91380580/src/encryption.ts#L179