rails-profiler 0.44.28 → 0.44.29

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: db4bcba43c1c1b5d0870757e25bc084c42ce53150ca7e61e2f9cf18404a82314
4
- data.tar.gz: d777658db9176d4e5b1d08cf3e2b5eba2c4c7a6477329d3873170377c1aa0463
3
+ metadata.gz: 8aaceadc8eb83f058028d9119aaa8d520fe326f3229102165cc9d47a4f8e50a9
4
+ data.tar.gz: 983d4aaad3182af60c19626a72f55cd84b8de8e109336438faec7079d3c385c1
5
5
  SHA512:
6
- metadata.gz: 1c27ced14b0f9b1dc252242dce5d3e525116c0030e19209ca6c9e01067fe9c970f740e7333cbfb27216bef74e33ba426bc98717e23f3253bcde775cad1abb232
7
- data.tar.gz: eea5be61d9ca47fcecf1454e1d6a7bf960c76671eaea78e9d62839407d8ab7e6b226983c4d02a85a85bffb5fc3698f6a00a09e77f93ccc589cc5621542dcbc2e
6
+ metadata.gz: c0b55328521b2285527700c7b7674e71abcfac7189cdb5538e0eda34336faac7f3c090b49acc9bdb2d82b96df8df6cc0d50920c536e12d49c979626e603854ec
7
+ data.tar.gz: 9679682523471ae75f48a570f114f770dcecdd79280fdfcefd84c97c9c4f0fb45e2eb2ee3a2516cff102a9d37caafc228de6c86b8cedecaf86a7c77d98da790b
data/CHANGELOG.md CHANGED
@@ -19,6 +19,17 @@ every commit of every tag interval is accounted for one way or the other.
19
19
 
20
20
  ## [Unreleased]
21
21
 
22
+ ## [0.44.29] - 2026-10-26
23
+
24
+ <!-- stamped -->
25
+
26
+ ### Fixed
27
+
28
+ - **Profiles:** Validate that `filter` parameter is a Hash before attempting to access its keys; previously passing a string or other type caused `NoMethodError` resulting in a 500 error. Now returns 422 with a clear error message. Refs #74
29
+ - **Profiles:** Clamp `limit` and `offset` to non-negative values using the existing `page_params` helper; a negative limit previously raised `ArgumentError` from `Array#first`, resulting in a 500 error. Refs #74
30
+ - **EnvVars:** Refuse an array or object `value` with 422 instead of storing its inspect string; nil, strings and JSON scalars (numbers, booleans) are still accepted and coerced with `to_s`. Refs #74
31
+ - **TestRunner:** Answer 422 when the `framework` parameter of `POST test_runner/runs` or `GET test_runner/files` is not a string, instead of a 500 from `NoMethodError`; `Runner.start` and `Discovery.files` raise `ArgumentError` for a framework that is neither a String nor a Symbol. Refs #74
32
+
22
33
  ## [0.44.28] - 2026-10-26
23
34
 
24
35
  <!-- stamped -->
@@ -32,6 +32,14 @@ module Profiler
32
32
 
33
33
  value = params[:value]
34
34
 
35
+ # A structured value (JSON array or object) has no ENV representation. Scalars (numbers,
36
+ # booleans) are still coerced with to_s, as before.
37
+ if value.is_a?(Array) || value.is_a?(Hash) || value.respond_to?(:to_unsafe_h)
38
+ render json: { error: "Value must be a scalar, not an array or an object; #{key} was left unchanged" },
39
+ status: :unprocessable_entity
40
+ return
41
+ end
42
+
35
43
  # A value ENV cannot hold is refused before the store is written, like a refused key.
36
44
  if (reason = Profiler::EnvKeyPolicy.value_rejection(key, value))
37
45
  render json: { error: "#{reason}; #{key} was left unchanged" }, status: :unprocessable_entity
@@ -16,6 +16,8 @@ module Profiler
16
16
 
17
17
  def files
18
18
  framework = params[:framework]
19
+ return render_invalid_framework unless framework.nil? || framework.is_a?(String)
20
+
19
21
  tree = Profiler::TestRunner::Discovery.files(framework: framework)
20
22
  frameworks = Profiler::TestRunner::Discovery.frameworks
21
23
 
@@ -28,6 +30,7 @@ module Profiler
28
30
  def create
29
31
  files = Array(params[:files])
30
32
  framework = params[:framework] || detect_framework
33
+ return render_invalid_framework unless framework.is_a?(String)
31
34
 
32
35
  if files.empty?
33
36
  return render json: { error: "No files selected" }, status: :unprocessable_entity
@@ -88,6 +91,10 @@ module Profiler
88
91
 
89
92
  private
90
93
 
94
+ def render_invalid_framework
95
+ render json: { error: "framework must be a String" }, status: :unprocessable_entity
96
+ end
97
+
91
98
  def detect_framework
92
99
  if Profiler::TestRunner::Discovery.rspec_available?
93
100
  "rspec"
@@ -5,8 +5,13 @@ require_relative "../../../lib/profiler/cluster/slave_proxy"
5
5
  module Profiler
6
6
  class ProfilesController < ApplicationController
7
7
  def index
8
- limit = params[:limit]&.to_i || 50
9
- offset = params[:offset]&.to_i || 0
8
+ limit, offset = page_params
9
+
10
+ # Validate filter parameter is a Hash if present
11
+ if params[:filter].present? && !params[:filter].respond_to?(:to_unsafe_h) && !params[:filter].is_a?(Hash)
12
+ render json: { error: "filter must be a hash" }, status: :unprocessable_entity
13
+ return
14
+ end
10
15
 
11
16
  @profiles = Profiler.storage.list(limit: limit, offset: offset)
12
17
  @profiles = filter_profiles(@profiles) if params[:filter].present?
@@ -15,6 +15,12 @@ module Profiler
15
15
 
16
16
  def self.files(framework: nil)
17
17
  root = defined?(Rails) ? Rails.root.to_s : Dir.pwd
18
+
19
+ # Validate framework is a String or Symbol if provided
20
+ if !framework.nil? && !framework.is_a?(String) && !framework.is_a?(Symbol)
21
+ raise ArgumentError, "framework must be a String or Symbol"
22
+ end
23
+
18
24
  result = {}
19
25
 
20
26
  globs = case framework&.to_sym
@@ -24,6 +24,12 @@ module Profiler
24
24
  # Raises TooManyRunsError when config.test_runner_max_active_runs runs still have their
25
25
  # test process.
26
26
  def self.start(files:, framework:)
27
+ unless framework.is_a?(String) || framework.is_a?(Symbol)
28
+ raise ArgumentError, "framework must be a String or Symbol"
29
+ end
30
+
31
+ framework = framework.to_s
32
+
27
33
  validate_files!(files, framework)
28
34
  config = Profiler.configuration
29
35
  run = Profiler::TestRunner.run_store.create(
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Profiler
4
- VERSION = "0.44.28"
4
+ VERSION = "0.44.29"
5
5
 
6
6
  GEM_ROOT = File.expand_path("../..", __dir__)
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.44.28
4
+ version: 0.44.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Duplessy