Skip to content

Commit 69c6aac

Browse files
committed
Mark deprecated SSL settings as obsolete
This commit updates SSL settings to be marked as obsolete: - Replace `ssl` with `ssl_enabled` - Replace `ca_file` with `ssl_certificate_authorities` - Replace `ssl_certificate_verification` with `ssl_verification_mode` `setup_ssl_params!` has been updated to only handle SSL inference when not explicitly configured. All changes have been updated in tests and in docs. The preparation for releasing a new major version is also included.
1 parent f49b710 commit 69c6aac

File tree

5 files changed

+48
-53
lines changed

5 files changed

+48
-53
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 5.0.0
2+
- SSL settings that were marked deprecated in version `4.17.0` are now marked obsolete, and will prevent the plugin from starting.
3+
- These settings are:
4+
- `ssl`, which should bre replaced by `ssl_enabled`
5+
- `ca_file`, which should bre replaced by `ssl_certificate_authorities`
6+
- `ssl_certificate_verification`, which should bre replaced by `ssl_verification_mode`
7+
- [#213](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/213)
8+
19
## 4.20.5
210
- Add `x-elastic-product-origin` header to Elasticsearch requests [#211](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/211)
311

docs/index.asciidoc

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ Enable SSL/TLS secured communication to Elasticsearch cluster.
478478
Leaving this unspecified will use whatever scheme is specified in the URLs listed in <<plugins-{type}s-{plugin}-hosts>> or extracted from the <<plugins-{type}s-{plugin}-cloud_id>>.
479479
If no explicit protocol is specified plain HTTP will be used.
480480

481+
When not explicitly set, SSL will be automatically enabled if any of the specified hosts use HTTPS.
482+
481483
[id="plugins-{type}s-{plugin}-ssl_key"]
482484
===== `ssl_key`
483485
* Value type is <<path,path>>
@@ -608,12 +610,12 @@ option when authenticating to the Elasticsearch server. If set to an
608610
empty string authentication will be disabled.
609611

610612

611-
[id="plugins-{type}s-{plugin}-deprecated-options"]
612-
==== Elasticsearch Input deprecated configuration options
613+
[id="plugins-{type}s-{plugin}-removed-options"]
614+
==== Elasticsearch Input Removed configuration options
613615

614-
This plugin supports the following deprecated configurations.
616+
The following configurations will be removed in version 5.0.0.
615617

616-
WARNING: Deprecated options are subject to removal in future releases.
618+
WARNING: These options have been deprecated and will be removed in version 5.0.0. Please use their replacements instead.
617619

618620
[cols="<,<,<",options="header",]
619621
|=======================================================================
@@ -625,7 +627,9 @@ WARNING: Deprecated options are subject to removal in future releases.
625627

626628
[id="plugins-{type}s-{plugin}-ca_file"]
627629
===== `ca_file`
628-
deprecated[4.17.0, Replaced by <<plugins-{type}s-{plugin}-ssl_certificate_authorities>>]
630+
deprecated[4.17.0, Will be removed in 5.0.0, replaced by <<plugins-{type}s-{plugin}-ssl_certificate_authorities>>]
631+
632+
This setting will be removed in 5.0.0. Please use <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> instead.
629633

630634
* Value type is <<path,path>>
631635
* There is no default value for this setting.
@@ -634,7 +638,9 @@ SSL Certificate Authority file in PEM encoded format, must also include any chai
634638

635639
[id="plugins-{type}s-{plugin}-ssl"]
636640
===== `ssl`
637-
deprecated[4.17.0, Replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
641+
deprecated[4.17.0, Will be removed in 5.0.0, replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
642+
643+
This setting will be removed in 5.0.0. Please use <<plugins-{type}s-{plugin}-ssl_enabled>> instead.
638644

639645
* Value type is <<boolean,boolean>>
640646
* Default value is `false`
@@ -645,7 +651,10 @@ server (i.e. HTTPS will be used instead of plain HTTP).
645651

646652
[id="plugins-{type}s-{plugin}-ssl_certificate_verification"]
647653
===== `ssl_certificate_verification`
648-
deprecated[4.17.0, Replaced by <<plugins-{type}s-{plugin}-ssl_verification_mode>>]
654+
deprecated[4.17.0, Will be removed in 5.0.0, replaced by <<plugins-{type}s-{plugin}-ssl_verification_mode>>]
655+
656+
This setting will be removed in 5.0.0. Please use <<plugins-{type}s-{plugin}-ssl_verification_mode>> instead.
657+
649658

650659
* Value type is <<boolean,boolean>>
651660
* Default value is `true`

lib/logstash/inputs/elasticsearch.rb

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,12 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
198198
# Set the address of a forward HTTP proxy.
199199
config :proxy, :validate => :uri_or_empty
200200

201-
# SSL
202-
config :ssl, :validate => :boolean, :default => false, :deprecated => "Set 'ssl_enabled' instead."
203-
204-
# SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary
205-
config :ca_file, :validate => :path, :deprecated => "Set 'ssl_certificate_authorities' instead."
206-
207201
# OpenSSL-style X.509 certificate certificate to authenticate the client
208202
config :ssl_certificate, :validate => :path
209203

210204
# SSL Certificate Authority files in PEM encoded format, must also include any chain certificates as necessary
211205
config :ssl_certificate_authorities, :validate => :path, :list => true
212206

213-
# Option to validate the server's certificate. Disabling this severely compromises security.
214-
# For more information on the importance of certificate verification please read
215-
# https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
216-
config :ssl_certificate_verification, :validate => :boolean, :default => true, :deprecated => "Set 'ssl_verification_mode' instead."
217-
218207
# The list of cipher suites to use, listed by priorities.
219208
# Supported cipher suites vary depending on which version of Java is used.
220209
config :ssl_cipher_suites, :validate => :string, :list => true
@@ -242,7 +231,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
242231
config :ssl_truststore_password, :validate => :password
243232

244233
# The JKS truststore to validate the server's certificate.
245-
# Use either `:ssl_truststore_path` or `:ssl_certificate_authorities`
234+
# Use either `:ssl_truststore_path`
246235
config :ssl_truststore_path, :validate => :path
247236

248237
# The format of the truststore file. It must be either jks or pkcs12
@@ -264,6 +253,11 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
264253
# If set, the _source of each hit will be added nested under the target instead of at the top-level
265254
config :target, :validate => :field_reference
266255

256+
# Obsolete Settings
257+
config :ssl, :obsolete => "Set 'ssl_enabled' instead."
258+
config :ca_file, :obsolete => "Set 'ssl_certificate_authorities' instead."
259+
config :ssl_certificate_verification, :obsolete => "Set 'ssl_verification_mode' instead."
260+
267261
# config :ca_trusted_fingerprint, :validate => :sha_256_hex
268262
include LogStash::PluginMixins::CATrustedFingerprintSupport
269263

@@ -408,8 +402,6 @@ def setup_client_ssl
408402
ssl_options[:ssl] = true if @ssl_enabled
409403

410404
unless @ssl_enabled
411-
# Keep it backward compatible with the deprecated `ssl` option
412-
ssl_options[:trust_strategy] = trust_strategy_for_ca_trusted_fingerprint if original_params.include?('ssl')
413405
return ssl_options
414406
end
415407

@@ -473,38 +465,11 @@ def setup_client_ssl
473465
end
474466

475467
def setup_ssl_params!
476-
@ssl_enabled = normalize_config(:ssl_enabled) do |normalize|
477-
normalize.with_deprecated_alias(:ssl)
478-
end
479-
480-
# Infer the value if neither the deprecate `ssl` and `ssl_enabled` were set
481-
infer_ssl_enabled_from_hosts
482-
483-
@ssl_certificate_authorities = normalize_config(:ssl_certificate_authorities) do |normalize|
484-
normalize.with_deprecated_mapping(:ca_file) do |ca_file|
485-
[ca_file]
486-
end
468+
# Only infer ssl_enabled if it wasn't explicitly set
469+
unless original_params.include?('ssl_enabled')
470+
@ssl_enabled = effectively_ssl?
471+
params['ssl_enabled'] = @ssl_enabled
487472
end
488-
489-
@ssl_verification_mode = normalize_config(:ssl_verification_mode) do |normalize|
490-
normalize.with_deprecated_mapping(:ssl_certificate_verification) do |ssl_certificate_verification|
491-
if ssl_certificate_verification == true
492-
"full"
493-
else
494-
"none"
495-
end
496-
end
497-
end
498-
499-
params['ssl_enabled'] = @ssl_enabled
500-
params['ssl_certificate_authorities'] = @ssl_certificate_authorities unless @ssl_certificate_authorities.nil?
501-
params['ssl_verification_mode'] = @ssl_verification_mode unless @ssl_verification_mode.nil?
502-
end
503-
504-
def infer_ssl_enabled_from_hosts
505-
return if original_params.include?('ssl') || original_params.include?('ssl_enabled')
506-
507-
@ssl_enabled = params['ssl_enabled'] = effectively_ssl?
508473
end
509474

510475
def setup_hosts

logstash-input-elasticsearch.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-input-elasticsearch'
4-
s.version = '4.20.5'
4+
s.version = '5.0.0'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Reads query results from an Elasticsearch cluster"
77
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

spec/inputs/elasticsearch_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@
5858
end
5959
end
6060

61+
describe 'handling obsolete settings' do
62+
[{:name => 'ssl', :replacement => 'ssl_enabled', :sample_value => true},
63+
{:name => 'ca_file', :replacement => 'ssl_certificate_authorities', :sample_value => 'spec/fixtures/test_certs/ca.crt'},
64+
{:name => 'ssl_certificate_verification', :replacement => 'ssl_verification_mode', :sample_value => false }].each do | obsolete_setting|
65+
context "with obsolete #{obsolete_setting[:name]}" do
66+
let (:config) { {obsolete_setting[:name] => obsolete_setting[:sample_value]} }
67+
it "should raise a config error with the appropriate message" do
68+
expect { plugin.register }.to raise_error LogStash::ConfigurationError, /The setting `#{obsolete_setting[:name]}` in plugin `elasticsearch` is obsolete and is no longer available. Set '#{obsolete_setting[:replacement]}' instead/i
69+
end
70+
end
71+
end
72+
end
73+
6174
context "against not authentic Elasticsearch" do
6275
before(:each) do
6376
Elasticsearch::Client.send(:define_method, :ping) { raise Elasticsearch::UnsupportedProductError.new("Fake error") } # define error ping method

0 commit comments

Comments
 (0)