webtorrent / bittorrent-tracker

🌊 Simple, robust, BitTorrent tracker (client & server) implementation
https://webtorrent.io
MIT License
1.72k stars 314 forks source link

feat: updated webrtc implementation #519

Closed ThaUnknown closed 1 month ago

ThaUnknown commented 1 month ago

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update [ ] Bug fix [x] New feature [ ] Other, please explain:

What changes did you make? (Give an overview) Include WebRTC on node, drop wrtc Which issue (if any) does this pull request address?

Is there anything you'd like reviewers to focus on?

socket-security[bot] commented 1 month ago

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@thaunknown/simple-peer@10.0.4 None +1 105 kB thaunknown
npm/ip@2.0.1 None 0 15.5 kB indutny

🚮 Removed packages: npm/@thaunknown/simple-peer@9.12.1, npm/ip@1.1.9, npm/semantic-release@21.1.2, npm/socks@2.8.3, npm/standard@17.1.0, npm/string2compact@2.0.1, npm/tape@5.7.5, npm/uint8-util@2.2.5, npm/undici@5.28.4, npm/unordered-array-remove@1.0.2, npm/utf-8-validate@5.0.10, npm/webtorrent-fixtures@2.0.2, npm/wrtc@0.4.7, npm/ws@8.17.0

View full report↗︎

socket-security[bot] commented 1 month ago

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSource
Install scripts npm/node-datachannel@0.9.0
  • Install script: install
  • Source: prebuild-install -r napi || (npm install --ignore-scripts --production=false && npm run _prebuild)
  • orphan: npm/node-datachannel@0.9.0

View full report↗︎

Next steps

What is an install script?

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/node-datachannel@0.9.0
ThaUnknown commented 1 month ago

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package Note Source Install scripts npm/node-datachannel@0.7.0

  • Install script: install

  • Source: prebuild-install -r napi || (npm install --ignore-scripts --production=false && npm run _prebuild)

  • package.json

View full report↗︎

Next steps

What is an install script? Take a deeper look at the dependency Remove the package Mark a package as acceptable risk

@SocketSecurity ignore npm/node-datachannel@0.7.0

webtorrent-bot commented 1 month ago

:tada: This PR is included in version 11.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

jarylc commented 1 month ago

It seems after this change which indirectly depends on npm/node-datachannel@0.7.0, the total dependency size has shot up substantially from this dependency alone (likely due to the new compilation steps)

ncdu 1.20 ~ Use the arrow keys to navigate, press ? for help                                                                                                                                                                                                                                                     
--- /usr/local/lib/node_modules/bittorrent-tracker/node_modules ---
                                                          /..                                                                                                                                                                                                                                                    
  655.8 MiB [###########################################] /node-datachannel
    8.7 MiB [                                           ] /web-streams-polyfill
  772.0 KiB [                                           ] /utf-8-validate
  428.0 KiB [                                           ] /bufferutil
  316.0 KiB [                                           ] /ip-address
  268.0 KiB [                                           ] /semver
  228.0 KiB [                                           ] /socks
  220.0 KiB [                                           ] /@thaunknown
  212.0 KiB [                                           ] /event-target-shim
  188.0 KiB [                                           ] /readable-stream
  180.0 KiB [                                           ] /ws
  168.0 KiB [                                           ] /smart-buffer
  164.0 KiB [                                           ] /node-domexception
*Total disk usage: 670.2 MiB   Apparent size: 611.1 MiB   Items: 23506

In previous versions, web-streams-polyfill was the biggest dependency.

I think it's a good idea to take note of this.

EDIT:

RUN mkdir -p node-datachannel/build/Release/ && \
    mv node_modules/node-datachannel/package.json node_modules/node-datachannel/lib node-datachannel/ && \
    mv node_modules/node-datachannel/build/Release/node_datachannel.node node-datachannel/build/Release/ && \
    rm -rf node_modules/node-datachannel/ && \
    mv node-datachannel node_modules/

For now, I'm adding this to my Docker image build process after running install to remove all unused remnants of the build process

ThaUnknown commented 1 month ago

not sure what to tell you image

jarylc commented 1 month ago

not sure what to tell you image

Hmm that's very weird, maybe it's only on OSes that require compilation or some sort (Alpine Linux in this case)

Compilation seems to pulls the entire git repository of node-datachannel and that is where the bulk of the remnant files.

I did notice there was a prebuilt folder in the node module folder maybe it's using that for Windows and compiles on Linux.

ThaUnknown commented 1 month ago

I think this is something to bring up with node-datachannel, not webtorrent

jarylc commented 1 month ago

I think this is something to bring up with node-datachannel, not webtorrent

Yep do agree, will raise an issue there.