trek 2.3.1 → 2.3.2

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: d6ee08de9f89d342f41a9c9139580e2b9bdc3196278a25093c32f4fdb252f2a8
4
- data.tar.gz: c9117839af6d9cbcec4951468913246ac20af148628d67a7930d0f8b8d74a3be
3
+ metadata.gz: 3749a9dc01b378419fbbaacdbf9e8251100d9bdd6281b308a9d44cf9dd18d182
4
+ data.tar.gz: d61b12a1f80494ebaf0c664bbfcfdf2d24b682632ef9c268117b4de23fb7e1b5
5
5
  SHA512:
6
- metadata.gz: 79a68fecd5c544d8e3184a9388196e9cc80403b4b788614dc4db7f98ca9734a5a14543a56eeb7cd2b777f96ad3dd57fe29883687ef3771362f6c12f2b7e34123
7
- data.tar.gz: 66358069ffd43f58794febe08082171cb2d47855e5f701436d5c38a87eb7c929490c7a4ae4837cdc7422765f6c1f57f1ee1214254b779300dcdb499eb01b5c3b
6
+ metadata.gz: e9083e34869370a8b22b69a8c9aadb3f404e74f9d4b32097c48f51ad024d750aed71769a203112b78f19b74c7489ec46f512340bdd728dfebfef76f6bd37ec27
7
+ data.tar.gz: 9800e5d16a2639e2a51644ce67bb488bd1e4c34930867f08311b7df56992dd7dcf42b37a926d4097a5bd5f9a1a59bc476f5d2c70091b9eb2f54efc11ee14dcfc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.3.2] - 2026-10-02
4
+
5
+ ### Fixed
6
+
7
+ - **Security:** `Trek::Scopes#apply_scopes` called any name found in `params[:scopes]` that the relation answered to, not only the controller's `available_scopes`, which let a request run unintended methods on the listed records. Only the names in `available_scopes` are applied now; others are ignored. **Upgrade note:** update Trek as soon as possible. A controller passing `apply_scopes` a scope name it does not list in `available_scopes` must add it there.
8
+ - The generated admin sign-in, password reset request and new password pages rendered their actions with the default aspect of `Trek::Form::ActionsComponent`, whose sticky action bar (top margin, padding, background) is meant for edit forms: inside those small cards, the button and the « forgotten password » link sat in a padded bar. They now use the `seamless` aspect. **Upgrade note:** in apps generated before this version, pass `aspect: :seamless` to `Trek::Form::ActionsComponent.new` in `app/views/admin/user_sessions/new.html.slim` and `app/views/admin/user_password_resets/{new,edit}.html.slim`.
9
+
3
10
  ## [2.3.1] - 2026-10-02
4
11
 
5
12
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trek (2.3.1)
4
+ trek (2.3.2)
5
5
  action_policy (~> 0.6)
6
6
  actioncable
7
7
  acts_as_list (~> 1.1)
@@ -19,8 +19,13 @@ module Trek
19
19
  def apply_scopes(scope, filters)
20
20
  return scope if filters.blank?
21
21
 
22
+ # Only the controller's own scopes: the names come from the request, and a relation also
23
+ # answers to destroy_all, delete_all…
24
+ allowed = available_scopes.map(&:to_s)
25
+
22
26
  filters.each do |filter, value|
23
27
  next if value.blank?
28
+ next unless allowed.include?(filter.to_s)
24
29
 
25
30
  scope = scope.public_send(filter) if scope.respond_to?(filter)
26
31
  end
@@ -31,7 +36,7 @@ module Trek
31
36
  def apply_scopes!
32
37
  @scopes_applied = true
33
38
  @unscoped_objects = @objects
34
- @objects = apply_scopes(@objects, params[:scopes])
39
+ @objects = apply_scopes(@objects, scope_params)
35
40
  scope_counts
36
41
  end
37
42
 
@@ -65,8 +70,10 @@ module Trek
65
70
  []
66
71
  end
67
72
 
73
+ # The requested scopes, permitted to the available ones; nil when params[:scopes] isn't a hash
68
74
  def scope_params
69
- params[:scopes]&.permit(*available_scopes)
75
+ scopes = params[:scopes]
76
+ scopes.permit(*available_scopes) if scopes.respond_to?(:permit)
70
77
  end
71
78
 
72
79
  private def ensure_scopes_applied
@@ -75,7 +75,7 @@ with the chosen filter:
75
75
  ### Scopes
76
76
 
77
77
  `Trek::Scopes` filters by **named model scopes** rather than raw attributes. Declare the allowed scopes via
78
- `available_scopes`, then call `apply_scopes!` in your `index`. It also exposes `scope_counts` and
78
+ `available_scopes`, then call `apply_scopes!` in your `index`; any other name in `params[:scopes]` is ignored. It also exposes `scope_counts` and
79
79
  `unscoped_objects` helpers (the per-scope match counts and the pre-scope collection) for building scope tabs:
80
80
 
81
81
  ```ruby
@@ -9,6 +9,12 @@ RSpec.describe "Admin password resets", type: :request do
9
9
  expect(response).to have_http_status(:ok)
10
10
  end
11
11
 
12
+ it "keeps the reset request actions in the card, out of the sticky action bar" do
13
+ get new_admin_user_password_reset_path
14
+
15
+ expect(response.body).to include("c-trek--form--actions-aspect-seamless")
16
+ end
17
+
12
18
  it "emails a reset link to a privileged user" do
13
19
  expect { post admin_user_password_resets_path, params: { email: editor.email } }
14
20
  .to have_enqueued_mail(Admin::PasswordsMailer, :reset)
@@ -31,6 +37,12 @@ RSpec.describe "Admin password resets", type: :request do
31
37
  expect(response).to have_http_status(:ok)
32
38
  end
33
39
 
40
+ it "keeps the new password actions in the card, out of the sticky action bar" do
41
+ get edit_admin_user_password_reset_path(editor.password_reset_token)
42
+
43
+ expect(response.body).to include("c-trek--form--actions-aspect-seamless")
44
+ end
45
+
34
46
  it "renders the new password form from an invitation link" do
35
47
  get edit_admin_user_password_reset_path(editor.generate_token_for(:invite))
36
48
 
@@ -9,6 +9,12 @@ RSpec.describe "Admin sign-in", type: :request do
9
9
  expect(response).to have_http_status(:ok)
10
10
  end
11
11
 
12
+ it "keeps the sign-in actions in the card, out of the sticky action bar" do
13
+ get new_admin_user_session_path
14
+
15
+ expect(response.body).to include("c-trek--form--actions-aspect-seamless")
16
+ end
17
+
12
18
  it "signs a privileged user in and opens the dashboard" do
13
19
  post admin_user_session_path, params: { email: editor.email, password: users.password }
14
20
  follow_redirect!
@@ -7,7 +7,7 @@
7
7
  maxlength: 72,
8
8
  minlength: 8
9
9
 
10
- = render Trek::Form::ActionsComponent.new do |c|
10
+ = render Trek::Form::ActionsComponent.new(aspect: :seamless) do |c|
11
11
  ruby:
12
12
  c.with_button(
13
13
  type: "submit",
@@ -6,7 +6,7 @@
6
6
  autofocus: true,
7
7
  autocomplete: "username"
8
8
 
9
- = render Trek::Form::ActionsComponent.new do |c|
9
+ = render Trek::Form::ActionsComponent.new(aspect: :seamless) do |c|
10
10
  ruby:
11
11
  c.with_button(
12
12
  type: "submit",
@@ -15,7 +15,7 @@
15
15
  maxlength: 72,
16
16
  minlength: 8
17
17
 
18
- = render Trek::Form::ActionsComponent.new do |c|
18
+ = render Trek::Form::ActionsComponent.new(aspect: :seamless) do |c|
19
19
  ruby:
20
20
  c.with_button(
21
21
  type: "submit",
data/lib/trek/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trek
4
- VERSION = "2.3.1"
4
+ VERSION = "2.3.2"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trek",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "A modern content management & back-office system for Ruby on Rails",
5
5
  "homepage": "https://trek.etamin.studio",
6
6
  "license": "MIT",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trek
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Bengrich