Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Heavily tested, but simple filelocking solution using flock command. It guarantees unlocking of files.
It works for sure on MRI 1.8, 1.9, 2.0, JRuby in both 1.8 and 1.9 mode, and Rubinius.
This gem doesn't support NFS. You can use it with GlusterFS, though.
Filelock '/tmp/path/to/lock' do
# do blocking operation
end
You can also pass the timeout for blocking operation (default is 60 seconds):
Filelock '/tmp/path/to/lock', :timeout => 10 do
# do blocking operation
end
You can detect timeout by catching Filelock::ExecTimeout
.
You can also pass a wait timeout for grabbing the lock (default is 1 day):
Filelock '/tmp/path/to/lock', :wait => 3600 do
# do blocking operation
end
You can detect this kind of timeout by catching Filelock::WaitTimeout
.
Note that lock file directory must already exist, and lock file is not removed after unlock.
Filelock '/tmp/path/to/lock' do |file|
file.truncate
file.write Process.pid
end
Does it support NFS?
No. You can use more complex lockfile gem if you want to support NFS.
The code is so short. Why shouln't I just copy-paste it?
Because even such short code can have issues in future. File locking is very fragile operation. You may expect new releases of this gem fixing discovered bogus behavior (or introducing awesome features).
You are encouraged to use it if you develop gem that uses flock command, and care about running it on different ruby versions and platforms. Each has its own quirks with regard to flock command.
How it's different from lockfile gem?
Lockfile is filelocking solution handling NFS filesystems, based on homemade locking solution. Filelock uses flock UNIX command to handle filelocking on very low level. Also lockfile allows you to specify retry timeout. In case of Ruby's flock command this is hard-cored to 0.1 seconds.
How it's different from cleverua-lockfile gem?
Cleverua removes lockfile after unlocking it. Thas has been proven fatal both in my tests and in filelocking advices from the Internet. You could try find a way to remove lock file without breaking Filelock tests. I will be glad to accept such pull-request.
Try to break Filelock in some way (note it doesn't support NFS).
Filelock is MIT-licensed. You are awesome.
FAQs
Unknown package
We found that filelock demonstrated a not healthy version release cadence and project activity because the last version was released 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.