Commit Graph
437 Commits
Author SHA1 Message Date
Isaac Connor 18dee7a711 Merge pull request #5803 from AJ0070/zone-followups
fix: zone filter typing, pixel zone bounds, API reload and delete restarts
2026-11-14 18:48:36 -05:00
Isaac Connor 28d463b325 Merge pull request #5913 from AJ0070/api-snapshot-tag-saves
fix: API snapshots and tags index, save errors and tag delete
2026-11-14 18:46:41 -05:00
Isaac Connor e2b3550b1b Merge pull request #5919 from AJ0070/api-admin-resource-saves
fix: id pinning and validation errors in API resource saves
2026-11-14 18:05:45 -05:00
Jash 001f97069a fix: answer the API event data add and edit in JSON with the result and validation errors refs #5918 2026-11-14 23:05:47 +05:30
Jash 65b56bc90b fix: pin the API encoder template id on save, answer a failed save with 422 and require Params on create refs #5918 2026-11-14 23:05:47 +05:30
Jash 4f14a7fc29 fix: serialize the API zone preset view, pin its id on save and answer a failed add or edit with the validation errors refs #5918 2026-11-14 23:05:46 +05:30
Jash e599232ff5 fix: look up an API server stat by its own alias in view, pin its id on save and answer a failed add or edit with the validation errors refs #5918 2026-11-14 23:05:46 +05:30
Jash dbc664a6f4 fix: pin the API manufacturer and model id on save, refuse duplicate names and answer a failed add with the validation errors refs #5918 2026-11-14 23:05:46 +05:30
Jash 0d2cdc7dbc fix: pin the API storage id on save, answer a failed add or edit with the validation errors and refuse to delete a storage area in use refs #5918 2026-11-14 23:05:46 +05:30
Jash 5866cdc6eb fix: pin the API server id on save and answer a failed server add or edit with the validation errors refs #5918 2026-11-14 23:05:46 +05:30
Jash 7c466cee05 fix: use the Id column as the API log key, apply named filters to the logs index, serialize the log view and require the not null log fields refs #5916 2026-11-14 23:05:29 +05:30
Jash 651e107f41 fix: read EventIds from a flat or JSON API tag add so the events are linked refs #5912 2026-11-14 23:05:16 +05:30
Jash a37b7c0952 fix: answer a failed API tag add or edit with the validation errors, refuse a duplicate tag name and let a tag with events be deleted refs #5912 2026-11-14 23:05:16 +05:30
Jash da502b0a5e fix: read EventIds from a flat or JSON API snapshot add so the events are linked refs #5912 2026-11-14 23:05:16 +05:30
Jash 9bb77bbf6b fix: stop the API snapshots index repeating a snapshot per event, return the events in associations and the validation errors on a failed add or edit refs #5912 2026-11-14 23:05:16 +05:30
Isaac Connor 40ada52b42 Merge pull request #5835 from AJ0070/api-input-validation
fix: validate API input against the column types before saving
2026-11-14 11:59:38 -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
Isaac Connor a4daebd2a6 Merge pull request #5829 from AJ0070/api-host-fixes
fix: API daemon control permission level, daemonCheck error and daemonStatus
2026-11-14 11:51:22 -05:00
Isaac Connor dd9134dcdd Merge pull request #5831 from AJ0070/api-groups-fixes
fix: API group parent loops and add/edit error responses
2026-11-14 11:50:52 -05:00
Isaac Connor 0796ccd825 Merge pull request #5833 from AJ0070/api-edit-responses
fix: API configs and zones edit responses
2026-11-14 11:50:23 -05:00
Jash 001891a5f1 fix: ignore non-string token and password request values refs #5858 2026-11-14 19:16:47 +05:30
Jash 78f591b721 fix: build the legacy plain credentials from the authenticated user refs #5858 2026-11-14 19:16:47 +05:30
Jash 0434acc1fb fix: serialize the roles index for JSON responses refs #5858 2026-11-14 19:16:47 +05:30
Jash 66619319d9 fix: validate number, date and enum values in API saves so a bad value is a field error and not a 500 refs #5834 2026-11-14 18:57:35 +05:30
Jash 17daba318b fix: return the validation errors in the API zone edit response instead of printing them refs #5832 2026-11-14 18:57:29 +05:30
Jash 89a9de0e92 fix: answer the API config edit in JSON instead of an empty body or the template source refs #5832 2026-11-14 18:57:28 +05:30
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 27e0da25f4 fix: report a monitor daemon as running in the API only when zmdc says it is refs #5828 2026-11-14 18:57:17 +05:30
Jash 950009dd5b fix: call ZM\Error for invalid daemon characters in the API host controller and reset the count refs #5828 2026-11-14 18:57:16 +05:30
Jash accde152ed fix: let an account with System Edit use the API daemonControl check and status commands refs #5828 2026-11-14 18:57:16 +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 6aa2f9b984 fix: qualify the API events index filter fields so Id or MonitorId with a GroupId or Tag filter is not ambiguous refs #5826 2026-11-14 18:57:10 +05:30
Jash 66534da715 fix: accept IS NULL in API named filters and answer 400 for operators that always failed refs #5826 2026-11-14 18:57:10 +05:30
Jash 9e8dea5c88 fix: answer 400 for an unknown interval unit in the API events search and consoleEvents refs #5826 2026-11-14 18:57:10 +05:30
Jash a6a0cb33f4 fix: reload the capture daemon when a zone is edited or deleted through the API refs #5802 2026-11-14 18:30:09 +05:30
Isaac Connor 29a376ba05 Merge pull request #5580 from AJ0070/5579-api-group-edit
fix: use the Group model when an API group edit fails validation
2026-11-11 19:11:34 -05:00
Jash c9de8488d5 fix: look up an event's highest scoring frame by FrameId in the API events index fixes #5591 2026-11-12 03:57:43 +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
Jash 90993466a4 fix: quote storage paths passed to df, du, ffprobe and AutoExecute refs #5556 2026-11-12 01:07:48 +05:30
Isaac ConnorandClaude Opus 4.8 dd2a658b31 fix: add the field allow-list to ServerStatsController too refs GHSA-xqfr-6v9x-cvwc
Completes the previous commit, which omitted this one call site.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-07 10:28:53 -05:00
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
Isaac ConnorandClaude Opus 4.8 71996d18b6 fix: reject all-digit API filter field names in FilterComponent refs GHSA-xqfr-6v9x-cvwc
A named parameter written `0:<payload>` reaches FilterComponent::buildFilter()
as an integer array key, and the field regex `[a-z0-9.]+` matched the all-digit
name, so `$conditions["0"] = $value` cast the key to an int. CakePHP 2.x renders
an integer-keyed condition as a raw, unescaped SQL fragment, so the value went
into the WHERE clause verbatim (UNION exfiltration, ACL bypass via a trailing
comment, blind boolean oracle) at the index() call sites that pass no
$validFields allow-list.

Refuse an all-digit field name in buildFilter(), so every key that reaches
$conditions contains a letter or a dot and stays a string key that CakePHP
quotes. Add tests/php/test_api_filter_numeric_field.php.

Reported by arpitjain099.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-07 10:01:11 -05:00
Isaac ConnorandClaude Opus 4.8 05a610a2c6 fix: revoke API tokens when a user's password is changed
Changing a user's password rewrote only the password hash and left the
user's JWT API tokens valid: a pre-change access token kept working and a
pre-change refresh token kept minting new access tokens for up to its 24
hour lifetime, so a leaked token survived the password change meant to
cut it off.

Set TokenMinExpiry to the change time in the same step that rewrites the
hash, so validateToken() rejects every token issued before the change,
matching the options page's existing revoke action. Covered paths: the
REST API User model (beforeSave), with the self-edit controller whitelist
widened to persist the field, and the classic web UI user action for both
the administrator edit and the self edit. The login-time upgrade of a
legacy hash to bcrypt rewrites the same password and is left untouched so
it does not revoke tokens.

refs GHSA-5w6w-qp25-2qqh

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-04 08:26:38 -05:00
Nic BoetandClaude Opus 5.5 96804bca31 fix: allow CORS only for exact server and same-host origins
CORSHeaders() (web UI) and AppController::beforeFilter() (API) send
Access-Control-Allow-Origin with Access-Control-Allow-Credentials: true.
With no Servers rows and ZM_MIN_STREAMING_PORT set they reflected any
Origin, and with Servers rows they matched the Origin against each
server's Hostname and Name with a regex anchored only at the start, so
https://zm.example.com.evil.net was accepted for zm.example.com.

Both now call corsAllowedOrigin() in Network.php, which accepts an
Origin of the form scheme://host[:port] whose host equals a server's
Hostname or Name, or, without Servers rows and with streaming ports,
the host this request was made to. Any port is accepted, so multi-port
streaming keeps working. Same-origin and unlisted origins get no CORS
headers, as before; the web UI still warns about unlisted origins only
when Servers rows exist.

Tests: tests/php/test_cors_allowed_origin.php

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:21:45 -05:00
Nic BoetandClaude Opus 5.5 d4655c1137 fix(api): accept a bare monitor filter field that one joined table has
qualifyFields() required a bare field to be a Monitors column, so names
only a joined table has, such as Status, CaptureFPS and AnalysisFPS from
Monitor_Status, answered 400 where they used to filter:

  GET /api/monitors/index/Status:Connected.json   -> 400 Unknown filter field

A bare field that Monitors has is still written Monitor.Field. Otherwise
it must be a column of exactly one joined table and is left bare, as
before, for MySQL to resolve; buildFilter() does not accept an alias with
an underscore such as Monitor_Status, so it cannot be qualified. A bare
field no table has stays a 400, and one two joined tables have and
Monitors does not (MonitorId, in Monitor_Status and Event_Summaries) is a
400 "Ambiguous filter field" instead of a 500 from MySQL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 11:31:26 -05:00
Nic BoetandClaude Opus 5.5 48180ae304 fix(api): answer 400 on a bad interval or field in events search
EventsController::search() and consoleEvents() threw a plain Exception
for an interval or field name they could not parse, which is a 500.
With the generic message in 5xx bodies the client no longer learned
what was wrong. Throw BadRequestException, as FilterComponent does
since 028ccecb5: a 400 that names the bad value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 11:31:26 -05:00
Nic BoetandClaude Opus 5.5 7fffa186f6 fix(api): check monitor filter fields, qualify them with the model
MonitorsController::index() passed its named parameters to
FilterComponent::buildFilter() without a field list, so any name made
of letters, digits and dots reached MySQL as a column:

  GET /api/monitors/index/Nope:1.json   -> 500, PDOException 42S22

and the bare names Id and Name, which the joined Manufacturers and
Models tables have too, failed as ambiguous columns (also 500).

FilterComponent::qualifyFields() checks each field against the columns
of the queried model and of the models find() joins, and writes it
Model.Field: a bare field is a Monitors column. GroupId stays bare for
the Groups_Monitors join. Anything else is a 400 "Unknown filter field",
as events/index answers since 028ccecb5. Column names match without
regard to case and are written as the schema spells them.

The web UI's map (Deleted:0) keeps working;
Name:x, Id >:0, Name LIKE:x and Id IN:1,2 now return monitors instead
of a 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 11:31:26 -05:00
Nic BoetandClaude Opus 5.5 66a1267b42 fix(api): keep exception text and credentials out of 5xx bodies
With debug 0, Cake replaces a 500's message with a generic one, but
Crud's exception renderer adds data.exception.message from the raw
exception. A PDOException (e.g. monitors/index/<unknown column>:1.json)
returned the SQL error and its fragment of the query to the client.
data.url also echoed the request URL with its token or password.

ZmExceptionRenderer extends Crud's renderer: with debug 0 a 5xx body
carries the generic message in data.exception.message (class and code
are kept), and data.url has credential values redacted.
AppController::beforeFilter() swaps it in for the renderer Crud's
ApiListener registers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 11:31:26 -05:00