Skip to content

lib: deprecate _tls_common and _tls_wrap #57643

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

Merged
merged 4 commits into from
May 10, 2025

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Mar 27, 2025

This PR is for runtime deprecation of the _tls_common and _tls_wrap modules

My hope is to manage to gradually deprecate the various _ modules that are not documented
and that should not be part of node.js' public API (for more context see: #57540 (comment))

Interestingly as you can see:
screenshot of the exports from '_tls_commonand_tls_wrap`
common and wrap expose respectively:

  • SecureContext
  • createSecureContext
  • translatePeerCertificate
    and
  • TLSSocket
  • Server
  • createServer
  • connect

All of these, seem to already being re-exported by node:tls:

node/lib/tls.js

Lines 389 to 394 in 186bbf7

exports.createSecureContext = _tls_common.createSecureContext;
exports.SecureContext = _tls_common.SecureContext;
exports.TLSSocket = _tls_wrap.TLSSocket;
exports.Server = _tls_wrap.Server;
exports.createServer = _tls_wrap.createServer;
exports.connect = _tls_wrap.connect;

the only exception being translatePeerCertificate (which I am not really very familiar with, but by the looks of it
seems like a rather simple function that can be re-implemented externally)

So I don't think that deprecating these modules should have huge impacts to users and that importing from
node:tls instead is a viable alternative

@BridgeAR 🙂👍

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 27, 2025
@dario-piotrowicz
Copy link
Member Author

dario-piotrowicz commented Mar 27, 2025

@BridgeAR I know you said that the runtime deprecation wasn't completely necessary but I really wanted to give it a shot (and I really like how it turned out 😄) I hope you don't mind 🙂

@dario-piotrowicz dario-piotrowicz force-pushed the dario/deprecate_tls branch 2 times, most recently from 6d4746b to 50c51bd Compare March 27, 2025 00:52
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

Attention: Patch coverage is 94.68846% with 104 lines in your changes missing coverage. Please review.

Project coverage is 90.18%. Comparing base (535c2f7) to head (f96445c).
Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/tls/wrap.js 94.38% 98 Missing and 2 partials ⚠️
lib/internal/tls/common.js 97.43% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57643      +/-   ##
==========================================
+ Coverage   90.12%   90.18%   +0.06%     
==========================================
  Files         629      631       +2     
  Lines      186638   186662      +24     
  Branches    36618    36656      +38     
==========================================
+ Hits       168202   168344     +142     
+ Misses      11222    11122     -100     
+ Partials     7214     7196      -18     
Files with missing lines Coverage Δ
lib/_tls_common.js 100.00% <100.00%> (+2.56%) ⬆️
lib/_tls_wrap.js 100.00% <100.00%> (+5.61%) ⬆️
lib/internal/crypto/x509.js 91.75% <100.00%> (ø)
lib/tls.js 95.93% <100.00%> (ø)
src/node_builtins.cc 79.17% <ø> (ø)
lib/internal/tls/common.js 97.43% <97.43%> (ø)
lib/internal/tls/wrap.js 94.38% <94.38%> (ø)

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@lpinca lpinca added the needs-citgm PRs that need a CITGM CI run. label Mar 27, 2025
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina added request-ci Add this label to start a Jenkins CI on a PR. semver-major PRs that contain breaking changes and should be released in the next major version. labels Apr 7, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 7, 2025
@nodejs-github-bot
Copy link
Collaborator

@dario-piotrowicz dario-piotrowicz force-pushed the dario/deprecate_tls branch 2 times, most recently from f09a338 to 15a47d9 Compare April 12, 2025 17:18
@nodejs-github-bot
Copy link
Collaborator

Type: Runtime

The `node:_tls_common` and `node:_tls_wrap` modules are deprecated as they should be considered
an internal nodejs implementation rather than a public facing API, use `node:tls` instead.
Copy link
Member

Choose a reason for hiding this comment

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

Just noting... it's an unfortunate truth that while these are deprecated we likely will never be able to actually remove them. See require('sys') ....

Copy link
Member Author

Choose a reason for hiding this comment

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

oh I see.. that's pretty disappointing 🥲 (although I understand the security implications...)

I like your suggestion of throwing an error though, it'd be pretty nice if we could do that at some point 🙂

Copy link
Member Author

@dario-piotrowicz dario-piotrowicz Apr 12, 2025

Choose a reason for hiding this comment

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

mh... or maybe the _ modules could be removed at some point since npm doesn't support such modules anyways? 🤔

#26292 (comment)
https://github.com/npm/validate-npm-package-name?tab=readme-ov-file#naming-rules

🤔

Copy link
Member

Choose a reason for hiding this comment

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

npm may not but an attacker could still locally inject a module which would still be problematic.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh I see what you mean... like with a postinstall script or something that drops an _ module in the node_modules right? 🤔

oh too bad then 😓 (but I am still hoping for the throwing idea! 😀)

@dario-piotrowicz dario-piotrowicz added the request-ci Add this label to start a Jenkins CI on a PR. label May 5, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 5, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@dario-piotrowicz dario-piotrowicz added the request-ci Add this label to start a Jenkins CI on a PR. label May 6, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 6, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

runtime deprecate the _tls_common and _tls_wrap
modules, users should use nust node:tls insteal
and internally internal/tls/commond and
internal/tls/wrap should be used instead
skip tests if crypo is missing
@anonrig anonrig added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. request-ci Add this label to start a Jenkins CI on a PR. labels May 7, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 7, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
Copy link
Member

Choose a reason for hiding this comment

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

Best to leave the trademark headers in place even if the rest is being removed

Copy link
Member Author

Choose a reason for hiding this comment

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

ok thanks 🙂

or should I move those to the new internal modules which contain the original copy-pasted code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copyright comments restored (into the new files): f96445c

I hope this works for you 🙏

@dario-piotrowicz dario-piotrowicz added the request-ci Add this label to start a Jenkins CI on a PR. label May 10, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 10, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@dario-piotrowicz dario-piotrowicz added the commit-queue Add this label to land a pull request using GitHub Actions. label May 10, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 10, 2025
@nodejs-github-bot nodejs-github-bot merged commit a822a1c into nodejs:main May 10, 2025
60 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in a822a1c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. needs-citgm PRs that need a CITGM CI run. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants