Skip to content

fix(accessories): reject nested resource entries - #2050

Merged
JohnVillalovos merged 1 commit into
mainfrom
jlvillal/psalm_3
Nov 22, 2026
Merged

JohnVillalovos merged 1 commit into
mainfrom
jlvillal/psalm_3

Conversation

@JohnVillalovos

Copy link
Copy Markdown
Collaborator

Changing an accessory's resources with only nested entries in the resource list (resource[][]=x) removed every resource from the accessory. When the list also held valid entries, those were saved and the nested ones were ignored.

Since 978565a the page read the list with GetFormStringList(), which drops entries that are not strings. A list holding only a nested entry reached the presenter as an empty list, which means "no resources selected". The check added in ccc443a, which rejects the request when an entry is not a string, could no longer run.

GetAccessoryResources() now returns the list as submitted, so the presenter sees the nested entry and changes nothing. A single value is still read as a one-item list, and a missing or blank field as an empty list.

Real-world severity is low:

  • The form never submits a nested entry. The request has to be built by hand.
  • Only an application administrator can send it, and it needs that administrator's CSRF token.
  • The same administrator can get the same result from the form by unticking every resource, so it grants nothing new.
  • The effect is limited to one accessory: its resource links and their minimum and maximum quantities are deleted and have to be entered again. No reservations are changed.

The presenter tests mock the page and kept passing. Add tests that drive the presenter through the real page.

Assisted-by: Claude:claude-fable-5-2

Changing an accessory's resources with only nested entries in the
resource list (resource[][]=x) removed every resource from the
accessory. When the list also held valid entries, those were saved
and the nested ones were ignored.

Since 978565a the page read the list with GetFormStringList(),
which drops entries that are not strings. A list holding only a
nested entry reached the presenter as an empty list, which means "no
resources selected". The check added in ccc443a, which rejects the
request when an entry is not a string, could no longer run.

GetAccessoryResources() now returns the list as submitted, so the
presenter sees the nested entry and changes nothing. A single value is
still read as a one-item list, and a missing or blank field as an
empty list.

Real-world severity is low:

- The form never submits a nested entry. The request has to be built
  by hand.
- Only an application administrator can send it, and it needs that
  administrator's CSRF token.
- The same administrator can get the same result from the form by
  unticking every resource, so it grants nothing new.
- The effect is limited to one accessory: its resource links and
  their minimum and maximum quantities are deleted and have to be
  entered again. No reservations are changed.

The presenter tests mock the page and kept passing. Add tests that
drive the presenter through the real page.

Assisted-by: Claude:claude-fable-5-2
Copilot AI lite review requested due to automatic review settings November 22, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain, and the changes include page-level coverage for malformed submissions, valid updates, and intentional clearing behavior.

No open issues 🎉

What changed in this PR

This PR prevents malformed nested accessory-resource submissions from being interpreted as an intentional empty selection that deletes all existing resource links.

Changes:

  • Preserve submitted resource values, including nested entries, so presenter validation can reject malformed requests.
  • Add page-level tests for malformed resources and quantities, valid updates, and intentional empty selections.
File Description
tests/​Pages/​Admin/​ManageAccessoriesPageTest.php Adds real-page coverage for malformed submissions, valid resource updates, malformed quantities, and clearing all selections.
Pages/​Admin/​ManageAccessoriesPage.php Preserves submitted accessory-resource entries so nested values reach presenter validation instead of being filtered into an empty list.

Review effort: Lite

@JohnVillalovos
JohnVillalovos enabled auto-merge (rebase) November 22, 2026 19:03
@JohnVillalovos
JohnVillalovos merged commit 1061529 into main Nov 22, 2026
17 checks passed
@JohnVillalovos
JohnVillalovos deleted the jlvillal/psalm_3 branch November 22, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants