logtail-rack 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +50 -9
- data/README.md +1 -0
- data/lib/logtail-rack/http_events.rb +21 -19
- data/lib/logtail-rack/version.rb +1 -1
- data/logtail-ruby-rack.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a63714ec66ecfdd4a4db3ffc637fe1b02da37422789fc7ea8617474b63f90367
|
4
|
+
data.tar.gz: 8fedbde00ed676731409c299e7e5183bc24daa049f21e9e5ffd7995706bc2dda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc10f2ad042d60da36ea8491f214764028e045bde28db87fb68fb7de32278fe98ddf84105deda98a07cfdfb7e9ee9ffaf46056093fa670dd35043fb2d48d69a
|
7
|
+
data.tar.gz: 437553fcaf79354dcb76bef63bca8c58cb1dcd8c7972f3f0204bd7c2b2aad30e0943776b78de0b307a9148643cb2974a6d5b3fc2f7a7d31b80bfc3e4d0243177
|
data/.github/workflows/main.yml
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
name: build
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
schedule:
|
6
|
+
- cron: '20 5 * * 1'
|
7
|
+
workflow_dispatch:
|
4
8
|
|
5
9
|
jobs:
|
6
10
|
test:
|
@@ -8,17 +12,50 @@ jobs:
|
|
8
12
|
runs-on: ubuntu-20.04
|
9
13
|
|
10
14
|
strategy:
|
15
|
+
fail-fast: false
|
11
16
|
matrix:
|
12
17
|
ruby-version:
|
13
|
-
- 3.
|
14
|
-
-
|
15
|
-
-
|
16
|
-
- 2.
|
17
|
-
- 2.
|
18
|
-
- 2.
|
19
|
-
- 2.
|
18
|
+
- 3.2
|
19
|
+
- 3.1
|
20
|
+
- 3.0
|
21
|
+
- 2.7
|
22
|
+
- 2.6
|
23
|
+
- 2.5
|
24
|
+
- 2.4
|
25
|
+
- 2.3
|
26
|
+
- jruby-9.4.3.0
|
20
27
|
- jruby-9.2.14.0
|
21
|
-
- truffleruby-
|
28
|
+
- truffleruby-23.0.0
|
29
|
+
- truffleruby-22.1.0
|
30
|
+
rack-version:
|
31
|
+
- # default Rack version
|
32
|
+
|
33
|
+
include:
|
34
|
+
- ruby-version: 2.7
|
35
|
+
rack-version: ~>1.2.0
|
36
|
+
- ruby-version: 2.7
|
37
|
+
rack-version: ~>1.2
|
38
|
+
- ruby-version: 2.7
|
39
|
+
rack-version: ~>2.0.0
|
40
|
+
- ruby-version: 2.7
|
41
|
+
rack-version: ~>2.0
|
42
|
+
- ruby-version: 2.7
|
43
|
+
rack-version: ~>3.0
|
44
|
+
- ruby-version: 2.7
|
45
|
+
rack-version: ~>3.0.0
|
46
|
+
|
47
|
+
- ruby-version: 3.2
|
48
|
+
rack-version: ~>1.2.0
|
49
|
+
- ruby-version: 3.2
|
50
|
+
rack-version: ~>1.2
|
51
|
+
- ruby-version: 3.2
|
52
|
+
rack-version: ~>2.0.0
|
53
|
+
- ruby-version: 3.2
|
54
|
+
rack-version: ~>2.0
|
55
|
+
- ruby-version: 3.2
|
56
|
+
rack-version: ~>3.0
|
57
|
+
- ruby-version: 3.2
|
58
|
+
rack-version: ~>3.0.0
|
22
59
|
|
23
60
|
steps:
|
24
61
|
- uses: actions/checkout@v2
|
@@ -29,5 +66,9 @@ jobs:
|
|
29
66
|
ruby-version: ${{ matrix.ruby-version }}
|
30
67
|
bundler-cache: true
|
31
68
|
|
69
|
+
- name: Specify "rack" gem version ${{ matrix.rack-version }}
|
70
|
+
if: ${{ matrix.rack-version }}
|
71
|
+
run: bundle add rack --version="${{ matrix.rack-version }}"
|
72
|
+
|
32
73
|
- name: Run tests
|
33
74
|
run: bundle exec rspec --format documentation
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# 🪵 Logtail Integration For Rack
|
2
2
|
|
3
3
|
[![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/logtail-rack.svg)](https://badge.fury.io/rb/logtail-rack)
|
4
5
|
[![Build Status](https://github.com/logtail/logtail-ruby-rack/workflows/build/badge.svg)](https://github.com/logtail/logtail-ruby-rack/actions?query=workflow%3Abuild)
|
5
6
|
|
6
7
|
This library integrates the [`logtail` Ruby library](https://github.com/logtail/logtail-ruby) with the [rack](https://github.com/rack/rack) framework,
|
@@ -102,23 +102,24 @@ module Logtail
|
|
102
102
|
@silence_request
|
103
103
|
end
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
#
|
110
|
-
|
111
|
-
@http_body_limit
|
112
|
-
end
|
113
|
-
|
105
|
+
# Filter sensitive HTTP headers (such as "Authorization: Bearer secret_token")
|
106
|
+
#
|
107
|
+
# Filtered HTTP header values will be sent to Better Stack as "[FILTERED]"
|
108
|
+
#
|
109
|
+
# @example
|
110
|
+
# Logtail::Integrations::Rack::HTTPEvents.http_header_filters = ["Authorization"]
|
114
111
|
def http_header_filters=(value)
|
115
|
-
@http_header_filters = value
|
112
|
+
@http_header_filters = value.map { |header_name| normalize_header_name(header_name) }
|
116
113
|
end
|
117
114
|
|
118
115
|
# Accessor method for {#http_header_filters=}
|
119
116
|
def http_header_filters
|
120
117
|
@http_header_filters
|
121
118
|
end
|
119
|
+
|
120
|
+
def normalize_header_name(name)
|
121
|
+
name.to_s.downcase.gsub("-", "_")
|
122
|
+
end
|
122
123
|
end
|
123
124
|
|
124
125
|
CONTENT_LENGTH_KEY = 'Content-Length'.freeze
|
@@ -147,13 +148,11 @@ module Logtail
|
|
147
148
|
|
148
149
|
http_response = HTTPResponse.new(
|
149
150
|
content_length: content_length,
|
150
|
-
headers: headers,
|
151
|
+
headers: filter_http_headers(headers),
|
151
152
|
http_context: http_context,
|
152
153
|
request_id: request.request_id,
|
153
154
|
status: status,
|
154
155
|
duration_ms: duration_ms,
|
155
|
-
body_limit: self.class.http_body_limit,
|
156
|
-
headers_to_sanitize: self.class.http_header_filters,
|
157
156
|
)
|
158
157
|
|
159
158
|
{
|
@@ -179,7 +178,7 @@ module Logtail
|
|
179
178
|
http_request = HTTPRequest.new(
|
180
179
|
body: event_body,
|
181
180
|
content_length: safe_to_i(request.content_length),
|
182
|
-
headers: request.headers,
|
181
|
+
headers: filter_http_headers(request.headers),
|
183
182
|
host: force_encoding(request.host),
|
184
183
|
method: request.request_method,
|
185
184
|
path: request.path,
|
@@ -187,8 +186,6 @@ module Logtail
|
|
187
186
|
query_string: force_encoding(request.query_string),
|
188
187
|
request_id: request.request_id,
|
189
188
|
scheme: force_encoding(request.scheme),
|
190
|
-
body_limit: self.class.http_body_limit,
|
191
|
-
headers_to_sanitize: self.class.http_header_filters,
|
192
189
|
)
|
193
190
|
|
194
191
|
{
|
@@ -223,12 +220,10 @@ module Logtail
|
|
223
220
|
http_response = HTTPResponse.new(
|
224
221
|
body: event_body,
|
225
222
|
content_length: content_length,
|
226
|
-
headers: headers,
|
223
|
+
headers: filter_http_headers(headers),
|
227
224
|
request_id: request.request_id,
|
228
225
|
status: status,
|
229
226
|
duration_ms: duration_ms,
|
230
|
-
body_limit: self.class.http_body_limit,
|
231
|
-
headers_to_sanitize: self.class.http_header_filters,
|
232
227
|
)
|
233
228
|
|
234
229
|
{
|
@@ -272,6 +267,13 @@ module Logtail
|
|
272
267
|
end
|
273
268
|
end
|
274
269
|
|
270
|
+
def filter_http_headers(headers)
|
271
|
+
headers.each do |name, _|
|
272
|
+
normalized_header_name = self.class.normalize_header_name(name)
|
273
|
+
headers[name] = "[FILTERED]" if self.class.http_header_filters&.include?(normalized_header_name)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
275
277
|
def safe_to_i(val)
|
276
278
|
val.nil? ? nil : val.to_i
|
277
279
|
end
|
data/lib/logtail-rack/version.rb
CHANGED
data/logtail-ruby-rack.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.homepage = "https://github.com/logtail/logtail-ruby-rack"
|
13
13
|
spec.license = "ISC"
|
14
14
|
|
15
|
-
spec.required_ruby_version = '>= 2.
|
15
|
+
spec.required_ruby_version = '>= 2.3'
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/logtail/logtail-ruby-rack"
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
spec.add_dependency "logtail", "~> 0.1"
|
31
|
-
spec.add_runtime_dependency "rack", ">= 1.2", "<
|
31
|
+
spec.add_runtime_dependency "rack", ">= 1.2", "< 4.0"
|
32
32
|
|
33
33
|
spec.add_development_dependency "bundler", ">= 0.0"
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logtail-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logtail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logtail
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '1.2'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '4.0'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '1.2'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '4.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,14 +129,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 2.
|
132
|
+
version: '2.3'
|
133
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.3.
|
139
|
+
rubygems_version: 3.3.7
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Logtail integration for Rack
|