-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Disallow destructuring internalbinding c #54023
Disallow destructuring internalbinding c #54023
Conversation
Review requested:
|
I have created the typings for crypto, I don't mind creating the rest, but I wanted to check that I had the correct approach |
typings/internalBinding/crypto.d.ts
Outdated
setFipsCrypto(bool: boolean): void; | ||
getSSLCiphers(): unknown; | ||
getRootCertificates(): unknown; | ||
} |
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.
Can you make sure all files have an EOL?
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.
Done!
Isn't this something that only matter for certain internal bindings that use the binding object as a receiver, and doesn't apply to all binding objects? Disallowing destructing on all other unrelated bindings would lead to a perf cost and for bindings that are public, this allows users to modify them and affect internals. |
I think a better way to enforce the fast API dependency on creation context may be - do not use the receiver. Just make that part of the API - always pass the binding object as the first argument. The linter configs that disallow destructing is not strong enough - someone can still do |
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.
lgtm
@@ -27,22 +27,10 @@ const { | |||
|
|||
const tls = require('tls'); | |||
|
|||
const { | |||
codes: { | |||
ERR_TLS_INVALID_PROTOCOL_VERSION, |
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.
Destructing symbols and constants should be safe and disallowing this could be way too verbose.
@joyeecheung I'm happy to implement your approach, but I'd need some guidance on how to do it and how to identify which bindings need to enforce it |
@anonrig can you help me unblock this? |
Basically, look for all the fast APIs (you can probably easily find them by searching |
@joyeecheung I created a draft PR with the changes for |
Closing in favour of #54408 |
follow up of #53947