logstash-codec-collectd 2.0.0 → 2.0.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
  SHA1:
3
- metadata.gz: 4f9e68d07f513e2d05f223797b8c285fa1098bde
4
- data.tar.gz: 77c9f1bbde0a5861240c6526e819655ba60f25f5
3
+ metadata.gz: a7b71a7a15a13360ff43a9f49a21c37d20733f0e
4
+ data.tar.gz: 5006e663de530455333dc945da8a43f5e4139057
5
5
  SHA512:
6
- metadata.gz: a21a0071c0ab97388dcc82d746e0acba4005984fd169e55e934d78e08bc60b73cde4018cc93ac0b74117f0ebd53a6fcade6db58727c0bf4537c723a734c601e2
7
- data.tar.gz: c50af4e4de30003d49f8f2efdd685b599059c1d496f8f4d8055d5afee4bd4cdf089f2d15dfa242568831ea4b350bdf199077876f5b6ee339490512caa433ca6b
6
+ metadata.gz: 94098945b3da4c007e85445d567dbb3d3597e62b0fd834cf5df2a870d022dd46eca09aae1b3e401ac9ab0890377352ab60c484910f5f77b0b2a55a0928a52adb
7
+ data.tar.gz: fc9094b60a7d990b1cc750ac8da9232e98541d24ef5f5f1fbc8fbd0a0d715b5625bf20dd5618254a0d08777cb00e12a6763791d18c5e090344637bd1385a7638
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 2.0.0
2
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
4
+ - Dependency on logstash-core update to 2.0
5
+
6
+ # 2.0.0
7
+ * synchronize access to OpenSSL::Cipher (not thread-safe)
8
+ * use Digest for digests instead of OpenSSL::Digest and OpenSSL::HMAC (not thread-safe)
9
+ * fix collectd packet mangling under high load conditions
1
10
  # 1.0.1
2
11
  * Bug fix release including the necessary vendored files.
3
12
  # 0.1.10
data/CONTRIBUTORS CHANGED
@@ -9,6 +9,7 @@ Contributors:
9
9
  * Richard Pijnenburg (electrical)
10
10
  * Suyog Rao (suyograo)
11
11
  * andis
12
+ * Frank de Jong (frapex)
12
13
 
13
14
  Note: If you've sent us patches, bug reports, or otherwise contributed to
14
15
  Logstash, and you aren't on the list above and want to be, please let us know
@@ -45,10 +45,13 @@ class NaNError < LogStash::Error; end
45
45
  class LogStash::Codecs::Collectd < LogStash::Codecs::Base
46
46
  config_name "collectd"
47
47
 
48
+ @@openssl_mutex = Mutex.new
49
+
48
50
  AUTHFILEREGEX = /([^:]+): (.+)/
49
51
 
50
52
  PLUGIN_TYPE = 2
51
53
  COLLECTD_TYPE = 4
54
+ COLLECTD_VALUES = 6
52
55
  SIGNATURE_TYPE = 512
53
56
  ENCRYPTION_TYPE = 528
54
57
 
@@ -59,7 +62,7 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
59
62
  3 => "plugin_instance",
60
63
  COLLECTD_TYPE => "collectd_type",
61
64
  5 => "type_instance",
62
- 6 => "values",
65
+ COLLECTD_VALUES => "values",
63
66
  7 => "interval",
64
67
  8 => "@timestamp",
65
68
  9 => "interval",
@@ -69,22 +72,6 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
69
72
  ENCRYPTION_TYPE => "encryption"
70
73
  }
71
74
 
72
- PLUGIN_TYPE_FIELDS = {
73
- 'host' => true,
74
- '@timestamp' => true,
75
- 'type_instance' => true,
76
- 'severity' => true,
77
- }
78
-
79
- COLLECTD_TYPE_FIELDS = {
80
- 'host' => true,
81
- '@timestamp' => true,
82
- 'plugin' => true,
83
- 'plugin_instance' => true,
84
- 'type_instance' => true,
85
- 'severity' => true,
86
- }
87
-
88
75
  INTERVAL_VALUES_FIELDS = {
89
76
  "interval" => true,
90
77
  "values" => true,
@@ -93,10 +80,10 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
93
80
 
94
81
  INTERVAL_BASE_FIELDS = {
95
82
  'host' => true,
96
- 'collectd_type' => true,
83
+ '@timestamp' => true,
97
84
  'plugin' => true,
98
85
  'plugin_instance' => true,
99
- '@timestamp' => true,
86
+ 'collectd_type' => true,
100
87
  'type_instance' => true,
101
88
  }
102
89
 
@@ -160,11 +147,15 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
160
147
  if @authfile.nil?
161
148
  raise "Security level is set to #{@security_level}, but no authfile was configured"
162
149
  else
163
- # Load OpenSSL and instantiate Digest and Crypto functions
150
+ # Load Digest and instantiate functions
151
+ require 'digest'
152
+ @sha256 = Digest::SHA256.new
153
+ @sha1 = Digest::SHA1.new
154
+
155
+ # Load OpenSSL and instantiate functions
164
156
  require 'openssl'
165
- @sha256 = OpenSSL::Digest::Digest.new('sha256')
166
- @sha1 = OpenSSL::Digest::Digest.new('sha1')
167
157
  @cipher = OpenSSL::Cipher.new('AES-256-OFB')
158
+
168
159
  @auth = {}
169
160
  parse_authfile
170
161
  end
@@ -207,7 +198,7 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
207
198
  byte1, byte2 = body.pack("C*").unpack("NN")
208
199
  Time.at(( ((byte1 << 32) + byte2) * (2**-30) )).utc
209
200
  end
210
- # Hi resolution intervals
201
+ # Hi-Resolution intervals
211
202
  hiresinterval_decoder = lambda do |body|
212
203
  byte1, byte2 = body.pack("C*").unpack("NN")
213
204
  Time.at(( ((byte1 << 32) + byte2) * (2**-30) )).to_i
@@ -297,7 +288,7 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
297
288
  def get_values(id, body)
298
289
  drop = false
299
290
  add_tag = false
300
- if id == 6
291
+ if id == COLLECTD_VALUES
301
292
  retval, drop, add_nan_tag = @id_decoder[id].call(body)
302
293
  # Use hash + closure/lambda to speed operations
303
294
  else
@@ -349,7 +340,7 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
349
340
  key = get_key(user)
350
341
  return false if key.nil?
351
342
 
352
- return OpenSSL::HMAC.digest(@sha256, key, user+payload) == signature
343
+ return Digest::HMAC.digest(user+payload, key, Digest::SHA256) == signature
353
344
  end # def verify_signature
354
345
 
355
346
  private
@@ -364,16 +355,20 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
364
355
  return []
365
356
  end
366
357
 
367
- # Set the correct state of the cipher instance
368
- @cipher.decrypt
369
- @cipher.padding = 0
370
- @cipher.iv = iv
371
- @cipher.key = @sha256.digest(key);
372
- # Decrypt the content
373
- plaintext = @cipher.update(content) + @cipher.final
374
- # Reset the state, as adding a new key to an already instantiated state
375
- # results in an exception
376
- @cipher.reset
358
+ # Coordinate access to OpenSSL::Cipher as it is not thread safe
359
+ plaintext = nil
360
+ @@openssl_mutex.synchronize do
361
+ # Set the correct state of the cipher instance
362
+ @cipher.decrypt
363
+ @cipher.padding = 0
364
+ @cipher.iv = iv
365
+ @cipher.key = @sha256.digest(key)
366
+ # Decrypt the content
367
+ plaintext = @cipher.update(content) + @cipher.final
368
+ # Reset the state, as adding a new key to an already instantiated state
369
+ # results in an exception
370
+ @cipher.reset
371
+ end
377
372
 
378
373
  # The plaintext contains a SHA1 hash as checksum in the first 160 bits
379
374
  # (20 octets) of the rest of the data
@@ -420,19 +415,6 @@ class LogStash::Codecs::Collectd < LogStash::Codecs::Base
420
415
  raise(EncryptionError) if payload.empty?
421
416
  was_encrypted = true
422
417
  next
423
- when PLUGIN_TYPE
424
- # We've reached a new plugin, delete everything except for the the host
425
- # field, because there's only one per packet and the timestamp field,
426
- # because that one goes in front of the plugin
427
- collectd.each_key do |k|
428
- collectd.delete(k) unless PLUGIN_TYPE_FIELDS.has_key?(k)
429
- end
430
- when COLLECTD_TYPE
431
- # We've reached a new type within the plugin section, delete all fields
432
- # that could have something to do with the previous type (if any)
433
- collectd.each_key do |k|
434
- collectd.delete(k) unless COLLECTD_TYPE_FIELDS.has_key?(k)
435
- end
436
418
  end
437
419
 
438
420
  raise(EncryptionError) if !was_encrypted and @security_level == SECURITY_ENCR
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-collectd'
4
- s.version = '2.0.0'
4
+ s.version = '2.0.1'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Read events from the collectd binary protocol"
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/plugin install gemname. This gem is not a stand-alone program"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", "~> 2.0.0.snapshot"
23
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0.snapshot", "< 3.0.0"
24
24
 
25
25
  s.add_development_dependency 'logstash-devutils'
26
26
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-collectd
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - ~>
16
+ - - '>='
17
17
  - !ruby/object:Gem::Version
18
18
  version: 2.0.0.snapshot
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
19
22
  name: logstash-core
20
23
  prerelease: false
21
24
  type: :runtime
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 2.0.0.snapshot
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements: