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.
Ever wondered which translations are being looked up by Rails, a gem, or simply your app? Wonder no more!
Rails' implicit translations, for instance, are a nice feature. But sometimes
getting the key to, let's say, the BillingAddress
' street
attribute in
a nested form inside an Order
can be quite tricky to get right on the first
try. The key for this example would be
activerecord.attributes.order/billing_address.street
. Good luck figuring that
out!
With this gem you can easily see which translations are being looked up. The key above would have created the following debug log entry:
[i18n-debug] activerecord.attributes.order/billing_address.name => nil
After setting the translation for that key you just discovered, the log entry changes to this:
[i18n-debug] activerecord.attributes.order/billing_address.name => "Order billing name"
Simply add the gem to your Gemfile
. You probably only want this in development.
Thus, place it inside the development
group.
gem 'i18n-debug', group: :development
If you need support for ruby <= 2.0, make sure to use version 1.0.0.
This gem works straight out of the box. If Rails is available, it will log using
Rails.logger.debug
. Otherwise it will log using Logger.new($stdout).debug
.
If you wish to use a custom logger, simply set it as follows (make sure it
responds to debug
):
I18n::Debug.logger = my_custom_logger
Every lookup invokes the lambda I18n::Debug.on_lookup
with the key and the
translation value as arguments. The default lambda simply logs it to the logger
mentioned above. If you want to change the logging format or do something
totally different, simply set your own handler to do so:
# Collect stats on I18n key usage.
i18n_stats = Hash.new { |stats, key| stats[key] = 0 }
I18n::Debug.on_lookup do |key, value|
i18n_stats[key] += 1 if value
end
Philipe Fatio (fphilipe)
MIT License. Copyright 2014 Philipe Fatio
FAQs
Unknown package
We found that i18n-debug 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.