Fixes finterprint filter handling of timestamp field

Fixes #1572
This commit is contained in:
Tray Torrance 2014-08-04 11:14:11 -07:00 committed by Joao Duarte
parent 4211522de1
commit bf953f0f90
2 changed files with 38 additions and 3 deletions

View file

@ -90,15 +90,15 @@ class LogStash::Filters::Fingerprint < LogStash::Filters::Base
def anonymize_openssl(data) def anonymize_openssl(data)
digest = encryption_algorithm() digest = encryption_algorithm()
# in JRuby 1.7.11 outputs as ASCII-8BIT # in JRuby 1.7.11 outputs as ASCII-8BIT
OpenSSL::HMAC.hexdigest(digest, @key, data).force_encoding(Encoding::UTF_8) OpenSSL::HMAC.hexdigest(digest, @key, data.to_s).force_encoding(Encoding::UTF_8)
end end
def anonymize_murmur3(value) def anonymize_murmur3(value)
case value case value
when Fixnum when Fixnum
MurmurHash3::V32.int_hash(value) MurmurHash3::V32.int_hash(value)
when String else
MurmurHash3::V32.str_hash(value) MurmurHash3::V32.str_hash(value.to_s)
end end
end end

View file

@ -164,4 +164,39 @@ describe LogStash::Filters::Fingerprint do
end end
end end
context 'Timestamps' do
epoch_time = Time.at(0).gmtime
describe 'OpenSSL Fingerprinting' do
config <<-CONFIG
filter {
fingerprint {
source => ['@timestamp']
key => '0123'
method => 'SHA1'
}
}
CONFIG
sample("@timestamp" => epoch_time) do
insist { subject["fingerprint"] } == '1d5379ec92d86a67cfc642d55aa050ca312d3b9a'
end
end
describe 'MURMUR3 Fingerprinting' do
config <<-CONFIG
filter {
fingerprint {
source => ['@timestamp']
method => 'MURMUR3'
}
}
CONFIG
sample("@timestamp" => epoch_time) do
insist { subject["fingerprint"] } == 743372282
end
end
end
end end