Skip to content

Commit

Permalink
Rename 'anonymize' to 'fingerprint' in functions
Browse files Browse the repository at this point in the history
This reflects the name and purpose of the plugin.

Fixes #37
  • Loading branch information
praseodym authored and jakelandis committed Jun 19, 2018
1 parent dc3623c commit ecca47b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/logstash/filters/fingerprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def register
# convert to symbol for faster comparisons
@method = @method.to_sym

# require any library and set the anonymize function
# require any library and set the fingerprint function
case @method
when :IPV4_NETWORK
if @key.nil?
Expand All @@ -90,9 +90,9 @@ def register
:error => "Key value is empty. please fill in a subnet prefix length"
)
end
class << self; alias_method :anonymize, :anonymize_ipv4_network; end
class << self; alias_method :fingerprint, :fingerprint_ipv4_network; end
when :MURMUR3
class << self; alias_method :anonymize, :anonymize_murmur3; end
class << self; alias_method :fingerprint, :fingerprint_murmur3; end
when :UUID
# nothing
when :PUNCTUATION
Expand All @@ -106,7 +106,7 @@ class << self; alias_method :anonymize, :anonymize_murmur3; end
:error => "Key value is empty. Please fill in an encryption key"
)
end
class << self; alias_method :anonymize, :anonymize_openssl; end
class << self; alias_method :fingerprint, :fingerprint_openssl; end
@digest = select_digest(@method)
end
end
Expand Down Expand Up @@ -137,14 +137,14 @@ def filter(event)
end
to_string << "|"
@logger.debug? && @logger.debug("String built", :to_checksum => to_string)
event.set(@target, anonymize(to_string))
event.set(@target, fingerprint(to_string))
else
@source.each do |field|
next unless event.include?(field)
if event.get(field).is_a?(Array)
event.set(@target, event.get(field).collect { |v| anonymize(v) })
event.set(@target, event.get(field).collect { |v| fingerprint(v) })
else
event.set(@target, anonymize(event.get(field)))
event.set(@target, fingerprint(event.get(field)))
end
end
end
Expand All @@ -154,12 +154,12 @@ def filter(event)

private

def anonymize_ipv4_network(ip_string)
def fingerprint_ipv4_network(ip_string)
# in JRuby 1.7.11 outputs as US-ASCII
IPAddr.new(ip_string).mask(@key.to_i).to_s.force_encoding(Encoding::UTF_8)
end

def anonymize_openssl(data)
def fingerprint_openssl(data)
# in JRuby 1.7.11 outputs as ASCII-8BIT
if @base64encode
hash = OpenSSL::HMAC.digest(@digest, @key, data.to_s)
Expand All @@ -169,7 +169,7 @@ def anonymize_openssl(data)
end
end

def anonymize_murmur3(value)
def fingerprint_murmur3(value)
case value
when Fixnum
MurmurHash3::V32.int_hash(value)
Expand Down

0 comments on commit ecca47b

Please sign in to comment.