mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -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)
|
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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue