
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
This gem correctly configures Rails for Imperva so that request.remote_ip
/ request.ip
both work correctly.
This gem requires railties
, activesupport
, and actionpack
>= 5.2
.
For Rails 5.0
and 5.1
use 2.0.0
.
For Rails 4.2
use 0.1.x
.
Add this line to your application's Gemfile
:
group :production do
# or :staging or :beta or whatever environments you are using imperva in.
# you probably don't want this for :test or :development
gem 'imperva-rails'
end
And then execute:
$ bundle
Using Imperva means it's hard to identify the IP address of incoming requests since all requests are proxied through Imperva's infrastructure. Imperva provides a Incap-Client-IP header which can be used to identify the originating IP address of a request. However, this header alone doesn't verify a request is legitimate. If an attacker has found the actual IP address of your server they could spoof this header and masquerade as legitimate traffic.
imperva-rails
mitigates this attack by checking that the originating ip address of any incoming connection is from one of Imperva's ip address ranges. If so, the incoming X-Forwarded-For
header is trusted and used as the ip address provided to rack
and rails
(via request.ip
and request.remote_ip
). If the incoming connection does not originate from a Imperva server then the X-Forwarded-For
header is ignored and the actual remote ip address is used.
This codef will fetch Imperva's current IPv4 and IPv6 list, store them in Rails.cache
, and add them to config.imperva.ips
. The X-Forwarded-For
header will then be trusted only from those ip addresses.
You can configure the HTTP timeout
and expires_in
cache parameters inside of your rails config:
config.imperva.expires_in = 12.hours # default value
config.imperva.timeout = 5.seconds # default value
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/modosc/imperva-rails.
FAQs
Unknown package
We found that imperva-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.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.