logstash-filter-fingerprint 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25ac9ded3114af17962469d77481c6992d65778a9dcf67012aaa3c7fb63c6ff7
4
- data.tar.gz: d42a1fc7ff16d940f5634cb5f14ee2b4f2216176bdf7b90a8e7e6ed23cc95909
3
+ metadata.gz: 314340e6e62bfa1dc34740e1f44af4313668c797dc99cb15b8fc37519f601c75
4
+ data.tar.gz: bba012a2b02065879152ac51fe926e8ba8beef8ed96d577b3aecb4555a255dce
5
5
  SHA512:
6
- metadata.gz: dc8e8df09287df6f5f0649397f0b6b326396508afb101b73b7b51ca95802c314719a74440657059114ddab7b5d47cd65b7a48babea76e2b341cbdf46753f4da6
7
- data.tar.gz: 605eec24d6a4587e565acfe35c405beb6ff782410ed23c955e3d7e938e9a8fb3f633f40bc282f7ccaec77be07dfe233843ce2564dceb6cbe87dbe7fec0759668
6
+ metadata.gz: bb420df3e75d292c83cf6e7f6488ff6bad9b194d45787ee43c1e2b2fadb9fc038b42b6ebb8d2403b852d111799ebc139819109a559abd59692693ca8d7fed42b
7
+ data.tar.gz: 451164868428c63860da386b856c4ea0adff10ce290ae24dc4a5d45a7b8ab12a6c90c74bf352bcab0af702cec820d9cba1fcf04889ed02bac63a45b93037d03a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.4.1
2
+ - Added backward compatibility of timestamp format to provide consistent fingerprint [#67](https://github.com/logstash-plugins/logstash-filter-fingerprint/pull/67)
3
+
1
4
  ## 3.4.0
2
5
  - Added support for 128bit murmur variant [#66](https://github.com/logstash-plugins/logstash-filter-fingerprint/pull/66).
3
6
 
@@ -24,6 +24,25 @@ require "logstash/plugin_mixins/ecs_compatibility_support"
24
24
  # To generate UUIDs, prefer the <<plugins-filters-uuid,uuid filter>>.
25
25
  class LogStash::Filters::Fingerprint < LogStash::Filters::Base
26
26
 
27
+ ##
28
+ # Logstash 8+ has variable-length serialization of timestamps
29
+ # that do not include subsecond info for whole-second timestamps.
30
+ # For backward-compatibility we refine the implementation to use
31
+ # our own three-decimal-place formatter for whole-second
32
+ # timestamps.
33
+ if LOGSTASH_VERSION.split('.').first.to_i >= 8
34
+ module MinimumSerializationLengthTimestamp
35
+ THREE_DECIMAL_INSTANT_FORMATTER = java.time.format.DateTimeFormatterBuilder.new.appendInstant(3).toFormatter
36
+ refine LogStash::Timestamp do
37
+ def to_s
38
+ return super unless nsec == 0
39
+ THREE_DECIMAL_INSTANT_FORMATTER.format(to_java.toInstant)
40
+ end
41
+ end
42
+ end
43
+ using MinimumSerializationLengthTimestamp
44
+ end
45
+
27
46
  INTEGER_MAX_32BIT = (1 << 31) - 1
28
47
  INTEGER_MIN_32BIT = -(1 << 31)
29
48
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-fingerprint'
4
- s.version = '3.4.0'
4
+ s.version = '3.4.1'
5
5
  s.licenses = ['Apache-2.0']
6
6
  s.summary = "Fingerprints fields by replacing values with a consistent hash"
7
7
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -19,6 +19,10 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
19
19
  plugin.filter(event)
20
20
  end
21
21
 
22
+ def ge_version_8
23
+ LOGSTASH_VERSION.split('.').first.to_i >= 8
24
+ end
25
+
22
26
  context "with a string field" do
23
27
  let(:data) { {"clientip" => "123.123.123.123" } }
24
28
  let(:config) { super().merge("source" => ["clientip" ]) }
@@ -273,7 +277,7 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
273
277
  end
274
278
 
275
279
  context 'Timestamps' do
276
- epoch_time = Time.at(0).gmtime
280
+ let(:epoch_time) { Time.at(0).gmtime }
277
281
  let(:config) { super().merge("source" => ['@timestamp']) }
278
282
 
279
283
  describe 'OpenSSL Fingerprinting' do
@@ -297,9 +301,35 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
297
301
  let(:fingerprint_method) { "MURMUR3_128" }
298
302
  let(:data) { { "@timestamp" => epoch_time } }
299
303
  it "fingerprints the timestamp correctly" do
300
- expect(fingerprint).to eq("37785b62a8cae473acc315d39b66d86e")
304
+ expect(fingerprint).to eq('37785b62a8cae473acc315d39b66d86e')
301
305
  end
302
306
  end
307
+
308
+ describe "fractional seconds" do
309
+ let(:fingerprint_method) { "MURMUR3" }
310
+ let(:data) { { "@timestamp" => epoch_time } }
311
+
312
+ describe "millisecond" do
313
+ let(:epoch_time) { LogStash::Timestamp.new('2000-01-01T05:00:00.12Z') }
314
+ it "fingerprints the timestamp correctly" do
315
+ expect(fingerprint).to eq(4263087275)
316
+ end
317
+ end
318
+
319
+ describe "microsecond" do
320
+ let(:epoch_time) { LogStash::Timestamp.new('2000-01-01T05:00:00.123456Z') }
321
+ it "fingerprints the timestamp correctly" do
322
+ expect(fingerprint).to eq(4188855160)
323
+ end
324
+ end if ge_version_8
325
+
326
+ describe "nanosecond" do
327
+ let(:epoch_time) { LogStash::Timestamp.new('2000-01-01T05:00:00.123456789Z') }
328
+ it "fingerprints the timestamp correctly" do
329
+ expect(fingerprint).to eq(3520111535)
330
+ end
331
+ end if ge_version_8
332
+ end
303
333
  end
304
334
 
305
335
  describe "post fingerprint execution triggers" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-fingerprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-03 00:00:00.000000000 Z
11
+ date: 2022-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement