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.
browser-timezone-rails
Advanced tools
Rails Engine which sets the Rails timezone to the browser's configured timezone for each request.
Add it to your Gemfile.
gem 'browser-timezone-rails'
Make sure you have each of the following entries in your application.js:
//= require js.cookie
//= require browser_timezone_rails/set_time_zone
That's it! No other configuration is needed as it's all done for you with this gem including setting up your application controller to start using your users' zones.
The browser's timezone is set in a cookie using the modern ECMAScript Internationalization API
Caveat: doesn't work with Internet Explorer.
(Up to 1.0.4 version of the gem, the cookie was set via the jsTimezoneDetect javascript library, which, however, was often inaccurate.)
That cookie is then read during each request to set the Rails timezone for that user.
You can also read more about this implementation here: Blog
For those of you who need or want to do this on the backend with just Rails, Ryan Bates has a good RailsCast on how to that: RailsCast #106
The cookie is set each full page request and lives for 365 days
Yes. It uses the Rails Time.zone method which is thread safe.
The first request ever made by a user's browser to your app will not set the browser's time zone as the javascript that sets the cookie has not yet run on their browser. This will only happen once and for me it was not a problem.
To run the tests, invoke bundle exec rspec
.
FAQs
Unknown package
We found that browser-timezone-rails 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
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.