Skip to content

Commit 5977fcc

Browse files
robbaveydonoghuckarenzone
authored
Mark deprecated SSL settings as obsolete (#228)
* Mark deprecated SSL settings as obsolete This commit marks the following SSL settings as obsolete: `ssl_cert`, which should be replaced by `ssl_certificate` `ssl_enable`, which should be replaced by `ssl_enabled` `ssl_verify`, which should be replaced by `ssl_client_authentication` when `mode` is `server` or `ssl_verification_mode`when mode is `client` --------- Co-authored-by: Cas Donoghue <[email protected]> Co-authored-by: Karen Metts <[email protected]>
1 parent 3c0c18a commit 5977fcc

File tree

6 files changed

+55
-149
lines changed

6 files changed

+55
-149
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 7.0.0
2+
- SSL settings that were marked deprecated in version `6.4.0` are now marked obsolete, and will prevent the plugin from starting.
3+
- These settings are:
4+
- `ssl_cert`, which should be replaced by `ssl_certificate`
5+
- `ssl_enable`, which should be replaced by `ssl_enabled`
6+
- `ssl_verify`, which should be replaced by `ssl_client_authentication` when `mode` is `server` or `ssl_verification_mode`when mode is `client`
7+
- [228](https://github.com/logstash-plugins/logstash-input-tcp/pull/228)
8+
19
## 6.4.4
210
- update netty to 4.1.115 [#227](https://github.com/logstash-plugins/logstash-input-tcp/pull/227)
311

docs/index.asciidoc

+19-31
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ filter {
121121

122122
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
123123

124+
NOTE: As of version `7.0.0` of this plugin, a number of previously deprecated settings related to SSL have been removed. Please see the
125+
<<plugins-{type}s-{plugin}-obsolete-options>> for more details.
126+
127+
124128
[cols="<,<,<",options="header",]
125129
|=======================================================================
126130
|Setting |Input type|Required
@@ -130,19 +134,16 @@ This plugin supports the following configuration options plus the <<plugins-{typ
130134
| <<plugins-{type}s-{plugin}-mode>> |<<string,string>>, one of `["server", "client"]`|No
131135
| <<plugins-{type}s-{plugin}-port>> |<<number,number>>|Yes
132136
| <<plugins-{type}s-{plugin}-proxy_protocol>> |<<boolean,boolean>>|No
133-
| <<plugins-{type}s-{plugin}-ssl_cert>> |a valid filesystem path|__Deprecated__
134137
| <<plugins-{type}s-{plugin}-ssl_certificate>> |a valid filesystem path|No
135138
| <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> |<<array,array>>|No
136139
| <<plugins-{type}s-{plugin}-ssl_cipher_suites>> |<<string,string>>|No
137140
| <<plugins-{type}s-{plugin}-ssl_client_authentication>> |<<string,string>>, one of `["none", "optional", "required"]`|No
138-
| <<plugins-{type}s-{plugin}-ssl_enable>> |<<boolean,boolean>>|__Deprecated__
139141
| <<plugins-{type}s-{plugin}-ssl_enabled>> |<<boolean,boolean>>|No
140142
| <<plugins-{type}s-{plugin}-ssl_extra_chain_certs>> |<<array,array>>|No
141143
| <<plugins-{type}s-{plugin}-ssl_key>> |a valid filesystem path|No
142144
| <<plugins-{type}s-{plugin}-ssl_key_passphrase>> |<<password,password>>|No
143145
| <<plugins-{type}s-{plugin}-ssl_supported_protocols>> |<<string,string>>|No
144146
| <<plugins-{type}s-{plugin}-ssl_verification_mode>> |<<string,string>>, one of `["full", "none"]`|No
145-
| <<plugins-{type}s-{plugin}-ssl_verify>> |<<boolean,boolean>>|__Deprecated__
146147
| <<plugins-{type}s-{plugin}-tcp_keep_alive>> |<<boolean,boolean>>|No
147148
|=======================================================================
148149

@@ -212,16 +213,6 @@ When mode is `client`, the port to connect to.
212213
Proxy protocol support, only v1 is supported at this time
213214
http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt
214215

215-
[id="plugins-{type}s-{plugin}-ssl_cert"]
216-
===== `ssl_cert`
217-
deprecated[6.4.0, Replaced by <<plugins-{type}s-{plugin}-ssl_certificate>>]
218-
219-
* Value type is <<path,path>>
220-
* There is no default value for this setting.
221-
222-
Path to certificate in PEM format. This certificate will be presented
223-
to the connecting clients.
224-
225216
[id="plugins-{type}s-{plugin}-ssl_certificate"]
226217
===== `ssl_certificate`
227218

@@ -268,14 +259,6 @@ Please note that the server does not validate the client certificate CN (Common
268259

269260
NOTE: This setting can be used only if <<plugins-{type}s-{plugin}-mode>> is `server` and <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> is set.
270261

271-
[id="plugins-{type}s-{plugin}-ssl_enable"]
272-
===== `ssl_enable`
273-
deprecated[6.4.0, Replaced by <<plugins-{type}s-{plugin}-ssl_enabled>>]
274-
275-
* Value type is <<boolean,boolean>>
276-
* Default value is `false`
277-
278-
Enable SSL (must be set for other `ssl_` options to take effect).
279262

280263
[id="plugins-{type}s-{plugin}-ssl_enabled"]
281264
===== `ssl_enabled`
@@ -343,16 +326,6 @@ This setting can be used only if <<plugins-{type}s-{plugin}-mode>> is `client`.
343326

344327
WARNING: Setting certificate verification to `none` disables many security benefits of SSL/TLS, which is very dangerous. For more information on disabling certificate verification please read https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
345328

346-
[id="plugins-{type}s-{plugin}-ssl_verify"]
347-
===== `ssl_verify`
348-
deprecated[6.4.0, Replaced by <<plugins-{type}s-{plugin}-ssl_client_authentication>> and <<plugins-{type}s-{plugin}-ssl_verification_mode>>]
349-
350-
* Value type is <<boolean,boolean>>
351-
* Default value is `true`
352-
353-
Verify the identity of the other end of the SSL connection against the CA.
354-
For input, sets the field `sslsubject` to that of the client certificate.
355-
356329
[id="plugins-{type}s-{plugin}-tcp_keep_alive"]
357330
===== `tcp_keep_alive`
358331

@@ -363,6 +336,21 @@ Instruct the socket to use TCP keep alive. If it's `true` then the underlying so
363336
will use the OS defaults settings for keep alive. If it's `false` it doesn't configure any
364337
keep alive setting for the underlying socket.
365338

339+
[id="plugins-{type}s-{plugin}-obsolete-options"]
340+
==== TCP Input Obsolete Configuration Options
341+
342+
WARNING: As of version `7.0.0` of this plugin, some configuration options have been replaced.
343+
The plugin will fail to start if it contains any of these obsolete options.
344+
345+
346+
[cols="<,<",options="header",]
347+
|=======================================================================
348+
|Setting|Replaced by
349+
| ssl_cert |<<plugins-{type}s-{plugin}-ssl_certificate>>
350+
| ssl_enable |<<plugins-{type}s-{plugin}-ssl_enabled>>
351+
| ssl_verify |<<plugins-{type}s-{plugin}-ssl_client_authentication>> in `server` mode and <<plugins-{type}s-{plugin}-ssl_verification_mode>> in `client` mode
352+
|=======================================================================
353+
366354

367355
[id="plugins-{type}s-{plugin}-common-options"]
368356
include::{include_path}/{type}.asciidoc[]

lib/logstash/inputs/tcp.rb

+7-40
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
require "logstash/util/socket_peer"
77
require "logstash-input-tcp_jars"
88
require 'logstash/plugin_mixins/ecs_compatibility_support'
9-
require "logstash/plugin_mixins/normalize_config_support"
109

1110
require "socket"
1211
require "openssl"
@@ -69,8 +68,6 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
6968
# ecs_compatibility option, provided by Logstash core or the support adapter.
7069
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1, :v8 => :v1)
7170

72-
include LogStash::PluginMixins::NormalizeConfigSupport
73-
7471
config_name "tcp"
7572

7673
default :codec, "line"
@@ -91,8 +88,6 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
9188
# http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt
9289
config :proxy_protocol, :validate => :boolean, :default => false
9390

94-
# Enable SSL (must be set for other `ssl_` options to take effect).
95-
config :ssl_enable, :validate => :boolean, :default => false, :deprecated => "Use 'ssl_enabled' instead."
9691

9792
# Enable SSL (must be set for other `ssl_` options to take effect).
9893
config :ssl_enabled, :validate => :boolean, :default => false
@@ -104,9 +99,6 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
10499
# This option needs to be used with `ssl_certificate_authorities` and a defined list of CAs.
105100
config :ssl_client_authentication, :validate => %w[none optional required], :default => 'required'
106101

107-
# Verify the identity of the other end of the SSL connection against the CA.
108-
# For input, sets the field `sslsubject` to that of the client certificate.
109-
config :ssl_verify, :validate => :boolean, :default => true, :deprecated => "Use 'ssl_client_authentication' when mode is 'server' or 'ssl_verification_mode' when mode is 'client'"
110102

111103
# Options to verify the server's certificate.
112104
# "full": validates that the provided certificate has an issue date that’s within the not_before and not_after dates;
@@ -116,8 +108,6 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
116108
config :ssl_verification_mode, :validate => %w[full none], :default => 'full'
117109

118110
# SSL certificate path
119-
config :ssl_cert, :validate => :path, :deprecated => "Use 'ssl_certificate' instead."
120-
121111
# SSL certificate path
122112
config :ssl_certificate, :validate => :path
123113

@@ -148,6 +138,13 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
148138
# Option to allow users to avoid DNS Reverse Lookup.
149139
config :dns_reverse_lookup_enabled, :validate => :boolean, :default => true
150140

141+
# Obsolete SSL Settings
142+
config :ssl_enable, :obsolete => "Use 'ssl_enabled' instead."
143+
config :ssl_verify, :obsolete => "Use 'ssl_client_authentication' when mode is 'server' or 'ssl_verification_mode' when mode is 'client'"
144+
config :ssl_cert, :obsolete => "Use 'ssl_certificate' instead."
145+
146+
147+
151148
# Monkey patch TCPSocket and SSLSocket to include socket peer
152149
# @private
153150
def self.patch_socket_peer!
@@ -163,7 +160,6 @@ def initialize(*args)
163160
super(*args)
164161

165162
setup_fields!
166-
setup_ssl_params!
167163

168164
self.class.patch_socket_peer!
169165

@@ -368,35 +364,6 @@ def provided_ssl_enabled_config_name
368364
original_params.include?('ssl_enable') ? 'ssl_enable' : 'ssl_enabled'
369365
end
370366

371-
def setup_ssl_params!
372-
@ssl_enabled = normalize_config(:ssl_enabled) do |normalizer|
373-
normalizer.with_deprecated_alias(:ssl_enable)
374-
end
375-
376-
@ssl_certificate = normalize_config(:ssl_certificate) do |normalizer|
377-
normalizer.with_deprecated_alias(:ssl_cert)
378-
end
379-
380-
if server?
381-
@ssl_client_authentication = normalize_config(:ssl_client_authentication) do |normalizer|
382-
normalizer.with_deprecated_mapping(:ssl_verify) do |ssl_verify|
383-
ssl_verify == true ? "required" : "none"
384-
end
385-
end
386-
else
387-
@ssl_verification_mode = normalize_config(:ssl_verification_mode) do |normalize|
388-
normalize.with_deprecated_mapping(:ssl_verify) do |ssl_verify|
389-
ssl_verify == true ? "full" : "none"
390-
end
391-
end
392-
end
393-
394-
params['ssl_enabled'] = @ssl_enabled unless @ssl_enabled.nil?
395-
params['ssl_certificate'] = @ssl_certificate unless @ssl_certificate.nil?
396-
params['ssl_verification_mode'] = @ssl_verification_mode unless @ssl_verification_mode.nil?
397-
params['ssl_client_authentication'] = @ssl_client_authentication unless @ssl_client_authentication.nil?
398-
end
399-
400367
def server?
401368
@mode == "server"
402369
end

logstash-input-tcp.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Gem::Specification.new do |s|
2222
# Gem dependencies
2323
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
2424
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.2'
25-
s.add_runtime_dependency 'logstash-mixin-normalize_config_support', '~>1.0'
2625

2726
s.add_runtime_dependency 'logstash-core', '>= 8.1.0'
2827

spec/inputs/tcp_spec.rb

+20-76
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ def get_port
5454
end
5555
end
5656

57+
['client', 'server'].each do | mode|
58+
describe "handling obsolete settings for #{mode} mode" do
59+
[{:name => 'ssl_cert', :replacement => 'ssl_certificate', :sample_value => "certificate_path"},
60+
{:name => 'ssl_enable', :replacement => 'ssl_enabled', :sample_value => true},
61+
{:name => 'ssl_verify', :replacement => 'ssl_client_authentication', :sample_value => 'peer'}].each do | obsolete_setting |
62+
context "with obsolete #{obsolete_setting[:name]}" do
63+
let(:config) { { "mode" => mode, "port" => port } }
64+
let (:deprecated_config) do
65+
config.merge({obsolete_setting[:name] => obsolete_setting[:sample_value]})
66+
end
67+
68+
it "should raise a config error with the appropriate message" do
69+
expect { LogStash::Inputs::Tcp.new(deprecated_config).register }.to raise_error LogStash::ConfigurationError, /The setting `#{obsolete_setting[:name]}` in plugin `tcp` is obsolete and is no longer available. Use '#{obsolete_setting[:replacement]}'/i
70+
end
71+
end
72+
end
73+
end
74+
end
75+
5776
ecs_compatibility_matrix(:disabled,:v1, :v8 => :v1) do |ecs_select|
5877
before(:each) do
5978
allow_any_instance_of(described_class).to receive(:ecs_compatibility).and_return(ecs_compatibility)
@@ -602,17 +621,6 @@ def get_port
602621
end
603622
end
604623

605-
context "with deprecated ssl_verify = true and no ssl_certificate_authorities" do
606-
let(:config) { super().merge(
607-
'ssl_verify' => true,
608-
'ssl_certificate_authorities' => []
609-
) }
610-
611-
it "should register without errors" do
612-
expect { subject.register }.to_not raise_error
613-
end
614-
end
615-
616624
%w[required optional].each do |ssl_client_authentication|
617625
context "with ssl_client_authentication = `#{ssl_client_authentication}` and no ssl_certificate_authorities" do
618626
let(:config) { super().merge(
@@ -636,70 +644,6 @@ def get_port
636644
end
637645
end
638646
end
639-
640-
context "with deprecated settings" do
641-
let(:ssl_verify) { true }
642-
let(:certificate_path) { File.expand_path('../fixtures/small.crt', File.dirname(__FILE__)) }
643-
let(:config) do
644-
{
645-
"host" => "127.0.0.1",
646-
"port" => port,
647-
"ssl_enable" => true,
648-
"ssl_cert" => certificate_path,
649-
"ssl_key" => File.expand_path('../fixtures/small.key', File.dirname(__FILE__)),
650-
"ssl_verify" => ssl_verify
651-
}
652-
end
653-
654-
context "and mode is server" do
655-
let(:config) { super().merge("mode" => 'server') }
656-
[true, false].each do |verify|
657-
context "and ssl_verify is #{verify}" do
658-
let(:ssl_verify) { verify }
659-
660-
it "should set new configs params" do
661-
subject.register
662-
expect(subject.params).to match hash_including(
663-
"ssl_enabled" => true,
664-
"ssl_certificate" => certificate_path,
665-
"ssl_client_authentication" => verify ? 'required' : 'none')
666-
end
667-
668-
it "should set new configs variables" do
669-
subject.register
670-
expect(subject.instance_variable_get(:@ssl_enabled)).to eql(true)
671-
expect(subject.instance_variable_get(:@ssl_client_authentication)).to eql(verify ? 'required' : 'none')
672-
expect(subject.instance_variable_get(:@ssl_certificate)).to eql(certificate_path)
673-
end
674-
end
675-
end
676-
end
677-
678-
context "and mode is client" do
679-
let(:config) { super().merge("mode" => 'client') }
680-
[true, false].each do |verify|
681-
context "and ssl_verify is #{verify}" do
682-
let(:ssl_verify) { verify }
683-
684-
it "should set new configs params" do
685-
subject.register
686-
expect(subject.params).to match hash_including(
687-
"ssl_enabled" => true,
688-
"ssl_certificate" => certificate_path,
689-
"ssl_verification_mode" => verify ? 'full' : 'none'
690-
)
691-
end
692-
693-
it "should set new configs variables" do
694-
subject.register
695-
expect(subject.instance_variable_get(:@ssl_enabled)).to eql(true)
696-
expect(subject.instance_variable_get(:@ssl_verification_mode)).to eql(verify ? 'full' : 'none')
697-
expect(subject.instance_variable_get(:@ssl_certificate)).to eql(certificate_path)
698-
end
699-
end
700-
end
701-
end
702-
end
703647
end
704648
end
705649

@@ -747,7 +691,7 @@ def get_port
747691

748692
context "with a non encrypted private key" do
749693
let(:config) do
750-
base_config.merge "ssl_verify" => true
694+
base_config.merge "ssl_client_authentication" => "required"
751695
end
752696
it "should be able to connect and write data" do
753697
result = TcpHelpers.pipelineless_input(subject, 1) do

version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.4.4
1+
7.0.0

0 commit comments

Comments
 (0)