mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
4211522de1
commit
bf953f0f90
2 changed files with 38 additions and 3 deletions
|
@ -90,15 +90,15 @@ class LogStash::Filters::Fingerprint < LogStash::Filters::Base
|
|||
def anonymize_openssl(data)
|
||||
digest = encryption_algorithm()
|
||||
# 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
|
||||
|
||||
def anonymize_murmur3(value)
|
||||
case value
|
||||
when Fixnum
|
||||
MurmurHash3::V32.int_hash(value)
|
||||
when String
|
||||
MurmurHash3::V32.str_hash(value)
|
||||
else
|
||||
MurmurHash3::V32.str_hash(value.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -164,4 +164,39 @@ describe LogStash::Filters::Fingerprint do
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue