From 19eeb0517cfb589cb8bc2e502127fc5b40e25bd9 Mon Sep 17 00:00:00 2001 From: Ajay Veluvolu Date: Wed, 9 Feb 2022 20:12:14 -0500 Subject: [PATCH] Rename the TrustedProxyFilter class to IsIpTrusted --- config/initializers/trusted_proxies.rb | 2 +- lib/conjur/{trusted_proxy_filter.rb => is_ip_trusted.rb} | 8 ++++---- ...trusted_proxy_filter_spec.rb => is_ip_trusted_spec.rb} | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename lib/conjur/{trusted_proxy_filter.rb => is_ip_trusted.rb} (88%) rename spec/lib/conjur/{trusted_proxy_filter_spec.rb => is_ip_trusted_spec.rb} (72%) diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb index 141caa0ad6..d20c751a52 100644 --- a/config/initializers/trusted_proxies.rb +++ b/config/initializers/trusted_proxies.rb @@ -6,7 +6,7 @@ disable_cache = config.respond_to?(:conjur_disable_trusted_proxies_cache) && config.conjur_disable_trusted_proxies_cache - Rack::Request.ip_filter = Conjur::TrustedProxyFilter.new( + Rack::Request.ip_filter = Conjur::IsIpTrusted.new( config: Rails.application.config.conjur_config, disable_cache: disable_cache ) diff --git a/lib/conjur/trusted_proxy_filter.rb b/lib/conjur/is_ip_trusted.rb similarity index 88% rename from lib/conjur/trusted_proxy_filter.rb rename to lib/conjur/is_ip_trusted.rb index a207c7e9dd..a95428774e 100644 --- a/lib/conjur/trusted_proxy_filter.rb +++ b/lib/conjur/is_ip_trusted.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Conjur - # TrustedProxyFilter wraps the default Rack IP filtering. This allows + # IsIpTrusted wraps the default Rack IP filtering. This allows # the trusted proxies to be configured using the environment variable, # `TRUSTED_PROXIES`. # @@ -9,7 +9,7 @@ module Conjur # addresses or IP address ranges using CIDR notation. # # Example: TRUSTED_PROXIES=4.4.4.4,192.168.100.0/24 - class TrustedProxyFilter + class IsIpTrusted def initialize(config:, disable_cache: true) @config = config @disable_cache = disable_cache @@ -47,8 +47,8 @@ def configured_trusted_proxies return [] unless trusted_proxies - Set.new(trusted_proxies). - map { |cidr| IPAddr.new(cidr.strip) } + Set.new(trusted_proxies) + .map { |cidr| IPAddr.new(cidr.strip) } end end end diff --git a/spec/lib/conjur/trusted_proxy_filter_spec.rb b/spec/lib/conjur/is_ip_trusted_spec.rb similarity index 72% rename from spec/lib/conjur/trusted_proxy_filter_spec.rb rename to spec/lib/conjur/is_ip_trusted_spec.rb index 7ae6eee691..92de700091 100644 --- a/spec/lib/conjur/trusted_proxy_filter_spec.rb +++ b/spec/lib/conjur/is_ip_trusted_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -describe Conjur::TrustedProxyFilter do +describe Conjur::IsIpTrusted do it "does not raise an exception when created with valid IP addresses" do config = Conjur::ConjurConfig.new(trusted_proxies: '127.0.0.1') expect { - Conjur::TrustedProxyFilter.new(config: config) + Conjur::IsIpTrusted.new(config: config) }.not_to raise_error end end