fluent-plugin-out-http 1.3.4 → 1.3.5

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: fc6b6a32252a6bd023ff50a7785ad1c761f0e0de88fd791cf80a03b4e03313c3
4
- data.tar.gz: 35f04c05e359cc78d9a2305a8b157439c930254d23ad032c5a57496506d21a84
3
+ metadata.gz: d3d0fe7b452afa815821161d819bdf70c394e10068d43ad9d7962f9e59506585
4
+ data.tar.gz: e6e6b6b72bda444045c274cdf1b4edc5d61da372f330b2697b09d16134072a92
5
5
  SHA512:
6
- metadata.gz: 14be9f2277907f3cf48a5388568b80a4a91f5daa6a0af8e0b24fd19510fdf0c0bad5c51dcc6338a2a61058907bffa9c5c95bf333a15d6a7ef5bc99a955c7e051
7
- data.tar.gz: 27ae799e130b2469947cee7f603477fba5fdd80cffa5041929cb7bfaa4948ce656d90cd349ccdf8884c8616758f79b2263e158b00dc8831a926462e8ce5757b2
6
+ metadata.gz: 7e3e2600427b82ec559a99411423cd161e7fd99146cb2beffb1467fc0f997297f59d3cb352b29cae717b5fc012b1122edc80f9a29087d26e0c9400a56ce9a37e
7
+ data.tar.gz: 2dd79aa067059bcd8626bc0d65230283f850996ea861fd792c53e8ea92c47cdf12a11c4823bc81309fecf28241390354a7dff8ce46d348c1fcfbb48a43c5b8da
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'monthly'
@@ -8,14 +8,14 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [ '2.7', '3.0', '3.1' ]
11
+ ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
12
12
  os:
13
13
  - ubuntu-latest
14
14
  - macOS-latest
15
15
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
16
16
  steps:
17
- - uses: actions/checkout@v3
18
- - uses: ruby/setup-ruby@v1
17
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18
+ - uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
19
19
  with:
20
20
  ruby-version: ${{ matrix.ruby }}
21
21
  bundler-cache: true
@@ -27,14 +27,14 @@ jobs:
27
27
  name: Gem test
28
28
  runs-on: ubuntu-latest
29
29
  steps:
30
- - uses: actions/checkout@v3
31
- - uses: ruby/setup-ruby@v1
30
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31
+ - uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
32
32
  with:
33
33
  ruby-version: 3.1
34
34
  - name: Install
35
35
  run: |
36
36
  rake install
37
- gem install test-unit webrick
37
+ gem install test-unit test-unit-rr webrick
38
38
  - name: Test
39
39
  run: |
40
40
  mkdir -p tmp
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # Changelog
2
+ ## 1.3.5
3
+ * Mask authentication bearer token in logs
4
+ * Avoid unnecessary gzip decompression and recompression
5
+
2
6
  ## 1.3.4
3
7
  * Add debug log about chunk writing
4
8
  * Tweak CI
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-out-http"
5
- gem.version = "1.3.4"
5
+ gem.version = "1.3.5"
6
6
  gem.authors = ["Marica Odagaki"]
7
7
  gem.email = ["ento.entotto@gmail.com"]
8
8
  gem.summary = %q{A generic Fluentd output plugin to send logs to an HTTP endpoint}
@@ -22,5 +22,6 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency "bundler"
23
23
  gem.add_development_dependency "rake"
24
24
  gem.add_development_dependency "test-unit", ">= 3.1.0"
25
+ gem.add_development_dependency "test-unit-rr", "~> 1.0"
25
26
  gem.add_development_dependency "webrick"
26
27
  end
@@ -61,7 +61,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
61
61
  config_param :authentication, :enum, list: [:none, :basic, :jwt, :bearer], :default => :none
62
62
  config_param :username, :string, :default => ''
63
63
  config_param :password, :string, :default => '', :secret => true
64
- config_param :token, :string, :default => ''
64
+ config_param :token, :string, :default => '', :secret => true
65
65
  # Switch non-buffered/buffered plugin
66
66
  config_param :buffered, :bool, :default => false
67
67
  config_param :bulk_request, :bool, :default => false
@@ -146,12 +146,21 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
146
146
  end
147
147
  end
148
148
 
149
+ def buffer_compressed?
150
+ @buffered && @buffer.compress == :gzip
151
+ end
152
+
149
153
  def compress_body(req, data)
150
154
  return unless @compress_request
151
- gz = Zlib::GzipWriter.new(StringIO.new)
152
- gz << data
153
155
 
154
156
  req['Content-Encoding'] = "gzip"
157
+ if buffer_compressed?
158
+ req.body = data
159
+ return
160
+ end
161
+
162
+ gz = Zlib::GzipWriter.new(StringIO.new)
163
+ gz << data
155
164
  req.body = gz.close.string
156
165
  end
157
166
 
@@ -261,7 +270,8 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
261
270
  end
262
271
 
263
272
  def handle_records(tag, time, chunk)
264
- req, uri = create_request(tag, time, chunk.read)
273
+ record = buffer_compressed? ? chunk.read(compressed: @buffer.compress) : chunk.read
274
+ req, uri = create_request(tag, time, record)
265
275
  send_request(req, uri)
266
276
  end
267
277
 
@@ -8,6 +8,8 @@ require 'fluent/test/driver/output'
8
8
  require 'fluent/test/helpers'
9
9
  require_relative "./script/plugin/formatter_test"
10
10
 
11
+ require 'test/unit/rr'
12
+
11
13
  module OS
12
14
  # ref. http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on
13
15
  def OS.windows?
@@ -100,9 +102,18 @@ class HTTPOutputTestBase < Test::Unit::TestCase
100
102
 
101
103
  expander = -> (req) {
102
104
  if req["Content-Encoding"] == "gzip"
103
- StringIO.open(req.body, 'rb'){|sio|
104
- Zlib::GzipReader.wrap(sio).read
105
- }
105
+ sio = StringIO.new(req.body)
106
+ output = ""
107
+
108
+ until sio.eof?
109
+ gz = Zlib::GzipReader.new(sio)
110
+ output << gz.read
111
+ unused = gz.unused
112
+ if unused
113
+ sio.pos -= unused.length
114
+ end
115
+ end
116
+ output
106
117
  else
107
118
  req.body
108
119
  end
@@ -523,6 +534,50 @@ class HTTPOutputTest < HTTPOutputTestBase
523
534
  assert_equal expected, record[:x_ndjson]
524
535
  assert_nil record[:auth]
525
536
  end
537
+
538
+ def test_emit_x_ndjson_with_compression_with_compressed_buffer
539
+ binary_string = "\xe3\x81\x82"
540
+ d = create_driver CONFIG_JSON + %[
541
+ buffered true
542
+ bulk_request true
543
+ compress_request true
544
+ <buffer>
545
+ @type memory
546
+ compress gzip
547
+ </buffer>
548
+ ]
549
+
550
+ # Should not recompress
551
+ dont_allow(Zlib::GzipWriter).new
552
+
553
+ d.run(default_tag: 'test.metrics') do
554
+ d.feed({ 'field1' => 50, 'field2' => 20, 'field3' => 10, 'otherfield' => 1, 'binary' => binary_string })
555
+ d.feed({ 'field1' => 70, 'field2' => 30, 'field3' => 20, 'otherfield' => 2, 'binary' => binary_string })
556
+ end
557
+
558
+ assert_equal 1, @posts.size
559
+ record = @posts[0]
560
+
561
+ expected =[
562
+ {
563
+ "binary" => "\u3042",
564
+ "field1" => 50,
565
+ "field2" => 20,
566
+ "field3" => 10,
567
+ "otherfield" => 1
568
+ },
569
+ {
570
+ "binary" => "\u3042",
571
+ "field1" => 70,
572
+ "field2" => 30,
573
+ "field3" => 20,
574
+ "otherfield" => 2
575
+ }
576
+ ]
577
+
578
+ assert_equal expected, record[:x_ndjson]
579
+ assert_nil record[:auth]
580
+ end
526
581
  end
527
582
 
528
583
  def test_emit_form_put
@@ -859,6 +914,8 @@ class HTTPSOutputTest < HTTPOutputTestBase
859
914
  ssl_no_verify true
860
915
  cacert_file /tmp/ssl.cert
861
916
  ]
917
+ cert, _ = WEBrick::Utils.create_self_signed_cert(2048, [["CN", "localhost"]], "Generated Test Cert")
918
+ File.write('/tmp/ssl.cert', cert.to_pem)
862
919
  d = create_driver config
863
920
  d.run(default_tag: 'test.metrics') do
864
921
  d.feed({ 'field1' => 50 })
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-out-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marica Odagaki
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-10-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: yajl-ruby
@@ -86,6 +85,20 @@ dependencies:
86
85
  - - ">="
87
86
  - !ruby/object:Gem::Version
88
87
  version: 3.1.0
88
+ - !ruby/object:Gem::Dependency
89
+ name: test-unit-rr
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.0'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '1.0'
89
102
  - !ruby/object:Gem::Dependency
90
103
  name: webrick
91
104
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +120,7 @@ executables: []
107
120
  extensions: []
108
121
  extra_rdoc_files: []
109
122
  files:
123
+ - ".github/dependabot.yml"
110
124
  - ".github/workflows/test.yml"
111
125
  - ".gitignore"
112
126
  - CHANGELOG.md
@@ -125,7 +139,6 @@ homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-out-http
125
139
  licenses:
126
140
  - Apache-2.0
127
141
  metadata: {}
128
- post_install_message:
129
142
  rdoc_options: []
130
143
  require_paths:
131
144
  - lib
@@ -140,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
153
  - !ruby/object:Gem::Version
141
154
  version: '0'
142
155
  requirements: []
143
- rubygems_version: 3.1.6
144
- signing_key:
156
+ rubygems_version: 4.0.6
145
157
  specification_version: 4
146
158
  summary: A generic Fluentd output plugin to send logs to an HTTP endpoint
147
159
  test_files: