
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
levo_rails_middleware
Advanced tools
A lightweight, high-performance middleware for mirroring your Rails application API traffic to the Levo.ai platform for API security analysis.
The Levo Rails Traffic Middleware captures HTTP requests and responses from your Rails application and securely sends them to the Levo.ai platform. This enables Levo.ai to provide API security analysis, identify vulnerabilities, and help protect your applications without requiring code changes or impacting performance.
Key features:
Add this line to your application's Gemfile:
gem 'levo_rails_middleware', git: 'https://github.com/levoai/levo-rails-traffic-middleware.git'
Then execute:
$ bundle update
After installing the gem, you need to:
Create an initializer file at config/initializers/levo_middleware.rb
:
require 'levo_rails_middleware'
LevoRailsMiddleware.configure do |config|
# Required: URL for the Levo.ai traffic collector
config.remote_url = ENV['LEVO_SATELLITE_URL']
# Optional configuration with defaults shown
config.sampling_rate = 1.0 # 100% of traffic
config.exclude_paths = ['/assets/', '/packs/', '/health']
config.filter_params = ['password', 'token', 'api_key', 'secret']
config.size_threshold_kb = 1024 # Skip bodies larger than 1MB config.timeout_seconds = 3
config.enabled = true
end
# Add the middleware to the Rails stack
LevoRailsmiddleware.instrument(Rails.application.config)
In your config/application.rb
file, add:
module YourApp
class Application < Rails::Application
# ... other configurations ...
# Add the Levo.ai traffic mirroring middleware
require 'levo_rails_middleware'
LevoRailsmiddleware.instrument(config)
end
end
For Heroku applications, you'll need to set the environment variable for the Levo middleware URL:
heroku config:set LEVO_SATELLITE_URL='https://collector.levo.ai (Replace with your own Satellite url'
heroku config:set LEVOAI_ORG_ID='your-org-id'
heroku config:set LEVO_ENV='your-environment-name, like Production or Staging'
Option | Description | Default |
---|---|---|
remote_url | The URL to send mirrored traffic to | ENV['LEVO_SATELLITE_URL'] |
sampling_rate | Percentage of requests to mirror (0.0 to 1.0) | 1.0 (100%) |
exclude_paths | Array of path prefixes to exclude from mirroring | ['/assets/', '/packs/', '/health'] |
filter_params | Array of parameter names to filter (sensitive data) | ['password', 'token', 'api_key', 'secret'] |
size_threshold_kb | Maximum size (KB) for request/response bodies | 1024 (1MB) |
timeout_seconds | Timeout for sending data to Levo.ai | 3 |
enabled | Toggle to enable/disable the middleware | true |
You may want to enable the middleware only in certain environments:
# In config/initializers/levo_middleware.rb
LevoRailsMiddleware.configure do |config|
config.remote_url = ENV['LEVO_SATELLITE_URL']
config.enabled = Rails.env.production? || Rails.env.staging?
end
You can specify additional sensitive parameters to filter:
LevoRailsMiddleware.configure do |config|
config.filter_params = ['password', 'token', 'api_key', 'secret', 'ssn', 'credit_card']
end
For high-traffic applications, you can reduce the sampling rate:
LevoRailsMiddleware.configure do |config|
# Mirror only 10% of traffic
config.sampling_rate = 0.1
end
To verify the middleware is properly installed, check your logs for entries containing LEVO_MIRROR
when your application receives traffic.
No data appearing in Levo.ai dashboard
LEVO_SATELLITE_URL
is correctLEVO_MIRROR
Performance Impact
The middleware is designed to have minimal impact on your application's performance. If you notice any impact:
exclude_paths
list to skip more endpointssize_threshold_kb
to skip large payloadsFor questions or issues, contact Levo.ai support at support@levo.ai or visit help.levo.ai.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that levo_rails_middleware demonstrated a healthy version release cadence and project activity because the last version was released less than 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
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
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.