crypto: allow monkey patching of pseudoRandomBytes#24108
crypto: allow monkey patching of pseudoRandomBytes#24108Flarna wants to merge 2 commits intonodejs:masterfrom Flarna:crypto_patchable
Conversation
|
/CC @nodejs/crypto |
|
Hello @Flarna and thank you for the contribution. |
sam-github
left a comment
There was a problem hiding this comment.
LGTM. The monkey patchability of the API surface isn't usually tested or documented, so while I'm usually a big fan of both, I don't personally think its necessary in this case. I can't think of any other APIs where we document the reassignability of the function. Monkey-patchability isn't something we formally commit to, but in the interests of supporting APM vendors, if the maintenance cost is low I don't think we should get in its way, either. This change looks to me to have very low maintenance cost.
|
Sure, I can add tests. |
Af I see it most of our current monkey patchability was just emergent. This is a bit different since we are enabling this explicitly and so IMHO we should commit to. |
|
I think the main target of the initial change was just to have the APIs not enumerable. I think it would be good to define a guideline for deprecations like this to get a consistent API. |
|
@nodejs/security-wg |
|
Updated by setting also |
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching.
add test
|
Is there anything left I have to do with this PR? |
|
@Flarna No, sorry for the delay. CI: https://ci.nodejs.org/job/node-test-pull-request/18857/ |
|
Landed in f85d636 |
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: nodejs#24108 Refs: nodejs#22519 Refs: nodejs#23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: #24108 Refs: #22519 Refs: #23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: #24108 Refs: #22519 Refs: #23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Make `pseudoRandomBytes` and it's aliases `prng` and `rng` configurable to allow monkey patching. PR-URL: nodejs#24108 Refs: nodejs#22519 Refs: nodejs#23017 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
This change does not land cleanly on |
|
@BethGriggs This change is not applicable to |
Make
pseudoRandomBytesand it's aliasesprngandrngconfigurable to allow monkey patching.
Background: Some modules still use these deprecated APIs (see e.g.
#23013) and therefore these APIs are only pending deprecated. As APM
vendor we can't decide which modules customers so we need a way to
monitor also the aliases similar as the correct API. Current way to
do this is monkey patching.
Maybe we could even consider to set
writeable: true.If there are good arguments to keep it as it is I'm also fine with
closing this PR.
Refs: #22519
Refs: #23017
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes