logtail-rack 0.2.1 → 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 +0 -1
- data/lib/logtail-rack/http_events.rb +21 -19
- data/lib/logtail-rack/version.rb +1 -1
- data/logtail-ruby-rack.gemspec +1 -1
- metadata +3 -3
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
@@ -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"
|
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: 2023-08-
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logtail
|
@@ -129,7 +129,7 @@ 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
|
- - ">="
|