fluent-plugin-syslog-tls 1.2.1 → 2.1.0.rc1

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
- SHA1:
3
- metadata.gz: 0a516dcc34ed21eeb6b543a98fab7aa0db940557
4
- data.tar.gz: cb40780e2f416387b4a3efa31ff9365342688f01
2
+ SHA256:
3
+ metadata.gz: 645976d5334d9574e292336a7a04fe771f42c2d6a3a4117157ac765002b0cd59
4
+ data.tar.gz: 93e1cd22473b4924810765608d9b6741a30faea7f416169f33f4eec07661a607
5
5
  SHA512:
6
- metadata.gz: 3b6560e0417cd77accc8afdc6dcaf39314c05194cf10e4ac8a677e4a36e335a56e56108ae81e896cf0d76308bfa800b55e5ea20521904e92aed60908d2b8eb32
7
- data.tar.gz: 6e04b86be9b0d5227ed339f91d5bf924f4ab60c289e1d1aab28f3a4c35919c118dae2193f30ffc92d39367393e9a9f31bc56083cd377cc4f715f40bee24d1d03
6
+ metadata.gz: acbe5677f687a549b3133af9a19079ee6ffdba5bc0640b2ddd8b44f0487d6b19c41bd2dd78e4406bf358624600d7509190b29c8048c52a59225998a3a4eae14e
7
+ data.tar.gz: 5e1c5004e04d102c9b143c37d12117032ac2aec885ad7429bdc68c3887cb75224d9ad46e6325bb38c517cfb706bf27bc036f7d622c49e8cde2cca15d88b70347
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ #### 2.1.0
2
+
3
+ * Require Ruby 2.5
4
+ * Allow TLS 1.3 (minimum remains TLS 1.2)
5
+
6
+
7
+ #### 2.0.0
8
+
9
+ * Require Ruby 2.4
10
+ * Support SNI and enable cert name verification by default. **This changes the default behavior** and may cause issues if the remote server's cert does not match the configured hostname.
11
+ * Add `verify_cert_name` to enable (default) or disable cert name verification.
12
+ Note: `ca_cert` verifies the certificate signing chain. `verify_cert_name` verifies the CN/SAN name on the cert.
13
+
14
+
1
15
  #### 1.2.1
2
16
 
3
17
  * Support Fluentd 1.0 (same API as 0.14).
data/Gemfile CHANGED
@@ -15,5 +15,3 @@
15
15
  source 'https://rubygems.org'
16
16
 
17
17
  gemspec
18
-
19
- gem 'coveralls', require: false
data/Gemfile.lock CHANGED
@@ -1,84 +1,74 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-syslog-tls (1.2.1)
4
+ fluent-plugin-syslog-tls (2.1.0.rc1)
5
5
  fluentd (>= 0.14.0, < 2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.5.2)
11
- public_suffix (>= 2.0.2, < 4.0)
12
- cool.io (1.5.3)
13
- coveralls (0.8.21)
14
- json (>= 1.8, < 3)
15
- simplecov (~> 0.14.1)
16
- term-ansicolor (~> 1.3)
17
- thor (~> 0.19.4)
18
- tins (~> 1.6)
19
- crack (0.4.3)
20
- safe_yaml (~> 1.0.0)
21
- dig_rb (1.0.1)
22
- docile (1.1.5)
23
- fluentd (1.1.0)
10
+ addressable (2.8.1)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ concurrent-ruby (1.1.10)
13
+ cool.io (1.7.1)
14
+ crack (0.4.5)
15
+ rexml
16
+ docile (1.4.0)
17
+ fluentd (1.15.3)
18
+ bundler
24
19
  cool.io (>= 1.4.5, < 2.0.0)
25
- dig_rb (~> 1.0.0)
26
- http_parser.rb (>= 0.5.1, < 0.7.0)
27
- msgpack (>= 0.7.0, < 2.0.0)
28
- serverengine (>= 2.0.4, < 3.0.0)
20
+ http_parser.rb (>= 0.5.1, < 0.9.0)
21
+ msgpack (>= 1.3.1, < 2.0.0)
22
+ serverengine (>= 2.3.0, < 3.0.0)
29
23
  sigdump (~> 0.2.2)
30
- strptime (>= 0.2.2, < 1.0.0)
31
- tzinfo (~> 1.0)
24
+ strptime (>= 0.2.4, < 1.0.0)
25
+ tzinfo (>= 1.0, < 3.0)
32
26
  tzinfo-data (~> 1.0)
27
+ webrick (>= 1.4.2, < 1.8.0)
33
28
  yajl-ruby (~> 1.0)
34
- hashdiff (0.3.7)
35
- http_parser.rb (0.6.0)
36
- json (2.1.0)
37
- minitest (5.10.3)
38
- minitest-stub_any_instance (1.0.1)
39
- msgpack (1.2.2)
40
- power_assert (1.1.1)
41
- public_suffix (3.0.1)
42
- rake (12.3.0)
43
- safe_yaml (1.0.4)
44
- serverengine (2.0.6)
29
+ hashdiff (1.0.1)
30
+ http_parser.rb (0.8.0)
31
+ minitest (5.17.0)
32
+ minitest-stub_any_instance (1.0.3)
33
+ msgpack (1.6.0)
34
+ power_assert (2.0.3)
35
+ public_suffix (5.0.1)
36
+ rake (13.0.6)
37
+ rexml (3.2.5)
38
+ serverengine (2.3.1)
45
39
  sigdump (~> 0.2.2)
46
40
  sigdump (0.2.4)
47
- simplecov (0.14.1)
48
- docile (~> 1.1.0)
49
- json (>= 1.8, < 3)
50
- simplecov-html (~> 0.10.0)
51
- simplecov-html (0.10.2)
52
- strptime (0.2.3)
53
- term-ansicolor (1.6.0)
54
- tins (~> 1.0)
55
- test-unit (3.2.6)
41
+ simplecov (0.22.0)
42
+ docile (~> 1.1)
43
+ simplecov-html (~> 0.11)
44
+ simplecov_json_formatter (~> 0.1)
45
+ simplecov-html (0.12.3)
46
+ simplecov_json_formatter (0.1.4)
47
+ strptime (0.2.5)
48
+ test-unit (3.5.7)
56
49
  power_assert
57
- thor (0.19.4)
58
- thread_safe (0.3.6)
59
- tins (1.16.0)
60
- tzinfo (1.2.4)
61
- thread_safe (~> 0.1)
62
- tzinfo-data (1.2017.3)
50
+ tzinfo (2.0.5)
51
+ concurrent-ruby (~> 1.0)
52
+ tzinfo-data (1.2022.7)
63
53
  tzinfo (>= 1.0.0)
64
- webmock (2.3.2)
65
- addressable (>= 2.3.6)
54
+ webmock (3.18.1)
55
+ addressable (>= 2.8.0)
66
56
  crack (>= 0.3.2)
67
- hashdiff
68
- yajl-ruby (1.3.1)
57
+ hashdiff (>= 0.4.0, < 2.0.0)
58
+ webrick (1.7.0)
59
+ yajl-ruby (1.4.3)
69
60
 
70
61
  PLATFORMS
71
62
  ruby
72
63
 
73
64
  DEPENDENCIES
74
- coveralls
75
65
  fluent-plugin-syslog-tls!
76
66
  minitest (~> 5.8)
77
67
  minitest-stub_any_instance (~> 1.0.0)
78
68
  rake
79
69
  simplecov (~> 0.11)
80
70
  test-unit (~> 3.1)
81
- webmock (~> 2.0)
71
+ webmock (~> 3.0)
82
72
 
83
73
  BUNDLED WITH
84
- 1.16.1
74
+ 2.3.26
@@ -21,12 +21,16 @@ If a given tag has gone this many seconds between log messages, disconnect and r
21
21
 
22
22
  ### ca_cert
23
23
 
24
- Whether and how to verify the server's TLS certificate. Examples:
24
+ Whether and how to verify the server's TLS certificate signing chain. Examples:
25
25
  * ca_cert system - Default; use the system CA certificate store (which must then be configured correctly)
26
26
  * ca_cert false - Disable verification; not recommended
27
27
  * ca_cert /path/to/file - A path+filename to a single CA file
28
28
  * ca_cert /path/to/dir/ - A directory of CA files (in format that OpenSSL can parse); must end with /
29
29
 
30
+ ### verify_cert_name
31
+
32
+ Whether to verify that the server's cert matches `host`. Enabled by default (except when `ca_cert false`). Recommended; helps prevent MitM attacks. Example: `true`
33
+
30
34
  ### token
31
35
 
32
36
  Some services require a token to identify the account. Example: `ABABABABABABA@99999`. Not required for Papertrail.
@@ -114,6 +118,7 @@ Optionally record key where to get msgid from the record. If not provided nil va
114
118
  token [token]@[iana-id]
115
119
  client_cert /path/to/cert/file.crt
116
120
  client_key /path/to/key/file.key
121
+ verify_cert_name true
117
122
 
118
123
  hostname static-hostname
119
124
  facility SYSLOG
@@ -1,5 +1,5 @@
1
1
  # Copyright 2016 Acquia, Inc.
2
- # Copyright 2016-2018 t.e.morgan.
2
+ # Copyright 2016-2023 t.e.morgan.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
31
31
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
32
32
  s.require_paths = ['lib']
33
- s.required_ruby_version = '>= 2.3.0'
33
+ s.required_ruby_version = '>= 2.5'
34
34
 
35
35
  s.add_runtime_dependency 'fluentd', [">= 0.14.0", "< 2"]
36
36
 
@@ -38,6 +38,6 @@ Gem::Specification.new do |s|
38
38
  s.add_development_dependency 'minitest-stub_any_instance', '~> 1.0.0'
39
39
  s.add_development_dependency 'rake'
40
40
  s.add_development_dependency 'test-unit', '~> 3.1'
41
- s.add_development_dependency 'webmock', '~> 2.0'
41
+ s.add_development_dependency 'webmock', '~> 3.0'
42
42
  s.add_development_dependency 'simplecov', '~> 0.11'
43
43
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright 2016 Acquia, Inc.
2
- # Copyright 2016 t.e.morgan.
2
+ # Copyright 2016-2019 t.e.morgan.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ module Fluent::Plugin
29
29
  config_param :port, :integer
30
30
  config_param :idle_timeout, :integer, default: nil
31
31
  config_param :ca_cert, :string, default: 'system'
32
+ config_param :verify_cert_name, :bool, default: true
32
33
  config_param :token, :string, default: nil
33
34
  config_param :client_cert, :string, default: nil
34
35
  config_param :client_key, :string, default: nil
@@ -98,7 +99,14 @@ module Fluent::Plugin
98
99
  end
99
100
 
100
101
  def new_logger(tag)
101
- transport = ::SyslogTls::SSLTransport.new(host, port, idle_timeout: idle_timeout, ca_cert: ca_cert, client_cert: client_cert, client_key: client_key, max_retries: 3)
102
+ transport = ::SyslogTls::SSLTransport.new(host, port,
103
+ idle_timeout: idle_timeout,
104
+ ca_cert: ca_cert,
105
+ client_cert: client_cert,
106
+ client_key: client_key,
107
+ verify_cert_name: verify_cert_name,
108
+ max_retries: 3,
109
+ )
102
110
  logger = ::SyslogTls::Logger.new(transport, token)
103
111
  logger.facility(facility)
104
112
  logger.hostname(hostname)
@@ -1,5 +1,5 @@
1
1
  # Copyright 2016 Acquia, Inc.
2
- # Copyright 2016 t.e.morgan.
2
+ # Copyright 2016-2023 t.e.morgan.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -25,17 +25,18 @@ module SyslogTls
25
25
 
26
26
  attr_accessor :socket
27
27
 
28
- attr_reader :host, :port, :idle_timeout, :ca_cert, :client_cert, :client_key, :ssl_version
28
+ attr_reader :host, :port, :idle_timeout, :ca_cert, :client_cert, :client_key, :verify_cert_name, :ssl_version
29
29
 
30
30
  attr_writer :retries
31
31
 
32
- def initialize(host, port, idle_timeout: nil, ca_cert: 'system', client_cert: nil, client_key: nil, ssl_version: :TLSv1_2, max_retries: 1)
32
+ def initialize(host, port, idle_timeout: nil, ca_cert: 'system', client_cert: nil, client_key: nil, verify_cert_name: true, ssl_version: :TLS1_2, max_retries: 1)
33
33
  @host = host
34
34
  @port = port
35
35
  @idle_timeout = idle_timeout
36
36
  @ca_cert = ca_cert
37
37
  @client_cert = client_cert
38
38
  @client_key = client_key
39
+ @verify_cert_name = verify_cert_name
39
40
  @ssl_version = ssl_version
40
41
  @retries = max_retries
41
42
  connect
@@ -95,7 +96,9 @@ module SyslogTls
95
96
 
96
97
  ctx = OpenSSL::SSL::SSLContext.new
97
98
  ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
98
- ctx.ssl_version = ssl_version
99
+ ctx.min_version = ssl_version
100
+
101
+ ctx.verify_hostname = verify_cert_name != false
99
102
 
100
103
  case ca_cert
101
104
  when true, 'true', 'system'
@@ -103,6 +106,7 @@ module SyslogTls
103
106
  ctx.cert_store = OpenSSL::X509::Store.new
104
107
  ctx.cert_store.set_default_paths
105
108
  when false, 'false'
109
+ ctx.verify_hostname = false
106
110
  ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
107
111
  when %r{/$} # ends in /
108
112
  ctx.ca_path = ca_cert
@@ -113,6 +117,7 @@ module SyslogTls
113
117
  ctx.cert = OpenSSL::X509::Certificate.new(File.read(client_cert)) if client_cert
114
118
  ctx.key = OpenSSL::PKey::read(File.read(client_key)) if client_key
115
119
  socket = OpenSSL::SSL::SSLSocket.new(tcp, ctx)
120
+ socket.hostname = host
116
121
  socket.sync_close = true
117
122
  socket
118
123
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright 2016 Acquia, Inc.
2
- # Copyright 2016-2018 t.e.morgan.
2
+ # Copyright 2016-2019 t.e.morgan.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,5 +14,5 @@
14
14
  # limitations under the License.
15
15
 
16
16
  module SyslogTls
17
- VERSION = '1.2.1'
17
+ VERSION = '2.1.0.rc1'
18
18
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright 2016 Acquia, Inc.
2
- # Copyright 2016 t.e.morgan.
2
+ # Copyright 2016-2019 t.e.morgan.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -55,6 +55,7 @@ class SyslogTlsOutputTest < Test::Unit::TestCase
55
55
  port 6514
56
56
  client_cert
57
57
  client_key
58
+ verify_cert_name true
58
59
  token 1234567890
59
60
  }
60
61
  instance = driver(config).instance
@@ -63,6 +64,7 @@ class SyslogTlsOutputTest < Test::Unit::TestCase
63
64
  assert_equal '6514', instance.port
64
65
  assert_equal '', instance.client_cert
65
66
  assert_equal '', instance.client_key
67
+ assert_equal true, instance.verify_cert_name
66
68
  assert_equal '1234567890', instance.token
67
69
  end
68
70
 
data/test/helper.rb CHANGED
@@ -12,13 +12,10 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'coveralls'
16
15
  require 'simplecov'
17
16
 
18
17
  SimpleCov.start
19
18
 
20
- Coveralls.wear! if ENV['TRAVIS']
21
-
22
19
  require 'test/unit'
23
20
  require 'fluent/test'
24
21
  require 'minitest/pride'
data/test/ssl.rb CHANGED
@@ -2,12 +2,14 @@ require 'socket'
2
2
  require 'openssl'
3
3
 
4
4
  module SSLTestHelper
5
- def ssl_server
5
+ def ssl_server(min_version: nil, max_version: nil)
6
6
  @ssl_server ||= begin
7
7
  tcp_server = TCPServer.new("localhost", 33000 + Random.rand(1000))
8
8
  ssl_context = OpenSSL::SSL::SSLContext.new
9
9
  ssl_context.cert = certificate
10
10
  ssl_context.key = rsa_key
11
+ ssl_context.min_version = min_version if min_version
12
+ ssl_context.max_version = max_version if max_version
11
13
  OpenSSL::SSL::SSLServer.new(tcp_server, ssl_context)
12
14
  end
13
15
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright 2016 Acquia, Inc.
2
- # Copyright 2016 t.e.morgan.
2
+ # Copyright 2016-2023 t.e.morgan.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -20,19 +20,36 @@ require 'syslog_tls/ssl_transport'
20
20
  class SSLTransportTest < Test::Unit::TestCase
21
21
  include SSLTestHelper
22
22
 
23
- def test_ok_connection
24
- server = ssl_server
25
- st = Thread.new {
26
- client = server.accept
27
- assert_equal "TESTTEST2\n", client.gets
28
- client.close
29
- }
30
- SyslogTls::SSLTransport.stub_any_instance(:get_ssl_connection, ssl_client) do
31
- t = SyslogTls::SSLTransport.new("localhost", server.addr[1], max_retries: 3)
32
- t.write("TEST")
33
- t.write("TEST2\n")
23
+ # srvr-min srvr-max clnt-min should-raise?
24
+ [ [:TLS1_2, :TLS1_2, :TLS1_2],
25
+ [:TLS1_2, :TLS1_3, :TLS1_2],
26
+ [:TLS1_3, :TLS1_3, :TLS1_2],
27
+ [:TLS1_2, :TLS1_2, :TLS1_3, true],
28
+ [:TLS1_2, :TLS1_3, :TLS1_3],
29
+ [:TLS1_3, :TLS1_3, :TLS1_3],
30
+ ].each do |(server_min, server_max, client_min, should_raise)|
31
+ define_method "test_#{server_min}-#{server_max}_server_#{client_min}_client" do
32
+ Thread.report_on_exception = false
33
+ blk = lambda do
34
+ server = ssl_server(min_version: server_min, max_version: server_max)
35
+ st = Thread.new {
36
+ client = server.accept
37
+ assert_equal "TESTTEST2\n", client.gets
38
+ client.close
39
+ }
40
+ t = SyslogTls::SSLTransport.new("localhost", server.addr[1], ca_cert: false, ssl_version: client_min)
41
+ t.write("TEST")
42
+ t.write("TEST2\n")
43
+ st.join
44
+ end
45
+ if should_raise
46
+ assert_raises OpenSSL::SSL::SSLError, &blk
47
+ else
48
+ blk.call
49
+ end
50
+ ensure
51
+ Thread.report_on_exception = true
34
52
  end
35
- st.join
36
53
  end
37
54
 
38
55
  def test_retry
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-syslog-tls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2023-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '2.0'
95
+ version: '3.0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '2.0'
102
+ version: '3.0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: simplecov
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +150,7 @@ homepage: https://github.com/zarqman/fluent-plugin-syslog-tls
150
150
  licenses:
151
151
  - Apache v2
152
152
  metadata: {}
153
- post_install_message:
153
+ post_install_message:
154
154
  rdoc_options: []
155
155
  require_paths:
156
156
  - lib
@@ -158,16 +158,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
158
  requirements:
159
159
  - - ">="
160
160
  - !ruby/object:Gem::Version
161
- version: 2.3.0
161
+ version: '2.5'
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - ">"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 1.3.1
167
167
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.6.13
170
- signing_key:
168
+ rubygems_version: 3.3.26
169
+ signing_key:
171
170
  specification_version: 4
172
171
  summary: Fluent Syslog TLS output plugin
173
172
  test_files: