logstash-core 6.8.8-java → 6.8.9-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: a483ab8ba590384e4a07e555f0012e9fab46096507f9b117d58a6e5d2233580e
4
+ data.tar.gz: 331a0544551ec432d76cbaead6010aed0fc04f015e38b9be127beae256cf1003
5
5
  SHA512:
6
- metadata.gz: bba9aafe9ce3d120534a84e58313a645326f2812284b39247a0f18ee34761f091c6fde2ea6864214ce349709aaa1e02526db61d7a9e8f9fa098aa63022a47ef9
7
- data.tar.gz: b7bc09ccf8eec2692e1d494a3d35e427a4ee83b2be52cdabb205566c4930b516c4a87273c4feee9b4d1dd37ac1874194648fc5c2f6dbcd899f3b2bc3ea07c359
6
+ metadata.gz: cb55ae7ed4849e11a098ef44374ad7069090383da9dfcd9000c9cf83337c50bab8c88b781332384b0c98934d8bc1940fd575af568df950b029557823c9725ca4
7
+ data.tar.gz: ab8084c066eddf69a27654efe9e024b51d27e5a10bb58662bf42593e7490a62c04956b23d95b3fe36f9e59f79800215992bedc242068af2a6733e23ae2ec5a34
@@ -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.9
3
+ logstash-core: 6.8.9
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.9
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-05-04 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