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.
Query Diet counts the number of database queries for the last request and subtly displays it in the upper right corner of your screen. The display turns red if too many queries are run, or if they take too long. This is useful to prevent N + 1 queries from creeping into your code.
This is Query Diet being happy about 3 requests taking 66ms:
This is Query Diet being angry about 103 requests taking 164ms:
Add it to your Gemfile with
gem 'query_diet', group: :development
Now add the widget to your application layout, like
# app/views/layout/application.html.erb
# ...
<body>
<%= query_diet_widget if Rails.env.development? %>
<%= yield %>
</body>
We recommend you only use the gem with the development environment.
You can define when the counter turns into a red warning. The default threshold is 8 queries and 5000 miliseconds.
To change the default, simply pass them to the query_diet_widget
helper:
<%= query_diet_widget(:bad_count => 4, :bad_time => 2000) %>
You can pass whether to use a nonce for style and script tags.
Note that the key must be a symbol like in the example below, otherwise it defaults to false
.
<%= query_diet_widget(:nonce => true) if Rails.env.development? %>
In your content security policy initializer of the project you should set the nonce to those directives:
Rails.application.config.content_security_policy_nonce_directives = %w[script-src style-src]
When you do not want to use a nonce, but use a style tag, for example, you could use unsafe_inline
:
Rails.application.config.content_security_policy do |policy|
policy.style_src :self, :unsafe_inline
The gem is tested to work with Rails 3.2+ and Ruby 2.5.8+.
For Rails 2.3 and Ruby 1.8.7 support, use a version < 0.6.
FAQs
Unknown package
We found that query_diet demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.