
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Rails middleware for observing of RSS memory changes around the request. Under the hood, it utilizes the get_process_mem gem.
Add the line
gem 'rss_observer'
to your Gemfile and run bundle install.
To use this middleware in a Rails application, modify relevant environment file (or application.rb to log rss in all environments).
You can use the supplied STDOUT logger and insert the RssObserver middleware after Rails::Rack::Logger
.
require 'rss_observer/logger_handler'
module FooApp
class Application < Rails::Application
# ...
config.middleware.insert_after Rails::Rack::Logger, RssObserver::Middleware, RssObserver::LoggerHandler.new
end
end
More realistically, you'll need something more production-ready.
You can prepare a custom class that will make use of Rails.logger
, that, with request_id in log tags will allow you to match
the usage log with actual request logs.
# lib/rails_logger_handler.rb
class RailsLoggerHandler
def initial_memory(kilobytes)
Thread.current[:_initial_memory] = kilobytes
end
def final_memory(kilobytes)
Rails.logger.info "Memory change: #{final_memory - Thread.current[:_initial_memory]} KB"
end
end
# config/application.rb
require_relative '../lib/rails_logger_handler'
module FooApp
class Application < Rails::Application
# ...
config.log_tags = [:request_id]
config.middleware.insert_after Rails::Rack::Logger, RssObserver::Middleware, RailsLoggerHandler.new
end
end
RssObserver vs Default Rails request logs
I, [2019-09-03T14:56:22.735264 #7290] INFO -- : [96956f1a-7f7f-4836-a8a1-bc3c05696433] Completed 200 OK in 47ms (Views: 29.7ms | ActiveRecord: 6.3ms | Allocations: 18614)
I, [2019-09-03T14:56:22.737113 #7290] INFO -- : [96956f1a-7f7f-4836-a8a1-bc3c05696433] Memory change: 264.0 KB
FAQs
Unknown package
We found that rss_observer 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.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.