logstash-output-redis 4.0.4 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03434cdc5a9abfc298250ae6bef7f085ce2732d9f7b6382f6f8f26362ce79a90
4
- data.tar.gz: a0146cd87f5d475de9bb420eea209926bf6aee2635006bedcb8c6dfcdb279920
3
+ metadata.gz: 22c5b60ca0ba0c727372b570fe5c4946065f7a6cf632154c97cd2b18552d035c
4
+ data.tar.gz: d82ef3b0de7f16d4db374a13b81b50adb6ffaba2c6a12063349d5381a2070aa3
5
5
  SHA512:
6
- metadata.gz: 679c2d0aa20058aaaaa6bf95bb959e38ee454c461acf9daa9beebe366e33e95fcc4ad79b92a1c87b5fb9180aeb2f03546b5a974b4f7a13f64cc6a212212ebda7
7
- data.tar.gz: '08cfcd4df976cf98dc6a4e5b2af9617d87debee595bafbeef97ad7799e0b9c98176b996b25f3dd3c156f5340e51c97b19bbe70cfd5f4bea4690f6be149cb66d5'
6
+ metadata.gz: 4cedf0b7eea307f77ef27706f9dfdf3d482928e097fdd1f5d59cccca31fc1206eb93daedf87b84127f262390a8b35d26a3492264cb29a2592dab4bbc9db8eb13
7
+ data.tar.gz: 113541d3dbb624a6c58340bd1d775c4d9d45e5975f644ace941d8f4e33e4966f05800b950eb1f246ae42f895a00d1e825dfa024f411866be25e8555aa80dbc98
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 5.2.0
2
+ - Added support to SSL/TLS configurations [#69](https://github.com/logstash-plugins/logstash-output-redis/pull/69)
3
+ - `ssl_enabled`
4
+ - `ssl_certificate_authorities`
5
+ - `ssl_certificate`
6
+ - `ssl_key`
7
+ - `ssl_verification_mode`
8
+ - `ssl_supported_protocols`
9
+ - `ssl_cipher_suites`
10
+
11
+ ## 5.1.0
12
+ - Added basic support for SSL [#59](https://github.com/logstash-plugins/logstash-output-redis/pull/59)
13
+ - Fixed documentation of required settings [#61](https://github.com/logstash-plugins/logstash-output-redis/pull/61)
14
+
15
+ ## 5.0.0
16
+ - Removed obsolete fields `queue` and `name`
17
+ - Changed major version of redis library dependency to 4.x
18
+
1
19
  ## 4.0.4
2
20
  - Docs: Set the default_codec doc attribute.
3
21
 
data/LICENSE CHANGED
@@ -1,13 +1,202 @@
1
- Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
2
1
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
6
5
 
7
- http://www.apache.org/licenses/LICENSE-2.0
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
7
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2020 Elastic and contributors
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-redis.svg)](https://travis-ci.org/logstash-plugins/logstash-output-redis)
3
+ [![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-output-redis.svg)](https://travis-ci.com/logstash-plugins/logstash-output-redis)
4
4
 
5
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
6
 
data/docs/index.asciidoc CHANGED
@@ -44,14 +44,21 @@ This plugin supports the following configuration options plus the <<plugins-{typ
44
44
  | <<plugins-{type}s-{plugin}-batch_timeout>> |<<number,number>>|No
45
45
  | <<plugins-{type}s-{plugin}-congestion_interval>> |<<number,number>>|No
46
46
  | <<plugins-{type}s-{plugin}-congestion_threshold>> |<<number,number>>|No
47
- | <<plugins-{type}s-{plugin}-data_type>> |<<string,string>>, one of `["list", "channel"]`|No
47
+ | <<plugins-{type}s-{plugin}-data_type>> |<<string,string>>, one of `["list", "channel"]`|Yes
48
48
  | <<plugins-{type}s-{plugin}-db>> |<<number,number>>|No
49
49
  | <<plugins-{type}s-{plugin}-host>> |<<array,array>>|No
50
- | <<plugins-{type}s-{plugin}-key>> |<<string,string>>|No
50
+ | <<plugins-{type}s-{plugin}-key>> |<<string,string>>|Yes
51
51
  | <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
52
52
  | <<plugins-{type}s-{plugin}-port>> |<<number,number>>|No
53
53
  | <<plugins-{type}s-{plugin}-reconnect_interval>> |<<number,number>>|No
54
54
  | <<plugins-{type}s-{plugin}-shuffle_hosts>> |<<boolean,boolean>>|No
55
+ | <<plugins-{type}s-{plugin}-ssl_certificate>> |<<path,path>>|No
56
+ | <<plugins-{type}s-{plugin}-ssl_certificate_authorities>> |list of <<path,path>>|No
57
+ | <<plugins-{type}s-{plugin}-ssl_cipher_suites>> |list of <<string,string>>|No
58
+ | <<plugins-{type}s-{plugin}-ssl_enabled>> |<<boolean,boolean>>|No
59
+ | <<plugins-{type}s-{plugin}-ssl_key>> |<<path,path>>|No
60
+ | <<plugins-{type}s-{plugin}-ssl_supported_protocols>> |<<string,string>>|No
61
+ | <<plugins-{type}s-{plugin}-ssl_verification_mode>> |<<string,string>>, one of `["full", "none"]`|No
55
62
  | <<plugins-{type}s-{plugin}-timeout>> |<<number,number>>|No
56
63
  |=======================================================================
57
64
 
@@ -173,8 +180,16 @@ Password to authenticate with. There is no authentication by default.
173
180
 
174
181
  The default port to connect on. Can be overridden on any hostname.
175
182
 
183
+ [id="plugins-{type}s-{plugin}-ssl"]
184
+ ===== `ssl`
185
+
186
+ * Value type is <<boolean,boolean>>
187
+ * Default value is `false`
188
+
189
+ Enable SSL support.
190
+
176
191
  [id="plugins-{type}s-{plugin}-reconnect_interval"]
177
- ===== `reconnect_interval`
192
+ ===== `reconnect_interval`
178
193
 
179
194
  * Value type is <<number,number>>
180
195
  * Default value is `1`
@@ -189,6 +204,86 @@ Interval for reconnecting to failed Redis connections
189
204
 
190
205
  Shuffle the host list during Logstash startup.
191
206
 
207
+ [id="plugins-{type}s-{plugin}-ssl_certificate"]
208
+ ===== `ssl_certificate`
209
+
210
+ * Value type is <<path,path>>
211
+ * There is no default value for this setting.
212
+
213
+ Path to certificate in PEM format. This certificate will be presented
214
+ to the other part of the TLS connection.
215
+
216
+ [id="plugins-{type}s-{plugin}-ssl_certificate_authorities"]
217
+ ===== `ssl_certificate_authorities`
218
+
219
+ * Value type is <<array,array>>
220
+ * Default value is `[]`
221
+
222
+ Validate the certificate chain against these authorities.
223
+ You can define multiple files. All the certificates will be read and added to the trust store.
224
+ The system CA path is automatically included.
225
+
226
+ [id="plugins-{type}s-{plugin}-ssl_cipher_suites"]
227
+ ===== `ssl_cipher_suites`
228
+
229
+ * Value type is a list of <<string,string>>
230
+ * There is no default value for this setting
231
+
232
+ The list of cipher suites to use, listed by priorities.
233
+ Supported cipher suites vary depending on the Java and protocol versions.
234
+
235
+ [id="plugins-{type}s-{plugin}-ssl_enabled"]
236
+ ===== `ssl_enabled`
237
+
238
+ * Value type is <<boolean,boolean>>
239
+ * Default value is `false`
240
+
241
+ Enable SSL (must be set for other `ssl_` options to take effect).
242
+
243
+ [id="plugins-{type}s-{plugin}-ssl_key"]
244
+ ===== `ssl_key`
245
+
246
+ * Value type is <<path,path>>
247
+ * There is no default value for this setting.
248
+
249
+ SSL key path
250
+
251
+ [id="plugins-{type}s-{plugin}-ssl_key_passphrase"]
252
+ ===== `ssl_key_passphrase`
253
+
254
+ * Value type is <<password,password>>
255
+ * Default value is `nil`
256
+
257
+ SSL key passphrase
258
+
259
+ [id="plugins-{type}s-{plugin}-ssl_supported_protocols"]
260
+ ===== `ssl_supported_protocols`
261
+
262
+ * Value type is <<string,string>>
263
+ * Allowed values are: `'TLSv1.1'`, `'TLSv1.2'`, `'TLSv1.3'`
264
+ * Default depends on the JDK being used. With up-to-date Logstash, the default is `['TLSv1.2', 'TLSv1.3']`.
265
+ `'TLSv1.1'` is not considered secure and is only provided for legacy applications.
266
+
267
+ List of allowed SSL/TLS versions to use when establishing a secure connection.
268
+
269
+ NOTE: If you configure the plugin to use `'TLSv1.1'` on any recent JVM, such as the one packaged with Logstash,
270
+ the protocol is disabled by default and needs to be enabled manually by changing `jdk.tls.disabledAlgorithms` in
271
+ the *$JDK_HOME/conf/security/java.security* configuration file. That is, `TLSv1.1` needs to be removed from the list.
272
+
273
+ [id="plugins-{type}s-{plugin}-ssl_verification_mode"]
274
+ ===== `ssl_verification_mode`
275
+
276
+ * Value can be any of: `full`, `none`
277
+ * Default value is `full`
278
+
279
+ Defines how to verify the certificates presented by another part in the TLS connection:
280
+
281
+ `full` validates that the server certificate has an issue date that's within
282
+ the not_before and not_after dates; chains to a trusted Certificate Authority (CA), and
283
+ has a hostname or IP address that matches the names within the certificate.
284
+
285
+ `none` performs no certificate validation.
286
+
192
287
  [id="plugins-{type}s-{plugin}-timeout"]
193
288
  ===== `timeout`
194
289
 
@@ -202,4 +297,4 @@ Redis initial connection timeout in seconds.
202
297
  [id="plugins-{type}s-{plugin}-common-options"]
203
298
  include::{include_path}/{type}.asciidoc[]
204
299
 
205
- :default_codec!:
300
+ :default_codec!:
@@ -20,9 +20,6 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
20
20
 
21
21
  default :codec, "json"
22
22
 
23
- # Name is used for logging in case there are multiple instances.
24
- config :name, :validate => :string, :obsolete => "This option is obsolete"
25
-
26
23
  # The hostname(s) of your Redis server(s). Ports may be specified on any
27
24
  # hostname, which will override the global port config.
28
25
  # If the hosts list is an array, Logstash will pick one random host to connect to,
@@ -41,6 +38,34 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
41
38
  # The default port to connect on. Can be overridden on any hostname.
42
39
  config :port, :validate => :number, :default => 6379
43
40
 
41
+ # SSL
42
+ config :ssl_enabled, :validate => :boolean, :default => false
43
+
44
+ # Validate the certificate chain against these authorities. You can define multiple files.
45
+ # All the certificates will be read and added to the trust store.
46
+ config :ssl_certificate_authorities, :validate => :path, :list => true
47
+
48
+ # Options to verify the server's certificate.
49
+ # "full": validates that the provided certificate has an issue date that’s within the not_before and not_after dates;
50
+ # chains to a trusted Certificate Authority (CA); has a hostname or IP address that matches the names within the certificate.
51
+ # "none": performs no certificate validation. Disabling this severely compromises security (https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf)
52
+ config :ssl_verification_mode, :validate => %w[full none], :default => 'full'
53
+
54
+ # SSL certificate path
55
+ config :ssl_certificate, :validate => :path
56
+
57
+ # SSL key path
58
+ config :ssl_key, :validate => :path
59
+
60
+ # SSL key passphrase
61
+ config :ssl_key_passphrase, :validate => :password, :default => nil
62
+
63
+ # NOTE: the default setting [] uses SSL engine defaults
64
+ config :ssl_supported_protocols, :validate => %w[TLSv1.1 TLSv1.2 TLSv1.3], :default => [], :list => true
65
+
66
+ # The list of ciphers suite to use
67
+ config :ssl_cipher_suites, :validate => :string, :list => true
68
+
44
69
  # The Redis database number.
45
70
  config :db, :validate => :number, :default => 0
46
71
 
@@ -50,8 +75,6 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
50
75
  # Password to authenticate with. There is no authentication by default.
51
76
  config :password, :validate => :password
52
77
 
53
- config :queue, :validate => :string, :obsolete => "This option is obsolete. Use `key` and `data_type`."
54
-
55
78
  # The name of a Redis list or channel. Dynamic names are
56
79
  # valid here, for example `logstash-%{type}`.
57
80
  config :key, :validate => :string, :required => true
@@ -95,6 +118,8 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
95
118
  def register
96
119
  require 'redis'
97
120
 
121
+ validate_ssl_config!
122
+
98
123
  if @batch
99
124
  if @data_type != "list"
100
125
  raise RuntimeError.new(
@@ -189,8 +214,12 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
189
214
  :host => @current_host,
190
215
  :port => @current_port,
191
216
  :timeout => @timeout,
192
- :db => @db
217
+ :db => @db,
218
+ :ssl => @ssl_enabled,
193
219
  }
220
+
221
+ params[:ssl_params] = setup_ssl_params if @ssl_enabled
222
+
194
223
  @logger.debug("connection params", params)
195
224
 
196
225
  if @password
@@ -200,6 +229,67 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
200
229
  Redis.new(params)
201
230
  end # def connect
202
231
 
232
+ def setup_ssl_params
233
+ require "openssl"
234
+
235
+ params = {}
236
+ params[:cert_store] = ssl_certificate_store
237
+
238
+ if @ssl_verification_mode == 'none'
239
+ params[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
240
+ else
241
+ params[:verify_mode] = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
242
+ end
243
+
244
+ if @ssl_certificate
245
+ params[:cert] = OpenSSL::X509::Certificate.new(File.read(@ssl_certificate))
246
+ if @ssl_key
247
+ # if we have an encrypted key and a password is not provided (nil) than OpenSSL::PKey::RSA
248
+ # prompts the user to enter a password interactively - we do not want to do that,
249
+ # for plain-text keys the default '' password argument gets simply ignored
250
+ params[:key] = OpenSSL::PKey::RSA.new(File.read(@ssl_key), @ssl_key_passphrase.value || '')
251
+ end
252
+ end
253
+
254
+ params[:min_version] = :TLS1_1
255
+ if @ssl_supported_protocols.any?
256
+ protocols = @ssl_supported_protocols.map { |v| v.delete('v').tr(".", "_").to_sym }.sort
257
+ params[:min_version] = protocols.first
258
+ params[:max_version] = protocols.last
259
+ end
260
+
261
+ params[:ciphers] = @ssl_cipher_suites if @ssl_cipher_suites&.any?
262
+ params
263
+ end
264
+
265
+ def ssl_certificate_store
266
+ cert_store = new_ssl_certificate_store
267
+ cert_store.set_default_paths
268
+ @ssl_certificate_authorities&.each do |cert|
269
+ cert_store.add_file(cert)
270
+ end
271
+
272
+ cert_store
273
+ end
274
+
275
+ def new_ssl_certificate_store
276
+ OpenSSL::X509::Store.new
277
+ end
278
+
279
+ def validate_ssl_config!
280
+ unless @ssl_enabled
281
+ ignored_ssl_settings = original_params.select { |k| k != 'ssl_enabled' && k.start_with?('ssl_') }
282
+ @logger.warn("Configured SSL settings are not used when `ssl_enabled` is set to `false`: #{ignored_ssl_settings.keys}") if ignored_ssl_settings.any?
283
+ return
284
+ end
285
+
286
+ if @ssl_certificate && !@ssl_key
287
+ raise LogStash::ConfigurationError, "Using an `ssl_certificate` requires an `ssl_key`"
288
+ elsif @ssl_key && !@ssl_certificate
289
+ raise LogStash::ConfigurationError, 'An `ssl_certificate` is required when using an `ssl_key`'
290
+ end
291
+ end
292
+
203
293
  # A string used to identify a Redis instance in log messages
204
294
  def identity
205
295
  "redis://#{@password}@#{@current_host}:#{@current_port}/#{@db} #{@data_type}:#{@key}"
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-redis'
4
- s.version = '4.0.4'
4
+ s.version = '5.2.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Sends events to a Redis queue using the `RPUSH` command"
7
7
  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"
@@ -21,8 +21,9 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # Gem dependencies
23
23
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
24
+ s.add_runtime_dependency 'logstash-core', '>= 6.0'
24
25
 
25
- s.add_runtime_dependency 'redis', '~> 3'
26
+ s.add_runtime_dependency 'redis', '~> 4'
26
27
  s.add_runtime_dependency 'stud'
27
28
 
28
29
  s.add_development_dependency 'logstash-devutils'
@@ -0,0 +1,31 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFSzCCAzOgAwIBAgIUKvrJklkPPavWxOu4m3Lk6Odcii4wDQYJKoZIhvcNAQEL
3
+ BQAwNTETMBEGA1UECgwKUmVkaXMgVGVzdDEeMBwGA1UEAwwVQ2VydGlmaWNhdGUg
4
+ QXV0aG9yaXR5MB4XDTI0MDUxNjE4NDUzOVoXDTM0MDUxNDE4NDUzOVowNTETMBEG
5
+ A1UECgwKUmVkaXMgVGV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HHLpeOU0W7o89/GEBjIZxFma6Idg6RTxj7HSuxnpshL66eNOvUsJH82LCsQUuCOs
39
+ iuPZUDIxSWP01kdAqsBCtze69udf8qZ8+D+pQocri3Q7sUAQbHbgbAtdVtvZCRwu
40
+ ijHGWG5lP0B4Dwzy+sDeHpdCtLM2rmLifK02/lECggEAY9vSUjoPUA5VvZVAIyAY
41
+ sINdkOka1/ix6DzdvokBuovorW4ChFFImS4XB0fDT6KONqT2iewOh5peGk0FZuNS
42
+ KKXLFrjj2OA0qYyaZRlFeQCOhGtfGom5DnQ36tZQb63WIktCVXNhbF/NWsBbNNjR
43
+ HKPFaIfJJPwgJ4ujphdKfF8+qu6bxS4prKtFCg53ZcnN4u2z/wntRU1MZWFiVsPX
44
+ m3kzfVH/hDCIALaThJaJoRqP/mPDnz0s5BqtT7i/xirx/hSmMSthMCJHohXN3MPz
45
+ pKioBoNNawREoMuno/IU6escRJYytPiGkcxnFel0m4F9UAG2MAp9niZgTigWbSKc
46
+ gQKCAQBykTYZ1LlUwxxx1BmdGBW5THKzjbo5Xp9amagtFfeFBF3c1/nnNCIXvbYk
47
+ PG9vyZ1on/Ic9CBzehHloLfjSRuBSNXkrpOnCeSTBRwwMXca0JbJJ85i6IGxhO6o
48
+ T6VP/mXU81LnIbRGsWVOGwZyvN0MAJH30zH7vAjs1e4qvUrT7B4lC8BqOdNAsqIq
49
+ R8j6N0BNSjCEumZG6LK4UMa0mYG0UFHiEZpjpK3qY1ddkouttPNVOE5FcdCko6YK
50
+ +HByMtgqlEMNFfTd673ScnxMyRgmlmlUL1RSfoBv5LTRp5a81BKUDD+82B5TUBY3
51
+ oDGPtZqf+lH6or1EtANdnw3K5AyN
52
+ -----END PRIVATE KEY-----
@@ -0,0 +1 @@
1
+ 47A3D82860FAB19E7F26B8FF7043280173FB5832
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEUjCCAjqgAwIBAgIUR6PYKGD6sZ5/Jrj/cEMoAXP7WDE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
25
+ ZPOdlv3Xp2jz7L0LOIiYggNXniiBq0IT7Xtu8FYNZ2vnMPi1PsQENqO89vlFeJ92
26
+ 5l2ZMfKceGjc3zxyWQzqPhXXbukBbQC1TYUP+ZxxghRmy5PCTn+siNW4UO1dtUh2
27
+ s3QtMleyQEr8SusIpJEnG+/ErQ==
28
+ -----END PRIVATE KEY-----
@@ -0,0 +1,60 @@
1
+
2
+ #!/bin/bash
3
+
4
+ # COPIED/MODIFIED from the redis server gen-certs util
5
+ # https://github.com/redis/redis/blob/cc0091f0f9fe321948c544911b3ea71837cf86e3/utils/gen-test-certs.sh
6
+
7
+ # Generate some test certificates which are used by the regression test suite:
8
+ #
9
+ # ca.{crt,key} Self signed CA certificate.
10
+ # redis.{crt,key} A certificate with no key usage/policy restrictions.
11
+ # client.{crt,key} A certificate restricted for SSL client usage.
12
+ # server.{crt,key} A certificate restricted for SSL server usage.
13
+ # redis.dh DH Params file.
14
+
15
+ generate_cert() {
16
+ local name=$1
17
+ local cn="$2"
18
+ local opts="$3"
19
+
20
+ local keyfile=${name}.key
21
+ local certfile=${name}.crt
22
+
23
+ [ -f $keyfile ] || openssl genrsa -out $keyfile 2048
24
+ openssl req \
25
+ -new -sha256 \
26
+ -subj "/O=Redis Test/CN=$cn" \
27
+ -key $keyfile | \
28
+ openssl x509 \
29
+ -req -sha256 \
30
+ -CA ca.crt \
31
+ -CAkey ca.key \
32
+ -CAserial ca.txt \
33
+ -CAcreateserial \
34
+ -days 999999 \
35
+ $opts \
36
+ -out $certfile
37
+ }
38
+
39
+ [ -f ca.key ] || openssl genrsa -out ca.key 4096
40
+ openssl req \
41
+ -x509 -new -nodes -sha256 \
42
+ -key ca.key \
43
+ -days 3650 \
44
+ -subj '/O=Redis Test/CN=Certificate Authority' \
45
+ -out ca.crt
46
+
47
+ cat > openssl.cnf <<_END_
48
+ [ server_cert ]
49
+ keyUsage = digitalSignature, keyEncipherment
50
+ nsCertType = server
51
+ [ client_cert ]
52
+ keyUsage = digitalSignature, keyEncipherment
53
+ nsCertType = client
54
+ _END_
55
+
56
+ generate_cert server "Server-only" "-extfile openssl.cnf -extensions server_cert"
57
+ generate_cert client "Client-only" "-extfile openssl.cnf -extensions client_cert"
58
+ generate_cert redis "Generic-cert"
59
+
60
+ [ -f redis.dh ] || openssl dhparam -out redis.dh 2048
@@ -0,0 +1,6 @@
1
+ [ server_cert ]
2
+ keyUsage = digitalSignature, keyEncipherment
3
+ nsCertType = server
4
+ [ client_cert ]
5
+ keyUsage = digitalSignature, keyEncipherment
6
+ nsCertType = client
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEMzCCAhugAwIBAgIUR6PYKGD6sZ5/Jrj/cEMoAXP7WDIwDQYJKoZIhvcNAQEL
3
+ BQAwNTETMBEGA1UECgwKUmVkaXMgVGVzdDEeMBwGA1UEAwwVQ2VydGlmaWNhdGUg
4
+ QXV0aG9yaXR5MCAXDTI0MDUxNjE4NDUzOVoYDzQ3NjIwNDEyMTg0NTM5WjAsMRMw
5
+ EQYDVQQKDApSZWRpcyBUZXN0MRUwEwYDVQQDDAxHZW5lcmljLWNlcnQwggEiMA0G
6
+ CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3kvR6caLws6+HAFpxx3nrA0pK4AKa
7
+ tALoFRjWe+7eKqAuXquSJRXHoVPhVXATcMZ1oePPjfDw3LYcDOT6l2BC+ixqyvlC
8
+ 7zngVNgFjpX9oOO6pkeLFre38R+u1U516L4H/MpiqB9S4/YtGV7HXZCCPctVQjGJ
9
+ 6VuxSHBqxJBXPtBw3U11JfKMOHE8MNXXP9mc9tBAZDg4tWuP5fRZ3P4urnen2iTq
10
+ q/xpuoj7bXAfNNzhbKYEWCFJvbPqIGvDz8JXdywrUaOa4hRctNjqKz5feTwd6A8f
11
+ 9DW87blj6i2/HwF3AZchOPs52O3vvHrw5zQS9qJlgAEq1nR/TZo6sQt1AgMBAAGj
12
+ QjBAMB0GA1UdDgQWBBT+stkMkr87n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vidlPngZDVvIBSw3b4woK3m+r1+bDpQseDATmTDaaItdHSktmTw
26
+ fNGAZFyfZmXtmmuPJu16j62ML0YlRWUSAvbD3ntCIKs0zRjyywSOJs/gnaJKNIhB
27
+ Pj3xop1kUBPxx2Y9Kcu2bg2C
28
+ -----END PRIVATE KEY-----
@@ -6,8 +6,13 @@ require "flores/random"
6
6
 
7
7
  describe LogStash::Outputs::Redis do
8
8
 
9
+ FIXTURES_PATH = File.expand_path('../../fixtures', File.dirname(__FILE__))
10
+ PORT = 16379
11
+ SSL_PORT = 26379
12
+
9
13
  context "integration tests", :integration => true do
10
14
  shared_examples_for "writing to redis list" do |extra_config|
15
+ let(:timeout) { 5 }
11
16
  let(:key) { 10.times.collect { rand(10).to_s }.join("") }
12
17
  let(:event_count) { Flores::Random.integer(0..10000) }
13
18
  let(:message) { Flores::Random.text(0..100) }
@@ -15,7 +20,9 @@ describe LogStash::Outputs::Redis do
15
20
  {
16
21
  "key" => key,
17
22
  "data_type" => "list",
18
- "host" => "localhost"
23
+ "host" => "redis",
24
+ "port" => PORT,
25
+ "timeout" => timeout
19
26
  }
20
27
  }
21
28
  let(:redis_config) {
@@ -23,6 +30,19 @@ describe LogStash::Outputs::Redis do
23
30
  }
24
31
  let(:redis_output) { described_class.new(redis_config) }
25
32
 
33
+ let(:redis) do
34
+ ssl_enabled = redis_config['ssl_enabled'] == true
35
+ cli_config = {
36
+ :host => redis_config["host"],
37
+ :port => redis_config["port"] || PORT,
38
+ :timeout => timeout,
39
+ :ssl => ssl_enabled
40
+ }
41
+
42
+ cli_config[:ssl_params] = redis_output.send(:setup_ssl_params) if ssl_enabled
43
+ Redis.new(cli_config)
44
+ end
45
+
26
46
  before do
27
47
  redis_output.register
28
48
  event_count.times do |i|
@@ -32,22 +52,24 @@ describe LogStash::Outputs::Redis do
32
52
  redis_output.close
33
53
  end
34
54
 
35
- it "should successfully send all events to redis" do
36
- redis = Redis.new(:host => "127.0.0.1")
55
+ after do
56
+ redis.del(key)
57
+ end
37
58
 
59
+ it "should successfully send all events to redis" do
38
60
  # The list should contain the number of elements our agent pushed up.
39
- insist { redis.llen(key) } == event_count
61
+ expect(redis.llen(key)).to eql event_count
40
62
 
41
63
  # Now check all events for order and correctness.
42
64
  event_count.times do |value|
43
- id, element = redis.blpop(key, 0)
65
+ id, element = redis.blpop(key, :timeout => timeout)
44
66
  event = LogStash::Event.new(LogStash::Json.load(element))
45
- insist { event.get("sequence") } == value
46
- insist { event.get("message") } == message
67
+ expect(event.get("sequence")).to eql value
68
+ expect(event.get("message")).to eql message
47
69
  end
48
70
 
49
71
  # The list should now be empty
50
- insist { redis.llen(key) } == 0
72
+ expect(redis.llen(key)).to eql 0
51
73
  end
52
74
  end
53
75
 
@@ -55,11 +77,41 @@ describe LogStash::Outputs::Redis do
55
77
  include_examples "writing to redis list"
56
78
  end
57
79
 
80
+ context "when SSL is enabled" do
81
+ context "with client certificate and key" do
82
+ ssl_config = {
83
+ "host" => "redis_ssl",
84
+ "port" => SSL_PORT,
85
+ "ssl_enabled" => true,
86
+ "ssl_certificate_authorities" => File.join(FIXTURES_PATH, 'certificates/ca.crt'),
87
+ "ssl_certificate" => File.join(FIXTURES_PATH, 'certificates/client.crt'),
88
+ "ssl_key" => File.join(FIXTURES_PATH, 'certificates/client.key')
89
+ }
90
+
91
+ include_examples "writing to redis list", ssl_config
92
+ end
93
+
94
+ context "with ssl_verification_mode => none" do
95
+ ssl_config = {
96
+ "host" => "redis_ssl",
97
+ "port" => SSL_PORT,
98
+ "ssl_enabled" => true,
99
+ "ssl_verification_mode" => "none",
100
+ "ssl_certificate" => File.join(FIXTURES_PATH, 'certificates/client.crt'),
101
+ "ssl_key" => File.join(FIXTURES_PATH, 'certificates/client.key')
102
+ }
103
+
104
+ include_examples "writing to redis list", ssl_config
105
+ end
106
+
107
+ end
108
+
58
109
  context "when batch_mode is true" do
59
110
  batch_events = Flores::Random.integer(1..1000)
60
111
  batch_settings = {
61
112
  "batch" => true,
62
- "batch_events" => batch_events
113
+ "batch_events" => batch_events,
114
+ "port" => PORT
63
115
  }
64
116
 
65
117
  include_examples "writing to redis list", batch_settings do
@@ -74,4 +126,3 @@ describe LogStash::Outputs::Redis do
74
126
  end
75
127
  end
76
128
  end
77
-
@@ -3,6 +3,7 @@ require "logstash/outputs/redis"
3
3
  require "logstash/json"
4
4
  require "redis"
5
5
  require "flores/random"
6
+ require "flores/pki"
6
7
 
7
8
  describe LogStash::Outputs::Redis do
8
9
 
@@ -38,5 +39,106 @@ describe LogStash::Outputs::Redis do
38
39
  end
39
40
  end
40
41
  end
41
- end
42
42
 
43
+ context "with SSL enabled" do
44
+ let(:config) {{ "ssl_enabled" => true, "key" => "key", "data_type" => "list" }}
45
+ subject(:plugin) { described_class.new(config) }
46
+
47
+ context "and not providing a certificate/key pair" do
48
+ it "registers without error" do
49
+ expect { plugin.register }.to_not raise_error
50
+ end
51
+ end
52
+
53
+ context "and providing a certificate/key pair" do
54
+ let(:cert_key_pair) { Flores::PKI.generate }
55
+ let(:certificate) do
56
+ path = Tempfile.new('certificate').path
57
+ IO.write(path, cert_key_pair.first.to_s)
58
+ path
59
+ end
60
+ let(:key) do
61
+ path = Tempfile.new('key').path
62
+ IO.write(path, cert_key_pair[1].to_s)
63
+ path
64
+ end
65
+ let(:config) { super().merge("ssl_certificate" => certificate, "ssl_key" => key) }
66
+
67
+ it "registers without error" do
68
+ expect { plugin.register }.to_not raise_error
69
+ end
70
+ end
71
+
72
+ FIXTURES_PATH = File.expand_path('../../fixtures', File.dirname(__FILE__))
73
+
74
+ context "and plain-text certificate/key" do
75
+ let(:key_file) { File.join(FIXTURES_PATH, 'certificates/redis.key') }
76
+ let(:crt_file) { File.join(FIXTURES_PATH, 'certificates/redis.crt') }
77
+ let(:config) { super().merge("ssl_certificate" => crt_file, "ssl_key" => key_file) }
78
+
79
+ it "registers without error" do
80
+ expect { plugin.register }.to_not raise_error
81
+ end
82
+
83
+ context 'with password set' do
84
+ let(:config) { super().merge("ssl_key_passphrase" => 'ignored') }
85
+
86
+ it "registers without error" do # password simply ignored
87
+ expect { plugin.register }.to_not raise_error
88
+ end
89
+ end
90
+
91
+ context 'with supported protocol' do
92
+ let(:config) { super().merge("ssl_supported_protocols" => %w[TLSv1.2 TLSv1.3]) }
93
+
94
+ it 'configures minimum TLS version' do
95
+ plugin.register
96
+ ssl_params = plugin.send(:setup_ssl_params)
97
+ expect(ssl_params).to match(a_hash_including(:min_version => :TLS1_2, :max_version => :TLS1_3))
98
+ end
99
+ end
100
+ end
101
+
102
+ context "with only ssl_certificate set" do
103
+ let(:config) { super().merge("ssl_certificate" => File.join(FIXTURES_PATH, 'certificates/redis.crt')) }
104
+
105
+ it "should raise a configuration error to request also `ssl_key`" do
106
+ expect { plugin.register }.to raise_error(LogStash::ConfigurationError, /Using an `ssl_certificate` requires an `ssl_key`/)
107
+ end
108
+ end
109
+
110
+ context "with only ssl_key set" do
111
+ let(:config) { super().merge("ssl_key" => File.join(FIXTURES_PATH, 'certificates/redis.key')) }
112
+
113
+ it "should raise a configuration error to request also `ssl_key`" do
114
+ expect { plugin.register }.to raise_error(LogStash::ConfigurationError, /An `ssl_certificate` is required when using an `ssl_key`/)
115
+ end
116
+ end
117
+
118
+ context "with ssl_certificate_authorities" do
119
+ let(:certificate_path) { File.join(FIXTURES_PATH, 'certificates/redis.crt') }
120
+ let(:config) do
121
+ super().merge('ssl_certificate_authorities' => [certificate_path])
122
+ end
123
+
124
+ it "sets cert_store values" do
125
+ ssl_store = double(OpenSSL::X509::Store.new)
126
+ allow(ssl_store).to receive(:set_default_paths)
127
+ allow(ssl_store).to receive(:add_file)
128
+ allow(subject).to receive(:new_ssl_certificate_store).and_return(ssl_store)
129
+ subject.send :setup_ssl_params
130
+ expect(ssl_store).to have_received(:add_file).with(certificate_path)
131
+ end
132
+ end
133
+
134
+ context "CAs certificates" do
135
+ it "includes openssl default paths" do
136
+ ssl_store = double(OpenSSL::X509::Store.new)
137
+ allow(ssl_store).to receive(:set_default_paths)
138
+ allow(plugin).to receive(:new_ssl_certificate_store).and_return(ssl_store)
139
+ subject.send :setup_ssl_params
140
+ expect(ssl_store).to have_received(:set_default_paths)
141
+ end
142
+ end
143
+ end
144
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.4
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-06 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -30,12 +30,26 @@ dependencies:
30
30
  - - "<="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.99'
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '6.0'
39
+ name: logstash-core
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '6.0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  requirement: !ruby/object:Gem::Requirement
35
49
  requirements:
36
50
  - - "~>"
37
51
  - !ruby/object:Gem::Version
38
- version: '3'
52
+ version: '4'
39
53
  name: redis
40
54
  prerelease: false
41
55
  type: :runtime
@@ -43,7 +57,7 @@ dependencies:
43
57
  requirements:
44
58
  - - "~>"
45
59
  - !ruby/object:Gem::Version
46
- version: '3'
60
+ version: '4'
47
61
  - !ruby/object:Gem::Dependency
48
62
  requirement: !ruby/object:Gem::Requirement
49
63
  requirements:
@@ -131,6 +145,18 @@ files:
131
145
  - docs/index.asciidoc
132
146
  - lib/logstash/outputs/redis.rb
133
147
  - logstash-output-redis.gemspec
148
+ - spec/fixtures/certificates/ca.crt
149
+ - spec/fixtures/certificates/ca.key
150
+ - spec/fixtures/certificates/ca.txt
151
+ - spec/fixtures/certificates/client.crt
152
+ - spec/fixtures/certificates/client.key
153
+ - spec/fixtures/certificates/gen-test-certs.sh
154
+ - spec/fixtures/certificates/openssl.cnf
155
+ - spec/fixtures/certificates/redis.crt
156
+ - spec/fixtures/certificates/redis.dh
157
+ - spec/fixtures/certificates/redis.key
158
+ - spec/fixtures/certificates/server.crt
159
+ - spec/fixtures/certificates/server.key
134
160
  - spec/integration/outputs/redis_spec.rb
135
161
  - spec/unit/outputs/redis_spec.rb
136
162
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
@@ -154,11 +180,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
180
  - !ruby/object:Gem::Version
155
181
  version: '0'
156
182
  requirements: []
157
- rubyforge_project:
158
- rubygems_version: 2.6.11
183
+ rubygems_version: 3.2.33
159
184
  signing_key:
160
185
  specification_version: 4
161
186
  summary: Sends events to a Redis queue using the `RPUSH` command
162
187
  test_files:
188
+ - spec/fixtures/certificates/ca.crt
189
+ - spec/fixtures/certificates/ca.key
190
+ - spec/fixtures/certificates/ca.txt
191
+ - spec/fixtures/certificates/client.crt
192
+ - spec/fixtures/certificates/client.key
193
+ - spec/fixtures/certificates/gen-test-certs.sh
194
+ - spec/fixtures/certificates/openssl.cnf
195
+ - spec/fixtures/certificates/redis.crt
196
+ - spec/fixtures/certificates/redis.dh
197
+ - spec/fixtures/certificates/redis.key
198
+ - spec/fixtures/certificates/server.crt
199
+ - spec/fixtures/certificates/server.key
163
200
  - spec/integration/outputs/redis_spec.rb
164
201
  - spec/unit/outputs/redis_spec.rb