logstash-core 5.4.1-java → 5.4.2-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
  SHA1:
3
- metadata.gz: 1a5a0bad713dd49bae31f5ce35302a518688e034
4
- data.tar.gz: fce1138b7e1a930dae5e232bff1bbe74afc505e0
3
+ metadata.gz: 25bc0eb9c11736f20bbfcf8ce52d5f36739099a3
4
+ data.tar.gz: 746a309a74e29b9038fa6dbf16b020411a84406e
5
5
  SHA512:
6
- metadata.gz: 27455700bac45bcf838b065c0fa716299f6167d1f70b658f31e2a5cedf6c678e4be7dcacdb7aba04a2cfc78c2c92850c46a93f14ac120d48a369940f054c3e18
7
- data.tar.gz: 30278142ebf380fc9e1254652e028ed31d24902a65ab2b363614978a7b6193104b4f40467f964af189cc5396779bd7da30de11c13cac897081b012cc6ba0f3d1
6
+ metadata.gz: a7fc76c80fe33ef6667f304e5d48b7a3cd0d52913a8444971e1e842fff51a75bea27f7b57f8720e25be083fbb4f34a45c204ef9051a7b1808fd551d96c80cc71
7
+ data.tar.gz: cf4a89721f3609926d553c3dfc393775e869316bf8a1233e33459501349d9f8666773a0ab693554e90fb5e5d722bdeb93127b1151f6b134e6a2239af04a8b5b3
@@ -5,4 +5,4 @@
5
5
  # Note to authors: this should not include dashes because 'gem' barfs if
6
6
  # you include a dash in the version string.
7
7
 
8
- LOGSTASH_CORE_VERSION = "5.4.1"
8
+ LOGSTASH_CORE_VERSION = "5.4.2"
@@ -6,6 +6,7 @@ require "logstash/util/password"
6
6
  require "logstash/util/safe_uri"
7
7
  require "logstash/version"
8
8
  require "logstash/environment"
9
+ require "logstash/util/environment_variables"
9
10
  require "logstash/util/plugin_version"
10
11
  require "filesize"
11
12
 
@@ -180,6 +181,9 @@ module LogStash::Config::Mixin
180
181
  end # def replace_env_placeholders
181
182
 
182
183
  module DSL
184
+
185
+ include LogStash::Util::EnvironmentVariables
186
+
183
187
  attr_accessor :flags
184
188
 
185
189
  # If name is given, set the name and return it.
@@ -425,6 +429,8 @@ module LogStash::Config::Mixin
425
429
  # (see LogStash::Inputs::File for example)
426
430
  result = nil
427
431
 
432
+ value = deep_replace(value)
433
+
428
434
  if validator.nil?
429
435
  return true, value
430
436
  elsif validator.is_a?(Array)
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ module ::LogStash::Util::EnvironmentVariables
3
+
4
+ ENV_PLACEHOLDER_REGEX = /\${(?<name>[a-zA-Z_.][a-zA-Z0-9_.]*)(:(?<default>[^}]*))?}/
5
+
6
+ # Recursive method to replace environment variable references in parameters
7
+ def deep_replace(value)
8
+ if value.is_a?(Hash)
9
+ value.each do |valueHashKey, valueHashValue|
10
+ value[valueHashKey.to_s] = deep_replace(valueHashValue)
11
+ end
12
+ else
13
+ if value.is_a?(Array)
14
+ value.each_index do | valueArrayIndex|
15
+ value[valueArrayIndex] = deep_replace(value[valueArrayIndex])
16
+ end
17
+ else
18
+ return replace_env_placeholders(value)
19
+ end
20
+ end
21
+ end
22
+
23
+ # Replace all environment variable references in 'value' param by environment variable value and return updated value
24
+ # Process following patterns : $VAR, ${VAR}, ${VAR:defaultValue}
25
+ def replace_env_placeholders(value)
26
+ return value unless value.is_a?(String)
27
+
28
+ value.gsub(ENV_PLACEHOLDER_REGEX) do |placeholder|
29
+ # Note: Ruby docs claim[1] Regexp.last_match is thread-local and scoped to
30
+ # the call, so this should be thread-safe.
31
+ #
32
+ # [1] http://ruby-doc.org/core-2.1.1/Regexp.html#method-c-last_match
33
+ name = Regexp.last_match(:name)
34
+ default = Regexp.last_match(:default)
35
+
36
+ replacement = ENV.fetch(name, default)
37
+ if replacement.nil?
38
+ raise LogStash::ConfigurationError, "Cannot evaluate `#{placeholder}`. Environment variable `#{name}` is not set and there is no default value given."
39
+ end
40
+ replacement
41
+ end
42
+ end # def replace_env_placeholders
43
+ end
@@ -11,4 +11,4 @@
11
11
  # eventually this file should be in the root logstash lib fir and dependencies in logstash-core should be
12
12
  # fixed.
13
13
 
14
- LOGSTASH_VERSION = "5.4.1"
14
+ LOGSTASH_VERSION = "5.4.2"
@@ -24,7 +24,7 @@ Gem::Specification.new do |gem|
24
24
  gem.add_runtime_dependency "clamp", "~> 0.6.5" #(MIT license) for command line args/flags
25
25
  gem.add_runtime_dependency "filesize", "0.0.4" #(MIT license) for :bytes config validator
26
26
  gem.add_runtime_dependency "gems", "~> 0.8.3" #(MIT license)
27
- gem.add_runtime_dependency "concurrent-ruby", "1.0.0"
27
+ gem.add_runtime_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.5"
28
28
  gem.add_runtime_dependency "sinatra", '~> 1.4', '>= 1.4.6'
29
29
  gem.add_runtime_dependency 'puma', '~> 2.16'
30
30
  gem.add_runtime_dependency "jruby-openssl", "0.9.16" # >= 0.9.13 Required to support TLSv1.2
@@ -369,11 +369,13 @@ describe LogStash::Config::Mixin do
369
369
  before do
370
370
  ENV["FunString"] = "fancy"
371
371
  ENV["FunBool"] = "true"
372
+ ENV["SERVER_LS_TEST_ADDRESS"] = "some.host.address.tld"
372
373
  end
373
374
 
374
375
  after do
375
376
  ENV.delete("FunString")
376
377
  ENV.delete("FunBool")
378
+ ENV.delete("SERVER_LS_TEST_ADDRESS")
377
379
  end
378
380
 
379
381
  subject do
@@ -397,6 +399,16 @@ describe LogStash::Config::Mixin do
397
399
  expect(subject.nestedArray).to(be == { "level1" => [{ "key1" => "http://fancy:8080/blah.txt" }, { "key2" => "http://fancy:8080/foo.txt" }] })
398
400
  expect(subject.deepHash).to(be == { "level1" => { "level2" => { "level3" => { "key1" => "http://fancy:8080/blah.txt" } } } })
399
401
  end
402
+
403
+ it "should validate settings after interpolating ENV variables" do
404
+ expect {
405
+ Class.new(LogStash::Filters::Base) do
406
+ include LogStash::Config::Mixin
407
+ config_name "test"
408
+ config :server_address, :validate => :uri
409
+ end.new({"server_address" => "${SERVER_LS_TEST_ADDRESS}"})
410
+ }.not_to raise_error
411
+ end
400
412
  end
401
413
 
402
414
  context "should support $ in values" do
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: 5.4.1
4
+ version: 5.4.2
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-29 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -83,17 +83,23 @@ dependencies:
83
83
  - !ruby/object:Gem::Dependency
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '='
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.0'
89
+ - - ">="
87
90
  - !ruby/object:Gem::Version
88
- version: 1.0.0
91
+ version: 1.0.5
89
92
  name: concurrent-ruby
90
93
  prerelease: false
91
94
  type: :runtime
92
95
  version_requirements: !ruby/object:Gem::Requirement
93
96
  requirements:
94
- - - '='
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.0'
100
+ - - ">="
95
101
  - !ruby/object:Gem::Version
96
- version: 1.0.0
102
+ version: 1.0.5
97
103
  - !ruby/object:Gem::Dependency
98
104
  requirement: !ruby/object:Gem::Requirement
99
105
  requirements:
@@ -393,6 +399,7 @@ files:
393
399
  - lib/logstash/util/charset.rb
394
400
  - lib/logstash/util/decorators.rb
395
401
  - lib/logstash/util/duration_formatter.rb
402
+ - lib/logstash/util/environment_variables.rb
396
403
  - lib/logstash/util/filetools.rb
397
404
  - lib/logstash/util/java_version.rb
398
405
  - lib/logstash/util/loggable.rb