rails-profiler 0.34.2 → 0.34.3

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: b6365d7a34d882d20ca0257247629d6099917508ad78cecc96726dc6788c7a75
4
- data.tar.gz: e7dffe134ddcac64202aae83bb73963837068ae258b1cdc1d959e78504b31861
3
+ metadata.gz: 066e4af89b9741273fe1740d6dfbcecaa32df311835699642cafad8e703ca4ec
4
+ data.tar.gz: 05f65764c8e80a2b61ceea1f164dd85fa1d3d920b71452c3abdd35044698107b
5
5
  SHA512:
6
- metadata.gz: 8912bad06bc0824942c4e696d9fd408dff3a76238af92faaa7c262815e477e3850fe90c14d9acd6ceced45271180c990c8d6d597cf591d998eae48edf3dc9e11
7
- data.tar.gz: aeb7cec816ce9de90ab3dcc72629d36c6f9b1ff69bfa618416e72fa5cbb6301cae5a5d12dd09d6d0a4c247c76095c397777dad9f42a18bbf5aaafa7d375b7248
6
+ metadata.gz: 7eeb6e60ace7bbfccb32d3a5eeb0d42243a5bd39d551d08aeaefe05ae8cb79a76b91aee3e1e2a5e2edcaba11d1cd99a89d9860c788841915b16a62483bc457bb
7
+ data.tar.gz: ae5f198e1f98ca9f964b25a1fba4d419d4c2544e5c651d7921f984626be85d64f4afc494501602e4a19e306ff6cacc8d16f9e5c6f2895a45778af1f444c7e3e3
data/CHANGELOG.md CHANGED
@@ -19,6 +19,26 @@ every commit of every tag interval is accounted for one way or the other.
19
19
 
20
20
  ## [Unreleased]
21
21
 
22
+ ## [0.34.3] - 2026-10-15
23
+
24
+ <!-- stamped -->
25
+
26
+ ### Changed
27
+
28
+ - **Test suite:** `bundle exec rspec` now measures the line coverage of the gem's Ruby code with
29
+ SimpleCov, and the CI fails below 92.0%, the level measured on Ruby 3.3 once the MCP
30
+ tools, the function profiler, the storage base class and the cluster client got specs of their
31
+ own. A run of a few spec files is held to no floor outside the CI.
32
+ - **Test suite:** The suite loads and passes under any locale, `LANG=C` included: `spec_helper.rb`
33
+ reads files as UTF-8 whatever the locale, and a `.rspec` file loads it for every spec. The specs
34
+ of the masking of sensitive data now live together under `spec/redaction/`.
35
+
36
+ ### Fixed
37
+
38
+ - **Middleware:** The default `skip_paths` are now anchored to the whole path, so a page such as `/users/favicon.ico.html` is no longer skipped by mistake, and the Sprockets assets (`/assets`) and Action Cable (`/cable`) requests are no longer profiled. A `skip_paths` list you set yourself is used as given.
39
+ - **Mailers:** Visiting the mailer previews (`/rails/mailers`) no longer records phantom delivered emails in the profile.
40
+ - **Security:** An `authorize_with` block that raises is now treated as a denial: the error is logged server side and the request is served unprofiled, instead of breaking every request of the application.
41
+
22
42
  ## [0.34.2] - 2026-10-15
23
43
 
24
44
  <!-- stamped -->
@@ -316,8 +316,9 @@ module Profiler
316
316
  end
317
317
 
318
318
  def rails_preview_request?
319
- path = Thread.current[:profiler_request_path]
320
- path&.start_with?("/rails/mailers")
319
+ # The profile of the request being served carries its path; the thread-local is kept
320
+ # for a caller that sets it by hand.
321
+ [profile&.path, Thread.current[:profiler_request_path]].any? { |path| path.to_s.match?(%r{\A/rails/mailers(/|\z)}) }
321
322
  end
322
323
 
323
324
  def to_path(class_name)
@@ -65,7 +65,8 @@ module Profiler
65
65
  @storage = :memory
66
66
  @storage_options = {}
67
67
  @collectors = []
68
- @skip_paths = [%r{^/_profiler}, /\.well-known/, /favicon\.ico/, /manifest\.json/]
68
+ @skip_paths = [%r{\A/_profiler}, %r{\A/\.well-known/}, %r{\A/favicon\.ico\z}, %r{\A(?:/[^/]+)*/manifest\.json\z},
69
+ %r{\A/assets/}, %r{\A/cable(/|\z)}]
69
70
  @slow_query_threshold = 100 # milliseconds
70
71
  @max_queries_warning = 50
71
72
  # Where each query comes from: :first_and_slow captures the caller the first time a
@@ -284,7 +285,7 @@ module Profiler
284
285
  LocalRequest.warn_once(reason)
285
286
  false
286
287
  when :allow_authorized
287
- @authorize_block ? @authorize_block.call(request) : false
288
+ run_authorize_block(request)
288
289
  else
289
290
  false
290
291
  end
@@ -373,5 +374,16 @@ module Profiler
373
374
  raise ArgumentError, "config.mcp_allowed_hosts: #{pattern.inspect} cannot be matched against the whole " \
374
375
  "host name (#{e.message})"
375
376
  end
377
+
378
+ # An exception in the application's own authorization code is a denial, never an error
379
+ # for the request: it would otherwise break every request. The detail stays in the log.
380
+ def run_authorize_block(request)
381
+ return false unless @authorize_block
382
+
383
+ @authorize_block.call(request) ? true : false
384
+ rescue StandardError => e
385
+ Profiler.log_error("authorize_with block raised, treating the request as unauthorized", e)
386
+ false
387
+ end
376
388
  end
377
389
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Profiler
4
- VERSION = "0.34.2"
4
+ VERSION = "0.34.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.2
4
+ version: 0.34.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Duplessy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-15 00:00:00.000000000 Z
11
+ date: 2026-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails