Socket
Book a DemoInstallSign in
Socket

firewall_constraint

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firewall_constraint

0.1.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

FirewallConstraint

Build Status

Easy whitelist firewalling for Rails 3+4 route constraints

gem 'firewall_constraint'

Or:

gem install firewall_constraint

##Example

config/routes.rb:

get 'dummy/index' => 'dummy#index'
get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint.new

constraints FirewallConstraint.new do
  get 'dummy/blocked_by_block' => 'dummy#blocked_by_block'
end

constraints FirewallConstraint.new(['127.0.0.1']) do
  get 'dummy/blocked_by_dynamic' => 'dummy#blocked_by_dynamic'
end

constraints FirewallConstraint.new(Proc.new{['127.0.0.1']}) do
  get 'dummy/blocked_by_proc'
end

##Configuration

Uses a config file if ips are not provided on instantiation

config/firewall_constraint.yml:

test:
  - 10.0.0.0/8

##Advanced Usage

You can also do DB-based whitelisting using the Proc-based whitelisting method:

app/models/valid_ip.rb:

class ValidIp < ActiveRecord::Base
end

config/routes.rb:

constraints FirewallConstraint.new(Proc.new{ValidIp.pluck(:ip)}) do
  get '/blah'
end

##Notes

Because parsing IPs with the IPAddress can take some time, this gem will only reparse ips returned by the Proc method if they have changed. Make sure you return your ips in the same order to avoid unnecessary reparsing.

FAQs

Package last updated on 22 May 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.