logstash-core 6.8.7-java → 6.8.12-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a803c9221ba6ccaaf0c69c85a773b8cc3b6ccb662a18771210e699dd4b8550f1
4
- data.tar.gz: 1d8b20d909b9fb0d6af5bf1d47720e35c2e066fe889ae2423b4f60c95d8cccb3
3
+ metadata.gz: 3e478e4beabbbd0c5b7e191f18e9b3609fb4c331f27685bdacb1d12a97e3e7c1
4
+ data.tar.gz: 23bab0fa74a87fa73ff4e6abe8a9e74586b0b2e6d529ea1f4116ccd881e707db
5
5
  SHA512:
6
- metadata.gz: dba2fcbc5446f9bf3a53f9c1f642a193c89af18511a6905cad0b9201ae1687e70b27191d6a75743f83398de1b160acf4ebfc0fe6ff67291c3b60adc01fdea0ba
7
- data.tar.gz: 6e2982c15f79f4cfdf58ad1e543ea332ee95a0e4122f308e2bab5c8a8c1f7c84f5e009410f6634cba23e80aa95d9fc2d49eb268772e2bcb57dffca0367b8d8e9
6
+ metadata.gz: b26be1c6adcd036103fc6712a961e67615b8bb8d949e4ae33342ef04ca9e7665332b44d15d76deef664932a26390d046fb0095ed2cc423b5858c4bd071acfc73
7
+ data.tar.gz: adca4e67478633905e470c31b221cd26412e3c0ee843c78af77e832c50bf5a9ef663d326474bda7f189f2142b076001aa9432b4515ef5a599c309b6a3a9581ed
@@ -0,0 +1,33 @@
1
+ require 'thread' # Mutex
2
+
3
+ # A [LazySingleton] wraps the result of the provided block,
4
+ # which is guaranteed to be called at-most-once, even if the
5
+ # block's return value is nil.
6
+ class ::LogStash::Util::LazySingleton
7
+
8
+ def initialize(&block)
9
+ @mutex = Mutex.new
10
+ @block = block
11
+ @instantiated = false
12
+ end
13
+
14
+ def instance
15
+ unless @instantiated
16
+ @mutex.synchronize do
17
+ unless @instantiated
18
+ @instance = @block.call
19
+ @instantiated = true
20
+ end
21
+ end
22
+ end
23
+
24
+ return @instance
25
+ end
26
+
27
+ def reset!
28
+ @mutex.synchronize do
29
+ @instantiated = false
30
+ @instance = nil
31
+ end
32
+ end
33
+ end
@@ -2,12 +2,17 @@
2
2
 
3
3
  java_import "org.logstash.secret.store.SecretStoreExt"
4
4
 
5
+ require_relative 'lazy_singleton'
6
+
5
7
  module ::LogStash::Util::SubstitutionVariables
6
8
 
7
9
  include LogStash::Util::Loggable
8
10
 
9
11
  SUBSTITUTION_PLACEHOLDER_REGEX = /\${(?<name>[a-zA-Z_.][a-zA-Z0-9_.]*)(:(?<default>[^}]*))?}/
10
12
 
13
+ SECRET_STORE = ::LogStash::Util::LazySingleton.new { load_secret_store }
14
+ private_constant :SECRET_STORE
15
+
11
16
  # Recursive method to replace substitution variable references in parameters
12
17
  def deep_replace(value)
13
18
  if value.is_a?(Hash)
@@ -42,7 +47,7 @@ module ::LogStash::Util::SubstitutionVariables
42
47
  logger.debug("Replacing `#{placeholder}` with actual value")
43
48
 
44
49
  #check the secret store if it exists
45
- secret_store = SecretStoreExt.getIfExists(LogStash::SETTINGS.get_setting("keystore.file").value, LogStash::SETTINGS.get_setting("keystore.classname").value)
50
+ secret_store = SECRET_STORE.instance
46
51
  replacement = secret_store.nil? ? nil : secret_store.retrieveSecret(SecretStoreExt.getStoreId(name))
47
52
  #check the environment
48
53
  replacement = ENV.fetch(name, default) if replacement.nil?
@@ -54,4 +59,20 @@ module ::LogStash::Util::SubstitutionVariables
54
59
  end
55
60
  end # def replace_placeholders
56
61
 
62
+ class << self
63
+ private
64
+
65
+ # loads a secret_store from disk if available, or returns nil
66
+ #
67
+ # @api private
68
+ # @return [SecretStoreExt,nil]
69
+ def load_secret_store
70
+ SecretStoreExt.getIfExists(LogStash::SETTINGS.get_setting("keystore.file").value, LogStash::SETTINGS.get_setting("keystore.classname").value)
71
+ end
72
+
73
+ # @api test
74
+ def reset_secret_store
75
+ SECRET_STORE.reset!
76
+ end
77
+ end
57
78
  end
@@ -158,6 +158,11 @@ describe LogStash::Settings do
158
158
 
159
159
  before :each do
160
160
  LogStash::SETTINGS.set("keystore.file", File.join(File.dirname(__FILE__), "../../src/test/resources/logstash.keystore.with.default.pass"))
161
+ LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
162
+ end
163
+
164
+ after(:each) do
165
+ LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
161
166
  end
162
167
 
163
168
  context "placeholders in flat logstash.yml" do
@@ -211,6 +216,7 @@ describe LogStash::Settings do
211
216
 
212
217
  before :each do
213
218
  LogStash::SETTINGS.set("keystore.file", File.join(File.dirname(__FILE__), "../../src/test/resources/logstash.keystore.with.default.pass"))
219
+ LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
214
220
  end
215
221
 
216
222
  before do
@@ -225,6 +231,10 @@ describe LogStash::Settings do
225
231
  ENV.delete('a')
226
232
  end
227
233
 
234
+ after(:each) do
235
+ LogStash::Util::SubstitutionVariables.send(:reset_secret_store)
236
+ end
237
+
228
238
  subject do
229
239
  settings = described_class.new
230
240
  settings.register(LogStash::Setting::ArrayCoercible.new("host", String, []))
@@ -1,6 +1,6 @@
1
1
  ---
2
- logstash: 6.8.7
3
- logstash-core: 6.8.7
2
+ logstash: 6.8.12
3
+ logstash-core: 6.8.12
4
4
  logstash-core-plugin-api: 2.1.16
5
5
 
6
6
  # jruby must reference a *released* version of jruby which can be downloaded from the official download url
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.8.7
4
+ version: 6.8.12
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -455,6 +455,7 @@ files:
455
455
  - lib/logstash/util/duration_formatter.rb
456
456
  - lib/logstash/util/filetools.rb
457
457
  - lib/logstash/util/java_version.rb
458
+ - lib/logstash/util/lazy_singleton.rb
458
459
  - lib/logstash/util/loggable.rb
459
460
  - lib/logstash/util/manticore_ssl_config_helper.rb
460
461
  - lib/logstash/util/modules_setting_array.rb