logstash-input-http 4.1.12-java → 4.2.0-java

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: db97525ba9c34e146ee41512fc5488a5178c4cc5bf10d7e6c68b4371c44f9683
4
- data.tar.gz: 841c57eee945b10cf1cb86a7c63aceda9fbfb2a0f0fc2771e961dcb16d59d142
3
+ metadata.gz: 539abcb4c339a32fffb7f9cacbd89d9d89699c2ba2fb095662c5b38f13a2d0e2
4
+ data.tar.gz: 88d0055774cdd24adac50a40ae6882847833774c4be98909ae1949291f221b26
5
5
  SHA512:
6
- metadata.gz: '0599f2a38364301caab70ab1656d0e12e007e674097cc352cd64ef7737319ba55c32355b12cb019f698d68bb21fe11f9b2e3cc7a97294a6e000d68260f320acb'
7
- data.tar.gz: 7966940eb34d949f61b591d1f136ca42003465aa30efafb9e60b7cf8563df9d707dbbe887822dad15bd2317f8bafdacfa329dbbbbd76da2fae14b0133dded867
6
+ metadata.gz: 04af87e8700a675a2c461dab2b876e61c16733ce1a670fe09a283ca8f4d5930e90bc874f68bb7d2f8610675498a15f51804a719fc7912db6bd9af77d98c9dafa
7
+ data.tar.gz: 02cb65c66466c985b7efa061f8bd50993cc4267a63f351b6702e24a9b72ef6cc8585aa7cf01e8da09247dd3db5b0ce07d7a4b0d247b56ff76bfb16c888db7f98
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 4.2.0
2
+ - Implements a functionality to log HTTP traffic, disabled by default. To unable switch on debug logs. [#237](https://github.com/logstash-plugins/logstash-input-http/pull/237)
3
+
4
+ ## 4.1.13
5
+ - Fix to use the `Content-type` declared charset to decode the request body [#230](https://github.com/logstash-plugins/logstash-input-http/pull/230)
6
+
1
7
  ## 4.1.12
2
8
  - Update Netty dependency to 4.1.136.Final [#228](https://github.com/logstash-plugins/logstash-input-http/pull/228)
3
9
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-input-http.svg)](https://travis-ci.com/logstash-plugins/logstash-input-http)
3
+ [![Unit Tests](https://github.com/logstash-plugins/logstash-input-http/actions/workflows/unit-tests.yml/badge.svg?branch=main)](https://github.com/logstash-plugins/logstash-input-http/actions/workflows/unit-tests.yml)
4
4
 
5
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.1.12
1
+ 4.2.0
data/docs/index.asciidoc CHANGED
@@ -27,6 +27,14 @@ Logstash will convert it into an event for subsequent processing. Users
27
27
  can pass plain text, JSON, or any formatted data and use a corresponding codec with this
28
28
  input. For Content-Type `application/json` the `json` codec is used, but for all other
29
29
  data formats, `plain` codec is used.
30
+ If the `Content-type` header also defines a charset like in:
31
+
32
+ [source,text]
33
+ -----
34
+ curl -X POST -H 'Content-Type: application/json; charset=ISO-8859-1'
35
+ -----
36
+
37
+ then that charset is used to decode the request body. Else UTF-8 is applied.
30
38
 
31
39
  This input can also be used to receive webhook requests to integrate with other services
32
40
  and applications. By taking advantage of the vast plugin ecosystem available in Logstash
@@ -82,6 +90,33 @@ Values in `additional_codecs` are prioritized over those specified in the
82
90
  `codec` option. That is, the default `codec` is applied only if no codec
83
91
  for the request's content-type is found in the `additional_codecs` setting.
84
92
 
93
+ [id="plugins-{type}s-{plugin}-wire-logging"]
94
+ ==== Enable wire logging
95
+ This plugin could log all requests and responses passing through the socket after TLS decoding.
96
+ This functionality helps troubleshoot issues in the processing pipeline that standard
97
+ external traffic captures, such as `tcpdump`, cannot resolve.
98
+ By default it's disabled, to dump received and sent payloads post-TLS decoding, enable debug logging
99
+ for `org.logstash.plugins.inputs.http.util.WireLogger`.
100
+ Note: Payloads exceeding 4 KB are automatically truncated to prevent excessive log file growth.
101
+ If you want to set a different limit, then in {ls} `config/jvm.options` configure a value for the system property `logstash.httpinput.wire.dump.size`.
102
+
103
+ [source,text]
104
+ -----
105
+ -Dlogstash.httpinput.wire.dump.size=512
106
+ -----
107
+ If you want to remove any limit, at the risk of polluting {ls} logs, set it to `0`.
108
+ Admitted values are only integers greater or equals to 0.
109
+
110
+ To enable it start {ls} in debug mode or configure the `config/log4j2.properties` to include:
111
+
112
+ [source,text]
113
+ -----
114
+ logger.httpwire.name = org.logstash.plugins.inputs.http.util.WireLogger
115
+ logger.httpwire.level = DEBUG
116
+ -----
117
+
118
+ WARNING: when this log is enabled the payload is dumped, so if contains secretes those are exposed in {ls} logs.
119
+
85
120
  [id="plugins-{type}s-{plugin}-options"]
86
121
  ==== Http Input Configuration Options
87
122
 
@@ -176,6 +176,8 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
176
176
 
177
177
  validate_ssl_settings!
178
178
 
179
+ validate_dump_size_system_property!
180
+
179
181
  if @user && @password
180
182
  token = Base64.strict_encode64("#{@user}:#{@password.value}")
181
183
  @auth_token = "Basic #{token}"
@@ -276,6 +278,12 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
276
278
  [http_host, nil]
277
279
  end
278
280
  end
281
+
282
+ def validate_dump_size_system_property!
283
+ java_import org.logstash.plugins.inputs.http.util.WireLogger
284
+ WireLogger.validate_dump_size_property
285
+ end
286
+ private :validate_dump_size_system_property!
279
287
 
280
288
  def validate_ssl_settings!
281
289
  ssl_config_name = original_params.include?('ssl') ? 'ssl' : 'ssl_enabled'
@@ -9,4 +9,4 @@ require_jar('io.netty', 'netty-transport', '4.1.136.Final')
9
9
  require_jar('io.netty', 'netty-buffer', '4.1.136.Final')
10
10
  require_jar('io.netty', 'netty-resolver', '4.1.136.Final')
11
11
  require_jar('io.netty', 'netty-common', '4.1.136.Final')
12
- require_jar('org.logstash.plugins.input.http', 'logstash-input-http', '4.1.12')
12
+ require_jar('org.logstash.plugins.input.http', 'logstash-input-http', '4.2.0')
@@ -11,6 +11,17 @@ require 'inputs/helpers'
11
11
 
12
12
  java_import "io.netty.handler.ssl.util.SelfSignedCertificate"
13
13
 
14
+ shared_examples "decodes message with charset" do |charset|
15
+ let(:headers) { { "content-type" => "application/json; charset=#{charset}" } }
16
+ let(:body) { '{"msg":"A Coruña"}'.encode(charset) }
17
+
18
+ it "should decode the message accordingly" do
19
+ client.post("http://127.0.0.1:#{port}/meh.json", :headers => headers, :body => body).call
20
+ event = logstash_queue.pop
21
+ expect(event.get("msg")).to eq("A Coruña")
22
+ end
23
+ end
24
+
14
25
  describe LogStash::Inputs::Http do
15
26
 
16
27
  before do
@@ -58,50 +69,42 @@ describe LogStash::Inputs::Http do
58
69
  end
59
70
 
60
71
  describe "handling overflowing requests with a 429" do
61
- let(:logstash_queue_size) { rand(10) + 1 }
62
- let(:max_pending_requests) { rand(5) + 1 }
63
- let(:threads) { rand(4) + 1 }
72
+ let(:logstash_queue_size) { 1 }
73
+ let(:max_pending_requests) { 1 }
74
+ let(:threads) { 1 }
64
75
  let(:logstash_queue) { SizedQueue.new(logstash_queue_size) }
65
76
  let(:client_options) { {
66
- "request_timeout" => 0.1,
67
- "connect_timeout" => 3,
68
- "socket_timeout" => 0.1
77
+ request_timeout: 5,
78
+ connect_timeout: 3,
79
+ socket_timeout: 0.5
69
80
  } }
70
81
 
71
82
  let(:config) { { "port" => port, "threads" => threads, "max_pending_requests" => max_pending_requests } }
72
83
 
73
84
  context "when sending more requests than queue slots" do
74
85
  it "rejects additional incoming requests with HTTP 429" do
75
- # these will queue and return 200
76
- logstash_queue_size.times.each do |i|
86
+ # fill the pipeline queue so the next push blocks the server worker
87
+ logstash_queue_size.times do
77
88
  response = client.post("http://127.0.0.1:#{port}", :body => '{}').call
78
89
  expect(response.code).to eq(200)
79
90
  end
80
91
 
81
- # these will block
82
- blocked_calls = (threads + max_pending_requests).times.map do
83
- Thread.new do
84
- begin
85
- {:result => client.post("http://127.0.0.1:#{port}", :body => '{}').call}
86
- rescue Manticore::SocketException, Manticore::SocketTimeout => e
87
- {:exception => e}
88
- end
92
+ # a blocked request holds its slot even after the client times out, so sending
93
+ # sequentially fills every worker and backlog slot before the next 429
94
+ blocked = 0
95
+ response = nil
96
+ deadline = Time.now + 30
97
+ until response && response.code == 429
98
+ raise "server never returned 429 (blocked=#{blocked})" if Time.now > deadline
99
+ begin
100
+ response = client.post("http://127.0.0.1:#{port}", :body => '{}').call
101
+ rescue Manticore::SocketTimeout
102
+ blocked += 1
89
103
  end
90
104
  end
91
105
 
92
- sleep 1 # let those requests go, but not so long that our block-detector starts emitting 429's
93
-
94
- # by now we should be rejecting with 429 since the backlog is full
95
- response = client.post("http://127.0.0.1:#{port}", :body => '{}').call
96
106
  expect(response.code).to eq(429)
97
-
98
- # ensure that our blocked connections did block
99
- aggregate_failures do
100
- blocked_calls.map(&:value).each do |blocked|
101
- expect(blocked[:result]).to be_nil
102
- expect(blocked[:exception]).to be_a_kind_of Manticore::SocketTimeout
103
- end
104
- end
107
+ expect(blocked).to eq(threads + max_pending_requests)
105
108
  end
106
109
  end
107
110
  end
@@ -112,9 +115,9 @@ describe LogStash::Inputs::Http do
112
115
  let(:threads) { rand(4) + 1 }
113
116
  let(:logstash_queue) { SizedQueue.new(logstash_queue_size) }
114
117
  let(:client_options) { {
115
- "request_timeout" => 0.1,
116
- "connect_timeout" => 3,
117
- "socket_timeout" => 0.1
118
+ request_timeout: 5,
119
+ connect_timeout: 3,
120
+ socket_timeout: 1
118
121
  } }
119
122
 
120
123
  let(:config) { { "port" => port, "threads" => threads, "max_pending_requests" => max_pending_requests } }
@@ -223,6 +226,16 @@ describe LogStash::Inputs::Http do
223
226
  expect(event.get("message_body")).to eq("Hello")
224
227
  end
225
228
  end
229
+
230
+ context "when receiving a request with content-type specifying charset" do
231
+ context "ISO-8859-1" do
232
+ it_behaves_like "decodes message with charset", "ISO-8859-1"
233
+ end
234
+
235
+ context "UTF-8" do
236
+ it_behaves_like "decodes message with charset", "utf-8"
237
+ end
238
+ end
226
239
  end
227
240
 
228
241
  context "with json codec" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.12
4
+ version: 4.2.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-08-20 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: logstash-core-plugin-api
@@ -176,7 +176,7 @@ files:
176
176
  - vendor/jar-dependencies/io/netty/netty-resolver/4.1.136.Final/netty-resolver-4.1.136.Final.jar
177
177
  - vendor/jar-dependencies/io/netty/netty-transport-native-unix-common/4.1.136.Final/netty-transport-native-unix-common-4.1.136.Final.jar
178
178
  - vendor/jar-dependencies/io/netty/netty-transport/4.1.136.Final/netty-transport-4.1.136.Final.jar
179
- - vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/4.1.12/logstash-input-http-4.1.12.jar
179
+ - vendor/jar-dependencies/org/logstash/plugins/input/http/logstash-input-http/4.2.0/logstash-input-http-4.2.0.jar
180
180
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
181
181
  licenses:
182
182
  - Apache License (2.0)
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
- rubygems_version: 3.7.2
201
+ rubygems_version: 3.6.3
202
202
  specification_version: 4
203
203
  summary: Receives events over HTTP or HTTPS
204
204
  test_files: