Remove crypto.randomUUID dependency in favor of a custom function#1016
Conversation
crypto.randomUUID dependency in favor of a custom function
|
|
||
| const wpContent = joinPaths(await playground.documentRoot, 'wp-content'); | ||
| const tmpDir = joinPaths(wpContent, crypto.randomUUID()); | ||
| const tmpDir = joinPaths(wpContent, randomString(46)); |
There was a problem hiding this comment.
[ Question ] Why we increased the characters we are using in comparison with UUID?
UUID has 36 + 4 characters instead of 46.
Can we change that to be 40 instead?
There was a problem hiding this comment.
Thanks for the correction. UUID actually is 36 characters long. Example 'd6c556d6-32b8-4bdf-b338-20a16e9860aa'.
A string containing a randomly generated, 36 character long v4 UUID.
https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID
I added a default length of 36 to randomString function.
|
Thank you @sejas! One caveat would be that |
|
@adamziel, Right!, I improved |
|
While I understand that the Playground has its own limited risk for security, I'm a bit surprised we removed a cryptographically-secure source of randomness in favor of one without that. Did we perform an audit to ensure that we don't need better randomness in the app? If all we're doing is creating a temporary filename for an in-memory database it seems harmless, but if we're using this for anything related to sensitive content then we may want to ensure we limit the use of this custom generator and warn people that it provides no cryptographic value. |
|
@dmsnell I agree. This PR is strictly about creating temporary files with random names, not cryptographic security. For anything security related we’ll still need to use crypto. |
What is this PR doing?
cryptoto Polyfills improving Blueprint compatibility for Node #1000randomStringfromremotepackage to@php-wasm/utilrandomFilenamecrypto.randomUUIDwithrandomFilename()What problem is it solving?
cryptois a library that is available, but needs to be imported on node apps.How is the problem addressed?
It replaces the function that generates a random value with our custom library
Testing Instructions