Commit Graph
28 Commits
Author SHA1 Message Date
Jash c56b69d992 fix: API groups and tags edit refuse a GET instead of answering an empty message refs #7000 2026-11-20 17:20:16 +05:30
Jash b28734f850 fix: API group add answers JSON with the new id and refuses non-POST requests refs #6894 2026-11-19 21:28:24 +05:30
singhharsh1708 6ab9e959c8 fix: deleting a group through the API keeps its children under its parent 2026-11-18 00:19:18 +05:30
singhharsh1708 c102eb76aa fix: stop the groups API add warning or failing on a missing or array MonitorIds 2026-11-16 03:58:58 +05:30
Isaac Connor f3b2027e1b Merge pull request #5945 from AJ0070/api-monitor-zone-event-fixes
fix: API deleted monitors, default zone, monitor and zone validation, event pagination and file fields
2026-11-15 11:31:23 -05:00
Jash 8924411e68 fix: answer API deletes with a JSON message and a 500 on failure instead of an empty 200 refs #5981 2026-11-15 13:22:49 +05:30
Jash 42a2345a88 fix: hide deleted monitors from the API monitor and group lists refs #5944 2026-11-15 11:17:13 +05:30
Isaac Connor f6fb3c5cf5 Merge pull request #5755 from AJ0070/group-fixes
fix: monitor group filter, edit modal and delete
2026-11-14 23:50:15 -05:00
Isaac Connor 7ba565221a Merge pull request #5827 from AJ0070/api-filter-fixes
fix: API filter parsing for intervals, IS NULL, operators and ambiguous columns
2026-11-14 11:52:07 -05:00
Jash b98818e5bf fix: include the save result in the API group edit response refs #5830 2026-11-14 18:57:23 +05:30
Jash 3657a7e2f4 fix: answer with the validation errors instead of a 500 when an API group add fails refs #5830 2026-11-14 18:57:23 +05:30
Jash 3221599a3f fix: refuse an API group edit that puts a group under itself or its descendants refs #5830 2026-11-14 18:57:23 +05:30
Jash 0cd93c72e8 fix: qualify the API groups index filter fields so filtering on Id is not ambiguous refs #5826 2026-11-14 18:57:10 +05:30
Jash 2f0a107fd6 fix: API group delete keeps child groups instead of cascading refs #5754 2026-11-14 18:08:06 +05:30
Jash dcb404e5d7 fix: use the Group model when an API group edit fails validation fixes #5579 2026-11-12 03:00:29 +05:30
Isaac ConnorandClaude Opus 4.8 71cae39ed9 fix: pass a field allow-list at every API buildFilter call site refs GHSA-xqfr-6v9x-cvwc
Follow-up to the numeric field-name guard. FilterComponent::buildFilter() takes
an optional $validFields allow-list, but only EventsController's search index
and MonitorsController (via qualifyFields) used it; the other index/search/
consoleEvents call sites passed none, so a field name was checked only by the
character class, not against a known column set.

Pass array_keys($this->Model->schema()) - the pattern EventsController already
uses - at the remaining sites across Configs, EventData, Events (three), Frames,
Groups, ServerStats, Snapshots, Storage, Tags and UserPreference, so a field
must be a real column of the queried model and an unknown field is a 400 rather
than a MySQL 500. The injection itself is already closed by the numeric
field-name guard; this is defense in depth and consistent error handling.

ServerStatsController's commented-out permission check is left as-is (clients
need the data to render monitors); only the allow-list is added there.

Add tests/php/test_api_filter_fields_enforced.php.

Reported by arpitjain099.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-07 10:27:31 -05:00
Nic Boet 959b47f67d fix: check the group and event links an API save will write
Groups, Snapshots and Tags add/edit checked the ids from MonitorIds or
EventIds when the request had them, but Model::save() links the HABTM
entry (Monitor, Event) and ignores those fields on edit. A Groups=Edit
user could send {"Group":{"MonitorIds":"<current members>"},"Monitor":[]}:
the membership check saw no monitor moved, the save emptied the group and
lifted the Groups_Permissions deny on its monitors. On add, an empty
MonitorIds or EventIds next to a Monitor/Event list let monitors the user
may not edit into a new group, and events the user may not view into a
snapshot.

requestAssociatedIds() now reads the list the way save() does and
rewrites the request's entry to that plain list of ids, so a row given as
a join record links only its MonitorId/EventId. add() copies MonitorIds
or EventIds into the entry before the check, as it did before the save.

Test: tests/php/test_api_associated_ids.php
(cherry picked from commit 6bf015530e)
2026-10-31 18:45:52 -04:00
Isaac ConnorandClaude Opus 5.5 7c09ebd9e2 fix: require edit on each monitor a group change moves
Group membership feeds per-monitor access through Groups_Permissions, but
the classic group actions and the Groups API checked only the global
Groups permission. A Groups editor could add a monitor they are denied to
a group they have access through, or remove it from, or delete, the group
that denies it.

Add Group::canEditMembership() and require it, in both the classic UI and
the API, for every monitor added to or removed from a group, for all of a
group's monitors when it is re-parented, and for all of them when it is
deleted. The API also pins the record id and omits monitors the user may
not view from the groups it lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 17:54:25 -04:00
stefan 1bd9def63e [API] Fix User variable from array to object
Fix $user variable from array to object to make API work again.
2023-04-23 22:07:24 +02:00
Isaac Connor 849d71efff Add filtering to groups 2021-03-02 15:10:15 -05:00
Isaac Connor 05bd6e1c56 Fix editing groups causing a new Group to be added. You have to tell cakephp which Group you are saving. Also fix the resulting output to be the saved group, not a list of monitors. Fixes #3088 2020-12-03 13:14:19 -05:00
Pliable Pixels dadcea4884 remove recursive from index 2020-05-05 16:35:14 -04:00
Pliable Pixels 0817ea3bfb added association method to GroupsController to get Monitor Id/Name of monitors that belong to the group 2020-05-05 16:32:54 -04:00
Isaac Connor 5f006421cc fix #2771. Correct relationship from hasMany to hasAndBelongsToMany for Monitors in Group Modelel. Use save Assiociated in Controller, and add code to handle backwards compatibility by turning MonitorIds into the appropriate Monitor array 2019-12-15 15:31:40 -05:00
Isaac Connor 47465260d1 Update permissions checking for Groups to not use session. Fixes #2353 2018-12-21 10:01:48 -05:00
Isaac Connor b4c13d56d6 Merge ../ZoneMinder.master into storageareas 2018-03-06 12:29:59 -05:00
tim 0654c7e3b2 Adding group handling in API 2018-03-04 23:01:52 -08:00
Isaac Connor 6270408c8f rework group MonitorIds and add GroupId filters to api 2017-12-04 15:52:16 -05:00