cyberark / conjur

CyberArk Conjur automatically secures secrets used by privileged users and machine identities
https://conjur.org
Other
777 stars 123 forks source link

Rename TrustedProxyFilter class #2176

Open jtuttle opened 3 years ago

jtuttle commented 3 years ago

(copied over on behalf of Jonah):

I think the name TrustedProxyFilter is subtly inaccurate. A filter is something that takes a list, and returns a sublist (the filtered list) back.

In contrast, this (via the call method) takes a single IP and tells you if it's valid. It's essentially a big configurable function whose input is an IP and whose output is a boolean value. What would you name such a function?

Probably something like valid_ip?. However, since this is a class name (which can't end in ?) I'd consider something like class IsIpValid or class IsIpTrusted.

In client code:

is_trusted = IsIpTrusted.new(...)
if is_trusted(suspicious_ip)
   # etc....
micahlee commented 2 years ago

File to rename: https://github.com/cyberark/conjur/blob/155c92259c64fd49fc86bf6f5c4e0e0fc1e7544d/lib/conjur/trusted_proxy_filter.rb

Unit tests: https://github.com/cyberark/conjur/blob/155c92259c64fd49fc86bf6f5c4e0e0fc1e7544d/spec/lib/conjur/trusted_proxy_filter_spec.rb