Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore error in parsing remote address #230

Merged
merged 2 commits into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/web_console/whitelist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def initialize(networks = nil)

def include?(network)
@networks.any? { |whitelist| whitelist.include?(network.to_s) }
rescue IPAddr::InvalidAddressError
false
end

def to_s
Expand Down
6 changes: 6 additions & 0 deletions test/web_console/whitelist_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class WhitelistTest < ActiveSupport::TestCase
assert_includes whitelisted_ips, "192.168.0.#{n}"
end
end

test 'ignore an unix socket' do
whitelisted_ips = whitelist('8.8.8.8')

assert_not_includes whitelisted_ips, 'unix:'
end

test 'can be represented in a human readable form' do
assert_includes whitelist.to_s, '127.0.0.0/127.255.255.255, ::1'
Expand Down