logstash-input-http 3.3.3-java → 3.4.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/LICENSE +199 -10
- data/README.md +1 -1
- data/VERSION +1 -1
- data/docs/index.asciidoc +93 -2
- data/lib/logstash-input-http_jars.rb +2 -3
- data/lib/logstash/inputs/http.rb +86 -20
- data/lib/logstash/inputs/http/message_handler.rb +4 -7
- data/logstash-input-http.gemspec +1 -0
- data/spec/inputs/http_spec.rb +219 -86
- data/vendor/jar-dependencies/io/netty/netty-all/4.1.49.Final/netty-all-4.1.49.Final.jar +0 -0
- data/vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/3.4.0/logstash-input-http-3.4.0.jar +0 -0
- metadata +18 -5
- data/vendor/jar-dependencies/io/netty/netty-all/4.1.30.Final/netty-all-4.1.30.Final.jar +0 -0
- data/vendor/jar-dependencies/io/netty/netty-tcnative-boringssl-static/2.0.12.Final/netty-tcnative-boringssl-static-2.0.12.Final.jar +0 -0
- data/vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/3.3.3/logstash-input-http-3.3.3.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b87a5c0d794b79c2fbc32f0019893258464c106d651b97ea461491d3abe82a3
|
4
|
+
data.tar.gz: d8a60c43c88913797b62e14d6724ab1ad263a65bccc02d2e60ff8e166c6950e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4489b8a66bd3a3a5f35c7d95f9f7c20a450b84aefe5416418983a3ec05ef41a278c78eaa48f40389d7262191a47c0fb9e2c43047af3f1817c9ca2c5871a783f0
|
7
|
+
data.tar.gz: 3c3c75d19312c553b31ed1144c59184c39ed5a6f5a96b3674c55c9b851c050206de08fa2900b1546d0fa416aff41a974efe8f035df4d08119b4f094dcf4cfd5b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## 3.4.0
|
2
|
+
- Add ECS support, mapping Http header to ECS compatible fields [#137](https://github.com/logstash-plugins/logstash-input-http/pull/137)
|
3
|
+
|
4
|
+
## 3.3.7
|
5
|
+
- Feat: improved error handling/logging/unwraping [#133](https://github.com/logstash-plugins/logstash-input-http/pull/133)
|
6
|
+
|
7
|
+
## 3.3.6
|
8
|
+
- Fixes a regression introduced in 3.1.0's migration to the Netty back-end that broke some users'
|
9
|
+
browser-based workflows. When an instance of this plugin that is configured to require Basic
|
10
|
+
authentication receives a request that does not include authentication, it now appropriately
|
11
|
+
includes an `WWW-Authenticate` header in its `401 Unauthorized` response, allowing the browser
|
12
|
+
to collect credentials before retrying the request.
|
13
|
+
|
14
|
+
## 3.3.5
|
15
|
+
- Updated jackson databind and Netty dependencies. Additionally, this release removes the dependency on `tcnative` +
|
16
|
+
`boringssl`, using JVM supplied ciphers instead. This may result in fewer ciphers being available if the JCE
|
17
|
+
unlimited strength jurisdiction policy is not installed. (This policy is installed by default on versions of the
|
18
|
+
JDK from u161 onwards)[#126](https://github.com/logstash-plugins/logstash-input-http/pull/126)
|
19
|
+
|
20
|
+
## 3.3.4
|
21
|
+
- Refactor: scope (and avoid unused) java imports [#124](https://github.com/logstash-plugins/logstash-input-http/pull/124)
|
22
|
+
|
1
23
|
## 3.3.3
|
2
24
|
- Revert updates to netty and tcnative since CBC ciphers are still used in many contexts
|
3
25
|
- More about the reasoning can be found [here](https://github.com/elastic/logstash/issues/11499#issuecomment-580333510)
|
data/LICENSE
CHANGED
@@ -1,13 +1,202 @@
|
|
1
|
-
Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
6
5
|
|
7
|
-
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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.
|
3
|
+
[![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-input-http.svg)](https://travis-ci.com/logstash-plugins/logstash-input-http)
|
4
4
|
|
5
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
6
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.0
|
data/docs/index.asciidoc
CHANGED
@@ -32,6 +32,28 @@ This input can also be used to receive webhook requests to integrate with other
|
|
32
32
|
and applications. By taking advantage of the vast plugin ecosystem available in Logstash
|
33
33
|
you can trigger actionable events right from your application.
|
34
34
|
|
35
|
+
[id="plugins-{type}s-{plugin}-ecs_metadata"]
|
36
|
+
==== Event Metadata and the Elastic Common Schema (ECS)
|
37
|
+
In addition to decoding the events, this input will add HTTP headers containing connection information to each event.
|
38
|
+
When ECS compatibility is disabled, the headers are stored in the `headers` field, which has the potential to create confusion and schema conflicts downstream.
|
39
|
+
When ECS is enabled, we can ensure a pipeline maintains access to this metadata throughout the event's lifecycle without polluting the top-level namespace.
|
40
|
+
|
41
|
+
Here’s how ECS compatibility mode affects output.
|
42
|
+
[cols="<l,<l,e,<e"]
|
43
|
+
|=======================================================================
|
44
|
+
| ECS disabled | ECS v1 | Availability | Description
|
45
|
+
|
46
|
+
| [host] | [host][ip] | Always | Host IP address
|
47
|
+
| [headers] | [@metadata][input][http][request][headers] | Always | Complete HTTP headers
|
48
|
+
| [headers][http_version] | [http][version] | Always | HTTP version
|
49
|
+
| [headers][http_user_agent] | [user_agent][original] | Always | client user agent
|
50
|
+
| [headers][http_host] | [url][domain] and [url][port] | Always | host domain and port
|
51
|
+
| [headers][request_method] | [http][method] | Always | HTTP method
|
52
|
+
| [headers][request_path] | [url][path] | Always | Query path
|
53
|
+
| [headers][content_length] | [http][request][body][bytes] | Always | Request content length
|
54
|
+
| [headers][content_type] | [http][request][mime_type] | Always | Request mime type
|
55
|
+
|=======================================================================
|
56
|
+
|
35
57
|
==== Blocking Behavior
|
36
58
|
|
37
59
|
The HTTP protocol doesn't deal well with long running requests. This plugin will either return
|
@@ -70,6 +92,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
70
92
|
|Setting |Input type|Required
|
71
93
|
| <<plugins-{type}s-{plugin}-additional_codecs>> |<<hash,hash>>|No
|
72
94
|
| <<plugins-{type}s-{plugin}-cipher_suites>> |<<array,array>>|No
|
95
|
+
| <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
|
73
96
|
| <<plugins-{type}s-{plugin}-host>> |<<string,string>>|No
|
74
97
|
| <<plugins-{type}s-{plugin}-keystore>> |<<path,path>>|No
|
75
98
|
| <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|No
|
@@ -115,6 +138,72 @@ and no codec for the request's content-type is found
|
|
115
138
|
|
116
139
|
The list of ciphers suite to use, listed by priorities.
|
117
140
|
|
141
|
+
[id="plugins-{type}s-{plugin}-ecs_compatibility"]
|
142
|
+
===== `ecs_compatibility`
|
143
|
+
|
144
|
+
* Value type is <<string,string>>
|
145
|
+
* Supported values are:
|
146
|
+
** `disabled`: unstructured connection metadata added at root level
|
147
|
+
** `v1`: headers added under `[@metadata][http][header]`. Some are copied to structured ECS fields `http`, `url`, `user_agent` and `host`
|
148
|
+
|
149
|
+
Controls this plugin's compatibility with the
|
150
|
+
{ecs-ref}[Elastic Common Schema (ECS)].
|
151
|
+
See <<plugins-{type}s-{plugin}-ecs_metadata>> for detailed information.
|
152
|
+
|
153
|
+
Example output:
|
154
|
+
|
155
|
+
**Sample output: ECS disabled**
|
156
|
+
[source,text]
|
157
|
+
-----
|
158
|
+
{
|
159
|
+
"@version" => "1",
|
160
|
+
"headers" => {
|
161
|
+
"request_path" => "/twitter/tweet/1",
|
162
|
+
"http_accept" => "*/*",
|
163
|
+
"http_version" => "HTTP/1.1",
|
164
|
+
"request_method" => "PUT",
|
165
|
+
"http_host" => "localhost:8080",
|
166
|
+
"http_user_agent" => "curl/7.64.1",
|
167
|
+
"content_length" => "5",
|
168
|
+
"content_type" => "application/x-www-form-urlencoded"
|
169
|
+
},
|
170
|
+
"@timestamp" => 2021-05-28T19:27:28.609Z,
|
171
|
+
"host" => "127.0.0.1",
|
172
|
+
"message" => "hello"
|
173
|
+
}
|
174
|
+
-----
|
175
|
+
|
176
|
+
**Sample output: ECS enabled**
|
177
|
+
[source,text]
|
178
|
+
-----
|
179
|
+
{
|
180
|
+
"@version" => "1",
|
181
|
+
"user_agent" => {
|
182
|
+
"original" => "curl/7.64.1"
|
183
|
+
},
|
184
|
+
"http" => {
|
185
|
+
"method" => "PUT",
|
186
|
+
"request" => {
|
187
|
+
"mime_type" => "application/x-www-form-urlencoded",
|
188
|
+
"body" => {
|
189
|
+
"bytes" => "5"
|
190
|
+
}
|
191
|
+
},
|
192
|
+
"version" => "HTTP/1.1"
|
193
|
+
},
|
194
|
+
"url" => {
|
195
|
+
"port" => "8080",
|
196
|
+
"domain" => "snmp1",
|
197
|
+
"path" => "/twitter/tweet/1"
|
198
|
+
},
|
199
|
+
"@timestamp" => 2021-05-28T23:32:38.222Z,
|
200
|
+
"host" => {
|
201
|
+
"ip" => "127.0.0.1"
|
202
|
+
},
|
203
|
+
"message" => "hello",
|
204
|
+
}
|
205
|
+
-----
|
206
|
+
|
118
207
|
[id="plugins-{type}s-{plugin}-host"]
|
119
208
|
===== `host`
|
120
209
|
|
@@ -209,7 +298,8 @@ specify a custom set of response headers
|
|
209
298
|
===== `remote_host_target_field`
|
210
299
|
|
211
300
|
* Value type is <<string,string>>
|
212
|
-
* Default value is `"host"`
|
301
|
+
* Default value is `"host"` when ECS is disabled
|
302
|
+
* Default value is `[host][ip]` when ECS is enabled
|
213
303
|
|
214
304
|
specify a target field for the client host of the http request
|
215
305
|
|
@@ -217,7 +307,8 @@ specify a target field for the client host of the http request
|
|
217
307
|
===== `request_headers_target_field`
|
218
308
|
|
219
309
|
* Value type is <<string,string>>
|
220
|
-
* Default value is `"headers"`
|
310
|
+
* Default value is `"headers"` when ECS is disabled
|
311
|
+
* Default value is `[@metadata][http][header]` when ECS is enabled
|
221
312
|
|
222
313
|
specify target field for the client host of the http request
|
223
314
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.
|
2
2
|
|
3
3
|
require 'jar_dependencies'
|
4
|
-
require_jar('io.netty', 'netty-all', '4.1.
|
5
|
-
require_jar('io.netty', 'netty-tcnative-boringssl-static', '2.0.12.Final')
|
4
|
+
require_jar('io.netty', 'netty-all', '4.1.49.Final')
|
6
5
|
require_jar('org.apache.logging.log4j', 'log4j-api', '2.11.1')
|
7
|
-
require_jar('org.logstash.plugins.input.http', 'logstash-input-http', '3.
|
6
|
+
require_jar('org.logstash.plugins.input.http', 'logstash-input-http', '3.4.0')
|
data/lib/logstash/inputs/http.rb
CHANGED
@@ -3,12 +3,11 @@ require "logstash/inputs/base"
|
|
3
3
|
require "logstash/namespace"
|
4
4
|
require "stud/interval"
|
5
5
|
require "logstash-input-http_jars"
|
6
|
-
|
7
|
-
java_import "io.netty.handler.codec.http.HttpUtil"
|
6
|
+
require "logstash/plugin_mixins/ecs_compatibility_support"
|
8
7
|
|
9
8
|
# Using this input you can receive single or multiline events over http(s).
|
10
9
|
# Applications can send a HTTP POST request with a body to the endpoint started by this
|
11
|
-
# input and Logstash will convert it into an event for subsequent processing. Users
|
10
|
+
# input and Logstash will convert it into an event for subsequent processing. Users
|
12
11
|
# can pass plain text, JSON, or any formatted data and use a corresponding codec with this
|
13
12
|
# input. For Content-Type `application/json` the `json` codec is used, but for all other
|
14
13
|
# data formats, `plain` codec is used.
|
@@ -16,7 +15,7 @@ java_import "io.netty.handler.codec.http.HttpUtil"
|
|
16
15
|
# This input can also be used to receive webhook requests to integrate with other services
|
17
16
|
# and applications. By taking advantage of the vast plugin ecosystem available in Logstash
|
18
17
|
# you can trigger actionable events right from your application.
|
19
|
-
#
|
18
|
+
#
|
20
19
|
# ==== Security
|
21
20
|
# This plugin supports standard HTTP basic authentication headers to identify the requester.
|
22
21
|
# You can pass in an username, password combination while sending data to this input
|
@@ -27,8 +26,11 @@ java_import "io.netty.handler.codec.http.HttpUtil"
|
|
27
26
|
# format]
|
28
27
|
#
|
29
28
|
class LogStash::Inputs::Http < LogStash::Inputs::Base
|
29
|
+
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1, :v8 => :v1)
|
30
30
|
require "logstash/inputs/http/tls"
|
31
31
|
|
32
|
+
java_import "io.netty.handler.codec.http.HttpUtil"
|
33
|
+
|
32
34
|
config_name "http"
|
33
35
|
|
34
36
|
# Codec used to decode the incoming data.
|
@@ -93,7 +95,7 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
93
95
|
config :tls_max_version, :validate => :number, :default => TLS.max.version
|
94
96
|
|
95
97
|
# The list of ciphers suite to use, listed by priorities.
|
96
|
-
config :cipher_suites, :validate => :array, :default => org.logstash.plugins.inputs.http.util.SslSimpleBuilder
|
98
|
+
config :cipher_suites, :validate => :array, :default => org.logstash.plugins.inputs.http.util.SslSimpleBuilder.getDefaultCiphers
|
97
99
|
|
98
100
|
# Apply specific codecs for specific content types.
|
99
101
|
# The default codec will be applied only after this list is checked
|
@@ -104,10 +106,10 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
104
106
|
config :response_headers, :validate => :hash, :default => { 'Content-Type' => 'text/plain' }
|
105
107
|
|
106
108
|
# target field for the client host of the http request
|
107
|
-
config :remote_host_target_field, :validate => :string
|
109
|
+
config :remote_host_target_field, :validate => :string
|
108
110
|
|
109
111
|
# target field for the client host of the http request
|
110
|
-
config :request_headers_target_field, :validate => :string
|
112
|
+
config :request_headers_target_field, :validate => :string
|
111
113
|
|
112
114
|
config :threads, :validate => :number, :required => false, :default => ::LogStash::Config::CpuCoreStrategy.maximum
|
113
115
|
|
@@ -130,7 +132,7 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
130
132
|
|
131
133
|
validate_ssl_settings!
|
132
134
|
|
133
|
-
if @user && @password
|
135
|
+
if @user && @password
|
134
136
|
token = Base64.strict_encode64("#{@user}:#{@password.value}")
|
135
137
|
@auth_token = "Basic #{token}"
|
136
138
|
end
|
@@ -144,6 +146,9 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
144
146
|
require "logstash/inputs/http/message_handler"
|
145
147
|
message_handler = MessageHandler.new(self, @codec, @codecs, @auth_token)
|
146
148
|
@http_server = create_http_server(message_handler)
|
149
|
+
|
150
|
+
@remote_host_target_field ||= ecs_select[disabled: "host", v1: "[host][ip]"]
|
151
|
+
@request_headers_target_field ||= ecs_select[disabled: "headers", v1: "[@metadata][input][http][request][headers]"]
|
147
152
|
end # def register
|
148
153
|
|
149
154
|
def run(queue)
|
@@ -177,12 +182,50 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
177
182
|
end
|
178
183
|
|
179
184
|
def push_decoded_event(headers, remote_address, event)
|
185
|
+
add_ecs_fields(headers, event)
|
180
186
|
event.set(@request_headers_target_field, headers)
|
181
187
|
event.set(@remote_host_target_field, remote_address)
|
182
188
|
decorate(event)
|
183
189
|
@queue << event
|
184
190
|
end
|
185
191
|
|
192
|
+
def add_ecs_fields(headers, event)
|
193
|
+
return if ecs_compatibility == :disabled
|
194
|
+
|
195
|
+
http_version = headers.get("http_version")
|
196
|
+
event.set("[http][version]", http_version) if http_version
|
197
|
+
|
198
|
+
http_user_agent = headers.get("http_user_agent")
|
199
|
+
event.set("[user_agent][original]", http_user_agent) if http_user_agent
|
200
|
+
|
201
|
+
http_host = headers.get("http_host")
|
202
|
+
domain, port = self.class.get_domain_port(http_host)
|
203
|
+
event.set("[url][domain]", domain) if domain
|
204
|
+
event.set("[url][port]", port) if port
|
205
|
+
|
206
|
+
request_method = headers.get("request_method")
|
207
|
+
event.set("[http][method]", request_method) if request_method
|
208
|
+
|
209
|
+
request_path = headers.get("request_path")
|
210
|
+
event.set("[url][path]", request_path) if request_path
|
211
|
+
|
212
|
+
content_length = headers.get("content_length")
|
213
|
+
event.set("[http][request][body][bytes]", content_length) if content_length
|
214
|
+
|
215
|
+
content_type = headers.get("content_type")
|
216
|
+
event.set("[http][request][mime_type]", content_type) if content_type
|
217
|
+
end
|
218
|
+
|
219
|
+
# match the domain and port in either IPV4, "127.0.0.1:8080", or IPV6, "[2001:db8::8a2e:370:7334]:8080", style
|
220
|
+
# return [domain, port]
|
221
|
+
def self.get_domain_port(http_host)
|
222
|
+
if /^(([^:]+)|\[(.*)\])\:([\d]+)$/ =~ http_host
|
223
|
+
["#{$2 || $3}", $4.to_i]
|
224
|
+
else
|
225
|
+
[http_host, nil]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
186
229
|
def validate_ssl_settings!
|
187
230
|
if !@ssl
|
188
231
|
@logger.warn("SSL Certificate will not be used") if @ssl_certificate
|
@@ -217,16 +260,16 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
217
260
|
def build_ssl_params
|
218
261
|
return nil unless @ssl
|
219
262
|
|
220
|
-
ssl_builder = nil
|
221
|
-
|
222
263
|
if @keystore && @keystore_password
|
223
264
|
ssl_builder = org.logstash.plugins.inputs.http.util.JksSslBuilder.new(@keystore, @keystore_password.value)
|
224
265
|
else
|
225
266
|
begin
|
226
|
-
ssl_builder = org.logstash.plugins.inputs.http.util.SslSimpleBuilder
|
227
|
-
|
267
|
+
ssl_builder = org.logstash.plugins.inputs.http.util.SslSimpleBuilder
|
268
|
+
.new(@ssl_certificate, @ssl_key, @ssl_key_passphrase.nil? ? nil : @ssl_key_passphrase.value)
|
269
|
+
.setCipherSuites(normalized_ciphers)
|
228
270
|
rescue java.lang.IllegalArgumentException => e
|
229
|
-
|
271
|
+
@logger.error("SSL configuration invalid", error_details(e))
|
272
|
+
raise LogStash::ConfigurationError, e
|
230
273
|
end
|
231
274
|
|
232
275
|
if client_authentication?
|
@@ -234,13 +277,7 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
234
277
|
end
|
235
278
|
end
|
236
279
|
|
237
|
-
|
238
|
-
ssl_handler_provider = org.logstash.plugins.inputs.http.util.SslHandlerProvider.new(ssl_context)
|
239
|
-
ssl_handler_provider.setVerifyMode(@ssl_verify_mode_final.upcase)
|
240
|
-
ssl_handler_provider.setProtocols(convert_protocols)
|
241
|
-
ssl_handler_provider.setHandshakeTimeoutMilliseconds(@ssl_handshake_timeout)
|
242
|
-
|
243
|
-
ssl_handler_provider
|
280
|
+
new_ssl_handshake_provider(ssl_builder)
|
244
281
|
end
|
245
282
|
|
246
283
|
def ssl_key_configured?
|
@@ -259,6 +296,8 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
259
296
|
@ssl_verify_mode_final == "force_peer" || @ssl_verify_mode_final == "peer"
|
260
297
|
end
|
261
298
|
|
299
|
+
private
|
300
|
+
|
262
301
|
def normalized_ciphers
|
263
302
|
@cipher_suites.map(&:upcase)
|
264
303
|
end
|
@@ -267,4 +306,31 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
267
306
|
TLS.get_supported(@tls_min_version..@tls_max_version).map(&:name)
|
268
307
|
end
|
269
308
|
|
309
|
+
def new_ssl_handshake_provider(ssl_builder)
|
310
|
+
begin
|
311
|
+
ssl_handler_provider = org.logstash.plugins.inputs.http.util.SslHandlerProvider.new(ssl_builder.build())
|
312
|
+
ssl_handler_provider.setVerifyMode(@ssl_verify_mode_final.upcase)
|
313
|
+
ssl_handler_provider.setProtocols(convert_protocols)
|
314
|
+
ssl_handler_provider.setHandshakeTimeoutMilliseconds(@ssl_handshake_timeout)
|
315
|
+
ssl_handler_provider
|
316
|
+
rescue java.lang.IllegalArgumentException => e
|
317
|
+
@logger.error("SSL configuration invalid", error_details(e))
|
318
|
+
raise LogStash::ConfigurationError, e
|
319
|
+
rescue java.lang.Exception => e
|
320
|
+
@logger.error("SSL configuration failed", error_details(e, true))
|
321
|
+
raise e
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
def error_details(e, trace = false)
|
326
|
+
error_details = { :exception => e.class, :message => e.message }
|
327
|
+
error_details[:backtrace] = e.backtrace if trace || @logger.debug?
|
328
|
+
cause = e.cause
|
329
|
+
if cause && e != cause
|
330
|
+
error_details[:cause] = { :exception => cause.class, :message => cause.message }
|
331
|
+
error_details[:cause][:backtrace] = cause.backtrace if trace || @logger.debug?
|
332
|
+
end
|
333
|
+
error_details
|
334
|
+
end
|
335
|
+
|
270
336
|
end # class LogStash::Inputs::Http
|
@@ -1,12 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash-input-http_jars"
|
3
|
-
java_import org.logstash.plugins.inputs.http.MessageHandler
|
4
|
-
java_import "io.netty.handler.codec.http.DefaultFullHttpResponse"
|
5
|
-
java_import "io.netty.handler.codec.http.HttpHeaderNames"
|
6
|
-
java_import "io.netty.handler.codec.http.HttpVersion"
|
7
|
-
java_import "io.netty.handler.codec.http.HttpResponseStatus"
|
8
|
-
java_import "io.netty.buffer.Unpooled"
|
9
|
-
java_import "io.netty.util.CharsetUtil"
|
10
3
|
|
11
4
|
module LogStash module Inputs class Http
|
12
5
|
class MessageHandler
|
@@ -29,6 +22,10 @@ module LogStash module Inputs class Http
|
|
29
22
|
end
|
30
23
|
end
|
31
24
|
|
25
|
+
def requires_token
|
26
|
+
!!@auth_token
|
27
|
+
end
|
28
|
+
|
32
29
|
def onNewMessage(remote_address, headers, body)
|
33
30
|
@input.decode_body(headers, remote_address, body, @default_codec, @additional_codecs)
|
34
31
|
end
|
data/logstash-input-http.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
24
24
|
s.add_runtime_dependency 'logstash-codec-plain'
|
25
25
|
s.add_runtime_dependency 'jar-dependencies', '~> 0.3', '>= 0.3.4'
|
26
|
+
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.2'
|
26
27
|
|
27
28
|
s.add_development_dependency 'logstash-devutils'
|
28
29
|
s.add_development_dependency 'logstash-codec-json'
|
data/spec/inputs/http_spec.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require "logstash/devutils/rspec/spec_helper"
|
2
|
+
require "logstash/devutils/rspec/shared_examples"
|
2
3
|
require "logstash/inputs/http"
|
3
4
|
require "json"
|
4
5
|
require "manticore"
|
5
6
|
require "stud/temporary"
|
6
7
|
require "zlib"
|
7
8
|
require "stringio"
|
9
|
+
require 'logstash/plugin_mixins/ecs_compatibility_support/spec_helper'
|
8
10
|
|
9
11
|
java_import "io.netty.handler.ssl.util.SelfSignedCertificate"
|
10
12
|
|
@@ -33,20 +35,7 @@ describe LogStash::Inputs::Http do
|
|
33
35
|
subject { LogStash::Inputs::Http.new("port" => port) }
|
34
36
|
|
35
37
|
before :each do
|
36
|
-
|
37
|
-
t = Thread.new { subject.run(logstash_queue) }
|
38
|
-
ok = false
|
39
|
-
until ok
|
40
|
-
begin
|
41
|
-
client.post("http://127.0.0.1:#{port}", :body => '{}').call
|
42
|
-
rescue => e
|
43
|
-
# retry
|
44
|
-
else
|
45
|
-
ok = true
|
46
|
-
end
|
47
|
-
sleep 0.01
|
48
|
-
end
|
49
|
-
logstash_queue.pop if logstash_queue.size == 1 # pop test event
|
38
|
+
setup_server_client
|
50
39
|
end
|
51
40
|
|
52
41
|
describe "handling overflowing requests with a 429" do
|
@@ -84,65 +73,6 @@ describe LogStash::Inputs::Http do
|
|
84
73
|
end
|
85
74
|
end
|
86
75
|
|
87
|
-
describe "remote host" do
|
88
|
-
subject { LogStash::Inputs::Http.new(config.merge("port" => port)) }
|
89
|
-
context "by default" do
|
90
|
-
let(:config) { {} }
|
91
|
-
it "is written to the \"host\" field" do
|
92
|
-
client.post("http://localhost:#{port}/meh.json",
|
93
|
-
:headers => { "content-type" => "text/plain" },
|
94
|
-
:body => "hello").call
|
95
|
-
event = logstash_queue.pop
|
96
|
-
expect(event.get("host")).to eq("127.0.0.1")
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "when using remote_host_target_field" do
|
101
|
-
let(:config) { { "remote_host_target_field" => "remote_host" } }
|
102
|
-
it "is written to the value of \"remote_host_target_field\" property" do
|
103
|
-
client.post("http://localhost:#{port}/meh.json",
|
104
|
-
:headers => { "content-type" => "text/plain" },
|
105
|
-
:body => "hello").call
|
106
|
-
event = logstash_queue.pop
|
107
|
-
expect(event.get("remote_host")).to eq("127.0.0.1")
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "request headers" do
|
113
|
-
subject { LogStash::Inputs::Http.new(config.merge("port" => port)) }
|
114
|
-
context "by default" do
|
115
|
-
let(:config) { {} }
|
116
|
-
it "are written to the \"headers\" field" do
|
117
|
-
client.post("http://localhost:#{port}/meh.json",
|
118
|
-
:headers => { "content-type" => "text/plain" },
|
119
|
-
:body => "hello").call
|
120
|
-
event = logstash_queue.pop
|
121
|
-
expect(event.get("headers")).to be_a(Hash)
|
122
|
-
expect(event.get("headers")).to include("request_method" => "POST")
|
123
|
-
end
|
124
|
-
end
|
125
|
-
context "when using request_headers_target_field" do
|
126
|
-
let(:config) { { "request_headers_target_field" => "request_headers" } }
|
127
|
-
it "are written to the field set in \"request_headers_target_field\"" do
|
128
|
-
client.post("http://localhost:#{port}/meh.json",
|
129
|
-
:headers => { "content-type" => "text/plain" },
|
130
|
-
:body => "hello").call
|
131
|
-
event = logstash_queue.pop
|
132
|
-
expect(event.get("request_headers")).to be_a(Hash)
|
133
|
-
expect(event.get("request_headers")).to include("request_method" => "POST")
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should include remote host in \"host\" property" do
|
139
|
-
client.post("http://127.0.0.1:#{port}/meh.json",
|
140
|
-
:headers => { "content-type" => "text/plain" },
|
141
|
-
:body => "hello").call
|
142
|
-
event = logstash_queue.pop
|
143
|
-
expect(event.get("host")).to eq("127.0.0.1")
|
144
|
-
end
|
145
|
-
|
146
76
|
context "with default codec" do
|
147
77
|
subject { LogStash::Inputs::Http.new("port" => port) }
|
148
78
|
context "when receiving a text/plain request" do
|
@@ -278,6 +208,11 @@ describe LogStash::Inputs::Http do
|
|
278
208
|
it "should respond with 401" do
|
279
209
|
expect(response.code).to eq(401)
|
280
210
|
end
|
211
|
+
it 'should include a WWW-Authenticate: Basic header' do
|
212
|
+
expect(response['WWW-Authenticate']).to_not be_nil
|
213
|
+
|
214
|
+
expect(response['WWW-Authenticate']).to start_with('Basic realm=')
|
215
|
+
end
|
281
216
|
it "should not generate an event" do
|
282
217
|
expect(logstash_queue).to be_empty
|
283
218
|
end
|
@@ -294,6 +229,9 @@ describe LogStash::Inputs::Http do
|
|
294
229
|
it "should respond with 401" do
|
295
230
|
expect(response.code).to eq(401)
|
296
231
|
end
|
232
|
+
it 'should not include a WWW-Authenticate header' do
|
233
|
+
expect(response['WWW-Authenticate']).to be_nil
|
234
|
+
end
|
297
235
|
it "should not generate an event" do
|
298
236
|
expect(logstash_queue).to be_empty
|
299
237
|
end
|
@@ -359,6 +297,143 @@ describe LogStash::Inputs::Http do
|
|
359
297
|
end
|
360
298
|
end
|
361
299
|
|
300
|
+
describe "ECS support", :ecs_compatibility_support, :aggregate_failures do
|
301
|
+
ecs_compatibility_matrix(:disabled, :v1) do |ecs_select|
|
302
|
+
let(:host_field) { ecs_select[disabled: "[host]", v1: "[host][ip]"] }
|
303
|
+
let(:header_field) { ecs_select[disabled: "headers", v1: "[@metadata][input][http][request][headers]"] }
|
304
|
+
let(:http_version_field) { ecs_select[disabled: "[headers][http_version]", v1: "[http][version]"] }
|
305
|
+
let(:user_agent_field) { ecs_select[disabled: "[headers][http_user_agent]", v1: "[user_agent][original]"] }
|
306
|
+
let(:http_host_field) { "[headers][http_host]" }
|
307
|
+
let(:domain_field) { "[url][domain]" }
|
308
|
+
let(:port_field) { "[url][port]" }
|
309
|
+
let(:request_method_field) { ecs_select[disabled: "[headers][request_method]", v1: "[http][method]"] }
|
310
|
+
let(:request_path_field) { ecs_select[disabled: "[headers][request_path]", v1: "[url][path]"] }
|
311
|
+
let(:content_length_field) { ecs_select[disabled: "[headers][content_length]", v1: "[http][request][body][bytes]"] }
|
312
|
+
let(:content_type_field) { ecs_select[disabled: "[headers][content_type]", v1: "[http][request][mime_type]"] }
|
313
|
+
|
314
|
+
before :each do
|
315
|
+
allow_any_instance_of(described_class).to receive(:ecs_compatibility).and_return(ecs_compatibility)
|
316
|
+
setup_server_client
|
317
|
+
end
|
318
|
+
|
319
|
+
describe "remote host" do
|
320
|
+
subject { LogStash::Inputs::Http.new(config.merge("port" => port)) }
|
321
|
+
context "by default" do
|
322
|
+
let(:config) { {} }
|
323
|
+
it "is written to the \"host\" field" do
|
324
|
+
client.post("http://localhost:#{port}/meh.json",
|
325
|
+
:headers => { "content-type" => "text/plain" },
|
326
|
+
:body => "hello").call
|
327
|
+
event = logstash_queue.pop
|
328
|
+
expect(event.get(host_field)).to eq("127.0.0.1")
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
context "when using remote_host_target_field" do
|
333
|
+
let(:config) { { "remote_host_target_field" => "remote_host" } }
|
334
|
+
it "is written to the value of \"remote_host_target_field\" property" do
|
335
|
+
client.post("http://localhost:#{port}/meh.json",
|
336
|
+
:headers => { "content-type" => "text/plain" },
|
337
|
+
:body => "hello").call
|
338
|
+
event = logstash_queue.pop
|
339
|
+
expect(event.get("remote_host")).to eq("127.0.0.1")
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
describe "request headers" do
|
345
|
+
subject { LogStash::Inputs::Http.new(config.merge("port" => port)) }
|
346
|
+
context "by default" do
|
347
|
+
let(:config) { {} }
|
348
|
+
it "are written to the \"headers\" field" do
|
349
|
+
client.post("http://localhost:#{port}/meh.json",
|
350
|
+
:headers => { "content-type" => "text/plain" },
|
351
|
+
:body => "hello").call
|
352
|
+
event = logstash_queue.pop
|
353
|
+
expect(event.get(header_field)).to be_a(Hash)
|
354
|
+
expect(event.get(request_method_field)).to eq("POST")
|
355
|
+
expect(event.get(request_path_field)).to eq("/meh.json")
|
356
|
+
expect(event.get(http_version_field)).to eq("HTTP/1.1")
|
357
|
+
expect(event.get(user_agent_field)).to include("Manticore")
|
358
|
+
if ecs_compatibility == :disabled
|
359
|
+
expect(event.get(http_host_field)).to eq("localhost:#{port}")
|
360
|
+
else
|
361
|
+
expect(event.get(domain_field)).to eq("localhost")
|
362
|
+
expect(event.get(port_field)).to eq(port)
|
363
|
+
end
|
364
|
+
|
365
|
+
expect(event.get(content_length_field)).to eq("5")
|
366
|
+
expect(event.get(content_type_field)).to eq("text/plain")
|
367
|
+
end
|
368
|
+
end
|
369
|
+
context "when using request_headers_target_field" do
|
370
|
+
let(:config) { { "request_headers_target_field" => "request_headers" } }
|
371
|
+
it "are written to the field set in \"request_headers_target_field\"" do
|
372
|
+
client.post("http://localhost:#{port}/meh.json",
|
373
|
+
:headers => { "content-type" => "text/plain" },
|
374
|
+
:body => "hello").call
|
375
|
+
event = logstash_queue.pop
|
376
|
+
expect(event.get("request_headers")).to be_a(Hash)
|
377
|
+
expect(event.get("request_headers")).to include("request_method" => "POST")
|
378
|
+
expect(event.get("request_headers")).to include("request_path" => "/meh.json")
|
379
|
+
expect(event.get("request_headers")).to include("http_version" => "HTTP/1.1")
|
380
|
+
expect(event.get("request_headers")["http_user_agent"]).to include("Manticore")
|
381
|
+
expect(event.get("request_headers")).to include("http_host" => "localhost:#{port}")
|
382
|
+
expect(event.get("request_headers")).to include("content_length" => "5")
|
383
|
+
expect(event.get("request_headers")).to include("content_type" => "text/plain")
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
# wait until server is ready
|
391
|
+
def setup_server_client
|
392
|
+
subject.register
|
393
|
+
t = Thread.new { subject.run(logstash_queue) }
|
394
|
+
ok = false
|
395
|
+
until ok
|
396
|
+
begin
|
397
|
+
client.post("http://127.0.0.1:#{port}", :body => '{}').call
|
398
|
+
rescue => e
|
399
|
+
# retry
|
400
|
+
else
|
401
|
+
ok = true
|
402
|
+
end
|
403
|
+
sleep 0.01
|
404
|
+
end
|
405
|
+
logstash_queue.pop if logstash_queue.size == 1 # pop test event
|
406
|
+
end
|
407
|
+
|
408
|
+
describe "parse domain host" do
|
409
|
+
let(:localhost) { "localhost" }
|
410
|
+
let(:ipv6) { "2001:db8::8a2e:370:7334" }
|
411
|
+
|
412
|
+
it "should parse in IPV4 format with port" do
|
413
|
+
domain, port = LogStash::Inputs::Http.get_domain_port("#{localhost}:8080")
|
414
|
+
expect(domain).to eq(localhost)
|
415
|
+
expect(port).to eq(8080)
|
416
|
+
end
|
417
|
+
|
418
|
+
it "should parse in IPV4 format without port" do
|
419
|
+
domain, port = LogStash::Inputs::Http.get_domain_port(localhost)
|
420
|
+
expect(domain).to eq(localhost)
|
421
|
+
expect(port).to be_nil
|
422
|
+
end
|
423
|
+
|
424
|
+
it "should parse in IPV6 format with port" do
|
425
|
+
domain, port = LogStash::Inputs::Http.get_domain_port("[#{ipv6}]:8080")
|
426
|
+
expect(domain).to eq(ipv6)
|
427
|
+
expect(port).to eq(8080)
|
428
|
+
end
|
429
|
+
|
430
|
+
it "should parse in IPV6 format without port" do
|
431
|
+
domain, port = LogStash::Inputs::Http.get_domain_port("#{ipv6}")
|
432
|
+
expect(domain).to eq(ipv6)
|
433
|
+
expect(port).to be_nil
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
362
437
|
context "with :ssl => false" do
|
363
438
|
subject { LogStash::Inputs::Http.new("port" => port, "ssl" => false) }
|
364
439
|
it "should not raise exception" do
|
@@ -377,21 +452,21 @@ describe LogStash::Inputs::Http do
|
|
377
452
|
let(:ssl_certificate) { ssc.certificate }
|
378
453
|
let(:ssl_key) { ssc.private_key }
|
379
454
|
|
455
|
+
let(:config) do
|
456
|
+
{ "port" => port, "ssl" => true, "ssl_certificate" => ssl_certificate.path, "ssl_key" => ssl_key.path }
|
457
|
+
end
|
458
|
+
|
380
459
|
after(:each) { ssc.delete }
|
381
460
|
|
382
|
-
subject { LogStash::Inputs::Http.new(
|
383
|
-
|
384
|
-
"ssl_key" => ssl_key.path) }
|
461
|
+
subject { LogStash::Inputs::Http.new(config) }
|
462
|
+
|
385
463
|
it "should not raise exception" do
|
386
464
|
expect { subject.register }.to_not raise_exception
|
387
465
|
end
|
388
466
|
|
389
467
|
context "with ssl_verify_mode = none" do
|
390
|
-
subject { LogStash::Inputs::Http.new("
|
391
|
-
|
392
|
-
"ssl_key" => ssl_key.path,
|
393
|
-
"ssl_verify_mode" => "none"
|
394
|
-
) }
|
468
|
+
subject { LogStash::Inputs::Http.new(config.merge("ssl_verify_mode" => "none")) }
|
469
|
+
|
395
470
|
it "should not raise exception" do
|
396
471
|
expect { subject.register }.to_not raise_exception
|
397
472
|
end
|
@@ -410,11 +485,8 @@ describe LogStash::Inputs::Http do
|
|
410
485
|
end
|
411
486
|
end
|
412
487
|
context "with verify_mode = none" do
|
413
|
-
subject { LogStash::Inputs::Http.new("
|
414
|
-
|
415
|
-
"ssl_key" => ssl_key.path,
|
416
|
-
"verify_mode" => "none"
|
417
|
-
) }
|
488
|
+
subject { LogStash::Inputs::Http.new(config.merge("verify_mode" => "none")) }
|
489
|
+
|
418
490
|
it "should not raise exception" do
|
419
491
|
expect { subject.register }.to_not raise_exception
|
420
492
|
end
|
@@ -432,6 +504,67 @@ describe LogStash::Inputs::Http do
|
|
432
504
|
end
|
433
505
|
end
|
434
506
|
end
|
507
|
+
|
508
|
+
context "with invalid cipher_suites" do
|
509
|
+
let(:config) { super().merge("cipher_suites" => "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA38") }
|
510
|
+
|
511
|
+
it "should raise a configuration error" do
|
512
|
+
expect( subject.logger ).to receive(:error) do |msg, opts|
|
513
|
+
expect( msg ).to match /.*?configuration invalid/
|
514
|
+
expect( opts[:message] ).to match /TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA38.*? not available/
|
515
|
+
end
|
516
|
+
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
context "with invalid ssl certificate" do
|
521
|
+
before do
|
522
|
+
cert = File.readlines path = config["ssl_certificate"]
|
523
|
+
i = cert.index { |line| line.index('END CERTIFICATE') }
|
524
|
+
cert[i - 1] = ''
|
525
|
+
File.write path, cert.join("\n")
|
526
|
+
end
|
527
|
+
|
528
|
+
it "should raise a configuration error" do
|
529
|
+
expect( subject.logger ).to receive(:error) do |msg, opts|
|
530
|
+
expect( msg ).to match /SSL configuration invalid/
|
531
|
+
expect( opts[:message] ).to match /File does not contain valid certificate/i
|
532
|
+
end
|
533
|
+
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
context "with invalid ssl key config" do
|
538
|
+
let(:config) { super().merge("ssl_key_passphrase" => "1234567890") }
|
539
|
+
|
540
|
+
it "should raise a configuration error" do
|
541
|
+
expect( subject.logger ).to receive(:error) do |msg, opts|
|
542
|
+
expect( msg ).to match /SSL configuration invalid/
|
543
|
+
expect( opts[:message] ).to match /File does not contain valid private key/i
|
544
|
+
end
|
545
|
+
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
546
|
+
end
|
547
|
+
end
|
548
|
+
|
549
|
+
context "with invalid ssl certificate_authorities" do
|
550
|
+
let(:config) do
|
551
|
+
super().merge("ssl_verify_mode" => "peer",
|
552
|
+
"ssl_certificate_authorities" => [ ssc.certificate.path, ssc.private_key.path ])
|
553
|
+
end
|
554
|
+
|
555
|
+
it "should raise a cert error" do
|
556
|
+
expect( subject.logger ).to receive(:error) do |msg, opts|
|
557
|
+
expect( msg ).to match(/SSL configuration failed/), lambda { "unexpected: logger.error #{msg.inspect}, #{opts.inspect}" }
|
558
|
+
expect( opts[:message] ).to match /signed fields invalid/
|
559
|
+
end
|
560
|
+
begin
|
561
|
+
subject.register
|
562
|
+
rescue Java::JavaSecurityCert::CertificateParsingException
|
563
|
+
:pass
|
564
|
+
end
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
435
568
|
end
|
436
569
|
end
|
437
570
|
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +64,20 @@ dependencies:
|
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 0.3.4
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
requirement: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '1.2'
|
73
|
+
name: logstash-mixin-ecs_compatibility_support
|
74
|
+
prerelease: false
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.2'
|
67
81
|
- !ruby/object:Gem::Dependency
|
68
82
|
requirement: !ruby/object:Gem::Requirement
|
69
83
|
requirements:
|
@@ -144,10 +158,9 @@ files:
|
|
144
158
|
- lib/tasks/build.rake
|
145
159
|
- logstash-input-http.gemspec
|
146
160
|
- spec/inputs/http_spec.rb
|
147
|
-
- vendor/jar-dependencies/io/netty/netty-all/4.1.
|
148
|
-
- vendor/jar-dependencies/io/netty/netty-tcnative-boringssl-static/2.0.12.Final/netty-tcnative-boringssl-static-2.0.12.Final.jar
|
161
|
+
- vendor/jar-dependencies/io/netty/netty-all/4.1.49.Final/netty-all-4.1.49.Final.jar
|
149
162
|
- vendor/jar-dependencies/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1.jar
|
150
|
-
- vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/3.
|
163
|
+
- vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/3.4.0/logstash-input-http-3.4.0.jar
|
151
164
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
152
165
|
licenses:
|
153
166
|
- Apache License (2.0)
|
Binary file
|
Binary file
|