logstash-core 6.8.8-java → 6.8.13-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: d42894860b18c174aa9664bffd1518c001452109a00476094a8423104d91cbe5
4
- data.tar.gz: 906608418ab20053c9f6caa88d4c6028ed0ff476d4a8bf327e271c003f11b155
3
+ metadata.gz: 7839ba73e0e08d435d3647cd0decaa15fdc47cf6a63ae3450b03b21042443577
4
+ data.tar.gz: 021d594b0f89188e6085d9ac411fb7352bb484db99bcdf1375cfefb817d325ab
5
5
  SHA512:
6
- metadata.gz: bba9aafe9ce3d120534a84e58313a645326f2812284b39247a0f18ee34761f091c6fde2ea6864214ce349709aaa1e02526db61d7a9e8f9fa098aa63022a47ef9
7
- data.tar.gz: b7bc09ccf8eec2692e1d494a3d35e427a4ee83b2be52cdabb205566c4930b516c4a87273c4feee9b4d1dd37ac1874194648fc5c2f6dbcd899f3b2bc3ea07c359
6
+ metadata.gz: 53398d391f58ce879e174a9745f447f08921b69e03ad152179e0177b0c14b28ceb7b7fa37e68f507e5deba72a3dccddfe9fb66d89d3d134b474e3cfa236763b7
7
+ data.tar.gz: 70d7d02c3c921daced3d65757bb7c9cf3198f21dfe48d11a907b40d44350b15d6d493afa24bb528fb5df23520740647037454e6737d2f2aca22834d65617be8a
@@ -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.8
3
- logstash-core: 6.8.8
2
+ logstash: 6.8.13
3
+ logstash-core: 6.8.13
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.8
4
+ version: 6.8.13
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-19 00:00:00.000000000 Z
11
+ date: 2020-10-16 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