logstash-filter-fingerprint 3.4.0 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/docs/index.asciidoc +2 -2
- data/lib/logstash/filters/fingerprint.rb +23 -4
- data/logstash-filter-fingerprint.gemspec +1 -1
- data/spec/filters/fingerprint_spec.rb +39 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f2a16bce946eb4f6e8397822a4abf882c600dcce7dee9fb10d4a94c186921b7
|
4
|
+
data.tar.gz: 74a90fce053b44de8fcd0991f24f84fe2cfe6eedf7971ef4dd170f467d7b04c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e086c37f7f9a7321741febefb51a3ab35ffdad9ca635da178aec9378131842cce321df124c545b7c10149ec5c588b965ee13b2a2857fe034fd31654e3aebb1b2
|
7
|
+
data.tar.gz: 4fef51f2ecf2a468006d8aca31ea225aac49ceca8826b8f4e4048bb2ad2d6052d22d388fa50b468ed5618c130c5e94d6a6b4f846c5cc86be4a4b45a446e85e13
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 3.4.2
|
2
|
+
- Key config type changed to `Password` type for better protection from leaks. [#71](https://github.com/logstash-plugins/logstash-filter-fingerprint/pull/71)
|
3
|
+
|
4
|
+
## 3.4.1
|
5
|
+
- Added backward compatibility of timestamp format to provide consistent fingerprint [#67](https://github.com/logstash-plugins/logstash-filter-fingerprint/pull/67)
|
6
|
+
|
1
7
|
## 3.4.0
|
2
8
|
- Added support for 128bit murmur variant [#66](https://github.com/logstash-plugins/logstash-filter-fingerprint/pull/66).
|
3
9
|
|
data/docs/index.asciidoc
CHANGED
@@ -59,7 +59,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
59
59
|
| <<plugins-{type}s-{plugin}-concatenate_sources>> |<<boolean,boolean>>|No
|
60
60
|
| <<plugins-{type}s-{plugin}-concatenate_all_fields>> |<<boolean,boolean>>|No
|
61
61
|
| <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
|
62
|
-
| <<plugins-{type}s-{plugin}-key>> |<<
|
62
|
+
| <<plugins-{type}s-{plugin}-key>> |<<password,password>>|No
|
63
63
|
| <<plugins-{type}s-{plugin}-method>> |<<string,string>>, one of `["SHA1", "SHA256", "SHA384", "SHA512", "MD5", "MURMUR3", "MURMUR3_128", IPV4_NETWORK", "UUID", "PUNCTUATION"]`|Yes
|
64
64
|
| <<plugins-{type}s-{plugin}-source>> |<<array,array>>|No
|
65
65
|
| <<plugins-{type}s-{plugin}-target>> |<<string,string>>|No
|
@@ -164,7 +164,7 @@ See <<plugins-{type}s-{plugin}-ecs_metadata>> for detailed information.
|
|
164
164
|
[id="plugins-{type}s-{plugin}-key"]
|
165
165
|
===== `key`
|
166
166
|
|
167
|
-
* Value type is <<
|
167
|
+
* Value type is <<password,password>>
|
168
168
|
* There is no default value for this setting.
|
169
169
|
|
170
170
|
When used with the `IPV4_NETWORK` method fill in the subnet prefix length.
|
@@ -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
|
|
@@ -42,7 +61,7 @@ class LogStash::Filters::Fingerprint < LogStash::Filters::Base
|
|
42
61
|
|
43
62
|
# When used with the `IPV4_NETWORK` method fill in the subnet prefix length.
|
44
63
|
# With other methods, optionally fill in the HMAC key.
|
45
|
-
config :key, :validate => :
|
64
|
+
config :key, :validate => :password
|
46
65
|
|
47
66
|
# When set to `true`, the `SHA1`, `SHA256`, `SHA384`, `SHA512`, `MD5` and `MURMUR3_128` fingerprint
|
48
67
|
# methods will produce base64 encoded rather than hex encoded strings.
|
@@ -180,7 +199,7 @@ class LogStash::Filters::Fingerprint < LogStash::Filters::Base
|
|
180
199
|
|
181
200
|
def fingerprint_ipv4_network(ip_string)
|
182
201
|
# in JRuby 1.7.11 outputs as US-ASCII
|
183
|
-
IPAddr.new(ip_string).mask(@key.to_i).to_s.force_encoding(Encoding::UTF_8)
|
202
|
+
IPAddr.new(ip_string).mask(@key.value.to_i).to_s.force_encoding(Encoding::UTF_8)
|
184
203
|
end
|
185
204
|
|
186
205
|
def fingerprint_openssl(data)
|
@@ -201,10 +220,10 @@ class LogStash::Filters::Fingerprint < LogStash::Filters::Base
|
|
201
220
|
end
|
202
221
|
else
|
203
222
|
if @base64encode
|
204
|
-
hash = OpenSSL::HMAC.digest(digest, @key, data.to_s)
|
223
|
+
hash = OpenSSL::HMAC.digest(digest, @key.value, data.to_s)
|
205
224
|
Base64.strict_encode64(hash).force_encoding(Encoding::UTF_8)
|
206
225
|
else
|
207
|
-
OpenSSL::HMAC.hexdigest(digest, @key, data.to_s).force_encoding(Encoding::UTF_8)
|
226
|
+
OpenSSL::HMAC.hexdigest(digest, @key.value, data.to_s).force_encoding(Encoding::UTF_8)
|
208
227
|
end
|
209
228
|
end
|
210
229
|
end
|
@@ -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.
|
4
|
+
s.version = '3.4.2'
|
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,13 +19,17 @@ 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" ]) }
|
25
29
|
|
26
30
|
describe "the IPV4_NETWORK method" do
|
27
31
|
let(:fingerprint_method) { "IPV4_NETWORK" }
|
28
|
-
let(:config) { super().merge("key" => 24) }
|
32
|
+
let(:config) { super().merge("key" => ::LogStash::Util::Password.new("24")) }
|
29
33
|
|
30
34
|
it "fingerprints the ip as the network" do
|
31
35
|
expect(fingerprint).to eq("123.123.123.0")
|
@@ -111,7 +115,7 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
|
|
111
115
|
end
|
112
116
|
|
113
117
|
context "with HMAC" do
|
114
|
-
let(:config) { super().merge("key" => "longencryptionkey") }
|
118
|
+
let(:config) { super().merge("key" => ::LogStash::Util::Password.new("longencryptionkey")) }
|
115
119
|
|
116
120
|
it "fingerprints the value" do
|
117
121
|
expect(fingerprint).to eq("fdc60acc4773dc5ac569ffb78fcb93c9630797f4")
|
@@ -137,7 +141,7 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
|
|
137
141
|
expect(fingerprint).to eq("4dabcab210766e35f03e77120e6986d6e6d4752b2a9ff22980b9253d026080d8")
|
138
142
|
end
|
139
143
|
context "with HMAC" do
|
140
|
-
let(:config) { super().merge("key" => "longencryptionkey") }
|
144
|
+
let(:config) { super().merge("key" => ::LogStash::Util::Password.new("longencryptionkey")) }
|
141
145
|
it "fingerprints the value" do
|
142
146
|
expect(fingerprint).to eq("345bec3eff242d53b568916c2610b3e393d885d6b96d643f38494fd74bf4a9ca")
|
143
147
|
end
|
@@ -156,7 +160,7 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
|
|
156
160
|
expect(fingerprint).to eq("fd605b0a3af3e04ce0d7a0b0d9c48d67a12dab811f60072e6eae84e35d567793ffb68a1807536f11c90874065c2a4392")
|
157
161
|
end
|
158
162
|
context "with HMAC" do
|
159
|
-
let(:config) { super().merge("key" => "longencryptionkey") }
|
163
|
+
let(:config) { super().merge("key" => ::LogStash::Util::Password.new("longencryptionkey")) }
|
160
164
|
it "fingerprints the value" do
|
161
165
|
expect(fingerprint).to eq("22d4c0e8c4fbcdc4887d2038fca7650f0e2e0e2457ff41c06eb2a980dded6749561c814fe182aff93e2538d18593947a")
|
162
166
|
end
|
@@ -174,7 +178,7 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
|
|
174
178
|
expect(fingerprint).to eq("5468e2dc64ea92b617782aae884b35af60041ac9e168a283615b6a462c54c13d42fa9542cce9b7d76a8124ac6616818905e3e5dd35d6e519f77c3b517558639a")
|
175
179
|
end
|
176
180
|
context "with HMAC" do
|
177
|
-
let(:config) { super().merge("key" => "longencryptionkey") }
|
181
|
+
let(:config) { super().merge("key" => ::LogStash::Util::Password.new("longencryptionkey")) }
|
178
182
|
it "fingerprints the value" do
|
179
183
|
expect(fingerprint).to eq("11c19b326936c08d6c50a3c847d883e5a1362e6a64dd55201a25f2c1ac1b673f7d8bf15b8f112a4978276d573275e3b14166e17246f670c2a539401c5bfdace8")
|
180
184
|
end
|
@@ -192,7 +196,7 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
|
|
192
196
|
expect(fingerprint).to eq("ccdd8d3d940a01b2fb3258c059924c0d")
|
193
197
|
end
|
194
198
|
context "with HMAC" do
|
195
|
-
let(:config) { super().merge("key" => "longencryptionkey") }
|
199
|
+
let(:config) { super().merge("key" => ::LogStash::Util::Password.new("longencryptionkey")) }
|
196
200
|
it "fingerprints the value" do
|
197
201
|
expect(fingerprint).to eq("9336c879e305c9604a3843fc3e75948f")
|
198
202
|
end
|
@@ -273,11 +277,11 @@ describe LogStash::Filters::Fingerprint, :ecs_compatibility_support, :aggregate_
|
|
273
277
|
end
|
274
278
|
|
275
279
|
context 'Timestamps' do
|
276
|
-
epoch_time
|
280
|
+
let(:epoch_time) { Time.at(0).gmtime }
|
277
281
|
let(:config) { super().merge("source" => ['@timestamp']) }
|
278
282
|
|
279
283
|
describe 'OpenSSL Fingerprinting' do
|
280
|
-
let(:config) { super().merge("key" =>
|
284
|
+
let(:config) { super().merge("key" => ::LogStash::Util::Password.new("0123")) }
|
281
285
|
let(:fingerprint_method) { "SHA1" }
|
282
286
|
let(:data) { { "@timestamp" => epoch_time } }
|
283
287
|
it "fingerprints the timestamp correctly" 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(
|
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.
|
4
|
+
version: 3.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|