rails-profiler 0.44.14 → 0.44.15
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/profiler/models/profile.rb +5 -4
- data/lib/profiler/replay.rb +35 -11
- data/lib/profiler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5494040c10e8c5e51c20aacf54788fdab573a5814f394ced5c7c7f7caa4693aa
|
|
4
|
+
data.tar.gz: b84ed786eaed7a1f59ed8ee9b953a546be714432dbecd7ad372fee2b4446d567
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a40f0b6d4d6c79de401838152198aae9528b795061f96c991e7a4bc1c65d8881af8f489d71f8e02078ee110a0de49b3d6715b82f818e00643fbbb67c9e84975
|
|
7
|
+
data.tar.gz: 8b49e505d5a86c01debb8fed088e3e428ff1e28b1492009f8a86c655c70d258b0f323d394fee3a3d2fac49ab2369ba4a14e1a106f7e2a651ebdf22cb14c37222
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,16 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.15] - 2026-10-23
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Replay:** Include `Content-Type` header from captured request when replaying. Previously, only `HTTP_*` Rack env vars were captured, missing `CONTENT_TYPE` which is stored separately. Replayed JSON POST requests were incorrectly treated as form data. Refs #64
|
|
29
|
+
- **Replay:** Reject stored request bodies containing redaction masks (`[FILTERED]` or `[FILTERED: ...]` markers) and note them in the result instead of sending them as real data, including when the captured params would otherwise have been re-encoded into a replacement body. Refs #64
|
|
30
|
+
- **Replay:** Validate that the `headers` override parameter is a Hash or nil; previously passing a string or other type caused `NoMethodError` resulting in a 500 error. Now raises `Replay::Invalid` with a clear message. Refs #64
|
|
31
|
+
|
|
22
32
|
## [0.44.14] - 2026-10-23
|
|
23
33
|
|
|
24
34
|
<!-- stamped -->
|
|
@@ -428,10 +428,11 @@ module Profiler
|
|
|
428
428
|
end
|
|
429
429
|
|
|
430
430
|
def extract_headers(env)
|
|
431
|
-
env.select { |k, _| k.start_with?("HTTP_") }
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
431
|
+
headers = env.select { |k, _| k.start_with?("HTTP_") }
|
|
432
|
+
.transform_keys { |k| k.sub(/^HTTP_/, "").split("_").map(&:capitalize).join("-") }
|
|
433
|
+
headers["Content-Type"] = env["CONTENT_TYPE"] if env["CONTENT_TYPE"]
|
|
434
|
+
headers.select { |k, _| ALLOWED_HEADERS.include?(k) }
|
|
435
|
+
.then { |h| Redaction.filter_headers(h) }
|
|
435
436
|
end
|
|
436
437
|
end
|
|
437
438
|
end
|
data/lib/profiler/replay.rb
CHANGED
|
@@ -242,8 +242,11 @@ module Profiler
|
|
|
242
242
|
end
|
|
243
243
|
notes << "Not sent, masked in the profile: #{redacted.join(", ")}." unless redacted.empty?
|
|
244
244
|
|
|
245
|
+
override_headers = options[:headers]
|
|
246
|
+
raise Invalid, "headers must be a Hash or nil" unless override_headers.nil? || override_headers.is_a?(Hash)
|
|
247
|
+
|
|
245
248
|
ignored = []
|
|
246
|
-
(
|
|
249
|
+
(override_headers || {}).each do |name, value|
|
|
247
250
|
if FORBIDDEN_HEADERS.include?(name.to_s.downcase) || name.to_s.match?(/[\r\n:\s]/) || value.to_s.match?(/[\r\n]/)
|
|
248
251
|
ignored << name.to_s
|
|
249
252
|
next
|
|
@@ -268,22 +271,32 @@ module Profiler
|
|
|
268
271
|
end
|
|
269
272
|
|
|
270
273
|
def body_and_query(source, options, method, path_query, headers, notes)
|
|
274
|
+
raise Invalid, "params must be a Hash or nil" if options.key?(:params) && !options[:params].nil? && !options[:params].is_a?(Hash)
|
|
275
|
+
raise Invalid, "body must be a String or nil" if options.key?(:body) && !options[:body].nil? && !options[:body].is_a?(String)
|
|
276
|
+
|
|
271
277
|
params = options.key?(:params) ? options[:params] : default_params(source, notes)
|
|
272
278
|
query = options.key?(:query) ? encode_query(options[:query]) : path_query
|
|
273
279
|
body = nil
|
|
274
280
|
|
|
281
|
+
masked_body_dropped = false
|
|
275
282
|
if options.key?(:body)
|
|
276
283
|
body = options[:body].to_s
|
|
277
|
-
elsif !options.key?(:params) && !BODYLESS_METHODS.include?(method)
|
|
278
|
-
body =
|
|
284
|
+
elsif !options.key?(:params) && !BODYLESS_METHODS.include?(method)
|
|
285
|
+
body, masked_body_dropped = stored_body(source, notes)
|
|
279
286
|
end
|
|
280
287
|
|
|
281
|
-
|
|
288
|
+
# A body dropped for masking must not be silently replaced by one rebuilt from params:
|
|
289
|
+
# the note says it "was not sent", not "was sent after all, reconstructed differently".
|
|
290
|
+
if !masked_body_dropped && params.is_a?(Hash) && !params.empty? && !options.key?(:query) && path_query.nil? && body.nil?
|
|
282
291
|
if BODYLESS_METHODS.include?(method)
|
|
283
292
|
query = encode_query(params)
|
|
284
293
|
else
|
|
285
294
|
body, content_type = encode_params_body(params, headers)
|
|
286
|
-
headers
|
|
295
|
+
user_content_type = (options[:headers] || {}).any? { |name, _| name.to_s.casecmp?("Content-Type") }
|
|
296
|
+
unless user_content_type
|
|
297
|
+
headers.delete_if { |existing, _| existing.casecmp?("Content-Type") }
|
|
298
|
+
headers["Content-Type"] = content_type
|
|
299
|
+
end
|
|
287
300
|
end
|
|
288
301
|
end
|
|
289
302
|
|
|
@@ -300,19 +313,30 @@ module Profiler
|
|
|
300
313
|
params.reject { |_, value| value == Redaction::MASK }
|
|
301
314
|
end
|
|
302
315
|
|
|
316
|
+
# Returns [body, masked]: masked is true only when a body existed and was dropped because
|
|
317
|
+
# it contains a redaction marker, so the caller can tell that case apart from "no body was
|
|
318
|
+
# ever captured", for which the default_params fallback remains appropriate.
|
|
303
319
|
def stored_body(source, notes)
|
|
304
|
-
return nil if source.request_body.nil? || source.request_body.empty?
|
|
320
|
+
return [nil, false] if source.request_body.nil? || source.request_body.empty?
|
|
305
321
|
|
|
306
322
|
if source.request_body_truncated
|
|
307
323
|
notes << "The stored request body is truncated (max_captured_body_bytes): the replay sends what was kept."
|
|
308
324
|
end
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
325
|
+
|
|
326
|
+
decoded = if source.request_body_encoding == "base64"
|
|
327
|
+
Base64.strict_decode64(source.request_body)
|
|
328
|
+
else
|
|
329
|
+
Models::Profile.decode_body(source.request_body, source.request_body_encoding).first
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
if decoded.include?(Redaction::MASK) || decoded.include?("[FILTERED:")
|
|
333
|
+
notes << "The stored request body contains masked values and was not sent."
|
|
334
|
+
return [nil, true]
|
|
313
335
|
end
|
|
336
|
+
|
|
337
|
+
[decoded, false]
|
|
314
338
|
rescue ArgumentError
|
|
315
|
-
nil
|
|
339
|
+
[nil, false]
|
|
316
340
|
end
|
|
317
341
|
|
|
318
342
|
def encode_query(value)
|
data/lib/profiler/version.rb
CHANGED