Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
It's a simple Ruby gem to get a random TCP port.
First, install it:
gem install random-port
Then, use it like this, to reserve a random TCP port:
require 'random-port'
port = RandomPort::Pool.new.acquire
The Pool
guarantees that the port won't be used again. You can put
the port back to the pool after usage:
RandomPort::Pool.new.acquire do |port|
# Use the TCP port. It will be returned back
# to the pool afterwards.
end
You can do it without the block:
pool = RandomPort::Pool.new
port = pool.acquire
pool.release(port)
You can also use a pre-defined Pool::SINGLETON
singleton:
RandomPort::Pool::SINGLETON.acquire do |port|
# Use it here...
end
The pool is thread-safe by default.
You can configure it to be
not-thread-safe, using optional sync
argument of the constructor.
Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 2.3+ and Bundler installed. Then:
bundle update
bundle exec rake
If it's clean and you don't see any error messages, submit your pull request.
FAQs
Unknown package
We found that random-port demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.