Commit Graph
14101 Commits
Author SHA1 Message Date
IgorA100 71b1104c74 Add new log management translations in Russian 2026-11-11 10:20:12 +03:00
Isaac Connor 9b46479dd4 Merge pull request #5479 from AJ0070/5190-filter-save-overwrite
fix: keep the filter id in the url restored by back so save overwrites
2026-11-10 22:35:53 -05:00
Isaac Connor d32b3d4752 Merge pull request #5069 from AJ0070/fix/4727-clear-logs
fix: clear all logs when no rows are selected
2026-11-10 19:14:43 -05:00
Isaac ConnorandClaude Opus 4.8 04f097b9c0 fix: surface export copy failures and stop output accumulating fixes #5085
exportEvents() copies each event file with exec($cmd, $output, $return)
and only put $return into a ZM\Debug line, so a failed cp never reached
the user and the export still handed back an archive missing files - the
"fails silently" half of #5074. $output was also never reset between
iterations, and exec() appends to a non-empty array, so that Debug line
accumulated every line of output from every file in the export.

Reset $output before each copy, and on a non-zero return log a ZM\Error
and mark the export failed; after the loop, return false when any copy
failed so ajax/event.php reports "Export Failed" instead of serving an
incomplete archive, matching how the tar/zip step already handles its
own exec() status.

tests/php/test_export_copy_failure.php extracts the exportEvents() body
from the real source and checks the reset and the failure handling are
present; it fails against the pre-fix source.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-08 18:07:30 -05:00
Jash 62e8d24e29 fix: port clear all logs to the log panel and report server refusals, refs #4727 2026-11-08 15:01:42 +05:30
Jash 0f5c823378 Merge remote-tracking branch 'upstream/master' into fix/4727-clear-logs
# Conflicts:
#	web/skins/classic/views/js/log.js
#	web/skins/classic/views/js/log.js.php
#	web/skins/classic/views/log.php
2026-11-08 14:54:24 +05:30
Jash c00306433f fix: keep the filter id in the url restored by back so save overwrites, fixes #5190 2026-11-08 14:20:33 +05:30
Isaac ConnorandClaude Opus 4.8 be82debafa chore: remove the dead classic plugin view fixes #5101
web/skins/classic/views/plugin.php queried a PluginsConfig table that no
schema or migration creates and read ZM_PLUGINS_CONFIG_PATH, which is not a
ConfigData option, so ?view=plugin could never run. Nothing links to the
view, no menu or router entry references it, and its history shows only
sweeping maintenance edits, never plugin-feature work. It is a vestige of
the old 1.2x plugin experiment.

Remove the view and its per-view skin assets (js/plugin.js and the base,
classic and dark plugin.css). PluginsConfig and ZM_PLUGINS_CONFIG_PATH
appear nowhere else in the tree.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-07 23:42:11 -05:00
Isaac ConnorandClaude Opus 4.8 bf04cfe04c fix: refuse a path-traversal export name in exportEvents/downloadEvents refs GHSA-9hf5-jpww-rvpp
The export-generation path sanitized the user-supplied export directory name with
preg_replace('/[^\w\-.]/', '', ...), a whitelist that keeps dots, so a bare '..'
survived and $export_root became the parent of the export root. exportEvents()
then chmod'd, wrote into, and tarred that parent, and the archive was downloadable
through the safeExportComponent() read guard because it genuinely sat in the
exports dir. downloadEvents() had the same shape via DIR_EXPORTS_DOWNLOAD
(refs GHSA-72h2-rvhv-wr5g).

These are residual siblings of GHSA-fvx4-86xp-9v22, which hardened the download/
read views but left the write path. Refuse a '.'/'..' component in exportEvents(),
and route downloadEvents()'s name through the existing safeExportComponent().

Add tests/php/test_export_path_traversal.php.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-07 10:54:46 -05:00
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 Connor 05081ce635 Merge pull request #5322 from connortechnology/5186-zms-ui-next-event
fix: let the UI tell zms which event is next/prev for gapless playback
2026-11-06 18:49:12 -05:00
Isaac ConnorandClaude Opus 5.5 2d4605ef11 fix: look up neighbours again while zms is paused refs #4186
When the next event the page sent has been deleted, zms stops at the end of
the current event. The page only asked again about a 0 boundary, so it kept the
deleted neighbour and zms stayed paused. Ask again every BOUNDARY_REFRESH_MS
while zms reports paused; a different answer is sent and resumes it through
HintResumes. A user's pause is unaffected, since zms only resumes after
stopping at the end of the filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 20:18:13 -05:00
Isaac ConnorandClaude Opus 5.5 63b77eb001 fix: keep the event view's controls and size right when zms changes monitor refs #4186
On the zms path the page can move on to another monitor's event without a page
load, but its elements and PanZoom are built for the monitor it was loaded for.
Looking them up by eventData.MonitorId found nothing after such a change: the
scale timer threw on panZoom[id].getScale(), the zoom buttons stopped showing,
and the stream element was not found. Look them up by domMonitorId(), the
monitor the page was loaded for.

The image also kept the first monitor's size and zms its scale. When the new
event's frames are another size, run changeScale() again. The zones drawn are
the page's monitor's, so hide them and disable the toggle over another
monitor's event, and put them back as they were on returning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 20:18:13 -05:00
Isaac ConnorandClaude Opus 5.5 2993404c88 fix: restart zms on the event it was playing refs #4186
restartZmsStream reloaded the stream image's original URL, which names the
event the page was opened on. zms moves on by itself, now across monitors, so
recovering from a broken stream started playback over from that first event.
Restart on the last event zms reported, without the first event's frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 19:55:35 -05:00
Isaac ConnorandClaude Opus 5.5 234996a0ea fix: drop the reply to a neighbour lookup that was retried refs #4186
A lookup given up on after LOOKUP_TIMEOUT_MS is retried while the first may
still answer. If the first answered last, its older neighbours replaced the
retry's: a stale 0 disabled Next and sent zms a boundary. Number the lookups
and apply only the reply to the last one; only its completion ends the wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 08:45:56 -05:00
Isaac ConnorandClaude Opus 5.5 07844a935e fix: keep hints in order and let a late one restart a stopped stream refs #4186
Each hint is its own request, so two sends for the same event, such as a
boundary 0 and then the event found by the refresh, could reach zms out of
order and leave it with the older one. The page now waits for the replies to
one send before starting the next; a zms restart drops that wait, since the
old commands went to the old process.

When zms stopped at the end of an event because the filter had nothing
further, or the hint came too late, a hint arriving afterwards was stored but
playback stayed paused, so an event recorded since was never played. A
SET_EVENT that names an event in the direction we stopped in now resumes
through the end-of-event wait, unless a user command came in between.

Give up on an unanswered neighbour lookup after 5s rather than 10s, so a
retry still arrives within zms's 10s wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 08:30:56 -05:00
Isaac ConnorandClaude Opus 5.5 150d7de86e fix: number hint sends and retry failed neighbour lookups refs #4186
Replies to CMD_SET_EVENT named only the source event, so after a boundary
refresh or a zms restart the replies to an earlier send for the same event
could mark the later one delivered and stop its retries. Number each send and
match replies by that number; reset() drops the number so replies to the old
zms no longer count.

If the neighbour lookup after an event change failed, the page kept the
previous event's neighbours and never asked again, so zms waited at the end
of the event and stopped. Track the lookup: look up the playing event's
neighbours when there are none for it, one request at a time, retrying a
failed one after 2s and giving up on an unanswered one after 10s. This also
replaces the separate boundary refresh bookkeeping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 22:05:35 -05:00
Isaac ConnorandClaude Opus 5.5 2552d54cc9 fix: deliver the event view's next/prev hints to zms reliably refs #4186
The page sent its two SET_EVENT commands once, as soon as its
neighbours query returned:

- On page load that is often before zms has opened its socket. The
  command then failed with no_socket, getCmdResponse marked zms broken,
  and status polling stopped, so later event changes were never seen.
- A restarted zms (restartZmsStream) never got them.
- After zms moved to a new event, the neighbours query waited for
  eventQuery to return first, adding a round trip before zms could
  learn what follows.
- A "no next event" answer was kept for the whole event, so an event
  recorded after the page asked was never played.

event-zms-hints.js now tracks the hints: they go out after zms answers a
status query for their event, are resent if they did not reach zms or
zms restarts, and a boundary in the direction of play is asked for again
every 5s. They are sent with their own handler, so a failure never marks
zms broken. The page asks for the new event's neighbours as soon as zms
reports it, alongside eventQuery, and drops a neighbours reply for an
event zms has already left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:32:53 -05:00
Isaac ConnorandClaude Opus 5.5 ef29de86d4 fix: check SET_EVENT ids before authorising and packing them refs #4186
stream.php checked the target event's permission using the request
string and then packed intval() of it. On 32-bit PHP intval('2147483648')
is 2147483647, so the check and zms could see different events, and a
non-numeric or array value was cast to whatever intval() made of it.

The ids now have to be digit strings that fit in this PHP's int, or the
request is refused. The checked int is what gets packed. The packing
moved to includes/stream_set_event.php so tests/php can check the bytes
against EventStream::DecodeSetEvent's layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 19:32:53 -05:00
Isaac Connor 42706741d3 Merge remote-tracking branch 'upstream/master' into 5186-zms-ui-next-event 2026-11-04 18:41:28 -05:00
Isaac ConnorandClaude Opus 5.5 161a979673 fix: check the ffmpeg Options field syntax before saving a monitor
The Options field takes key=value pairs, but people copy ffmpeg command
line flags into it, such as -tls_verify 0 to accept an rtsps camera's
self-signed certificate now that ffmpeg 9 verifies by default. zmc then
logs that it could not parse the options and drops them.

monitor-ffmpeg-options.js ports av_dict_parse_string() and av_get_token()
so the form reports the entry ffmpeg would stop at. It also reports keys
that parse but can name no option: a leading dash, or whitespace or a
separator inside the key, which is what "a=1,tls_verify 0,b=2" turns into.
The help text now spells out the key=value form with tls_verify=0 as an
example.

The expected results in tests/js/ffmpeg-options.test.js were taken from
libavutil 61.1.102 on the same strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 18:30:49 -05:00
Isaac Connor ee9fefd267 Merge pull request #5455 from connortechnology/fix/ghsa-5w6w-revoke-tokens-master
fix: revoke API tokens when a user's password is changed (GHSA-5w6w-qp25-2qqh)
2026-11-04 08:40:04 -05:00
Isaac Connor 474c2af09e Merge pull request #5449 from IgorA100/patch-763131
Chore: Improved the display of the Monitor page’s "Viewing" tab (for both standard and narrow screens)
2026-11-04 08:27:25 -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
IgorA100 348b19b608 Add Russian translations for various features 2026-11-04 00:56:04 +03:00
IgorA100 cb9ac8a595 Improved the display of the Monitor page’s "Viewing" tab (for both standard and narrow screens) 2026-11-03 23:19:18 +03:00
Isaac ConnorandClaude Opus 5.5 9e3885e8fd refactor: remove ZM_OPT_FAST_DELETE
With fast deletes on, deleting an event in the web interface removed only
its Events row and left its Frames and Stats rows and its files for
zmaudit, and deleting a monitor left all of its events. zmaudit only runs
when ZM_RUN_AUDIT is on, and both options default to off independently,
so with fast deletes on and the audit off nothing ever removed them and
the Frames table grew without bound. In the Perl Event::delete the option
also kept zmfilter from removing the files of the events it purged.

Remove the option. ZM\Event::delete() always removes the Stats and Frames
rows and the files in one transaction with the Events row,
ZM\Monitor::destroy() always deletes the monitor's events, and the Perl
Event::delete deletes the files unless the storage area has DoDelete off.
zmupdate.pl rebuilds the Config table from ConfigData, so the option's row
goes away on upgrade without a migration. Drop the option from the docs,
from the zmaudit option help, and from the es_la, ro_ro and ru_ru
translations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 22:50:01 -05:00
Isaac Connor 9fef3b578a Merge pull request #5344 from IgorA100/patch-278747
Add a setting to enable/disable "backchannel" (a parameter used by Go2RTC) for the monitor.
2026-11-02 18:00:39 -05:00
Isaac Connor c566d738fc Merge pull request #5430 from connortechnology/fix/ghsa-8fj6-frames-canview
fix: require per-event view permission to list an event's frames (GHSA-8fj6-vrj2-vxmr)
2026-11-02 17:59:58 -05:00
Isaac Connor 4eda31b07d Merge pull request #5429 from jayhemnani9910/5416-audit-report-monitor-links
fix: give each event audit report row its own monitor link, fixes #5416
2026-11-02 08:41:10 -05:00
Isaac ConnorandClaude Opus 4.8 28c5f267a7 fix: require per-event view permission to list an event's frames refs GHSA-8fj6-vrj2-vxmr
ajax/frames.php task=query checked the global canView('Events') and then
built the Frames query from the request event id alone, without the
per-event check its siblings make. A user with Events=View but a monitor
permission of None on an event's monitor could read that event's frame
records -- frame number, Normal/Alarm type, timestamp, delta and score --
for any event on a denied monitor, learning when activity happened and how
strong the alarm scores were across monitor boundaries. This is the web
copy of the disclosure GHSA-mg2g-jmfc-3w8g fixed in the Frames API;
frame images stay protected by views/image.php.

Construct the event in the sanity block and refuse the request unless
ZM\Event::canView() passes, which enforces the per-monitor permission
through Monitor()->canView(), matching ajax/event.php and the API.

Test tests/php/test_frames_query_requires_view.php includes the real file
with the web helpers stubbed (one child php process per case, as the file
declares queryRequest() at file scope) and asserts the Frames table is
never read for a denied or missing event. 11 checks; 6 fail before the fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-02 08:39:59 -05:00
Isaac ConnorandClaude Opus 4.8 0fd646ef2e fix: reject path traversal in export download and archive views refs GHSA-fvx4-86xp-9v22
views/download.php and views/archive.php sanitized the user-controlled
`file` and `export_root` request parameters with str_replace('/', '')
only, which strips slashes but leaves `..` intact. export_root=.. made the
resolved path climb out of DIR_EXPORTS_DOWNLOAD into ZM_DIR_EXPORTS (and,
with file=.. as well, higher), and download.php then readfile()s it and,
from its shutdown handler, @unlink()s it. Any user with Events or Snapshots
view permission could read and delete files the web user can reach outside
the downloads directory.

Add safeExportComponent() and pathWithinExportDir() in
download_functions.php. The export file and directory names these views
handle are always single path components (zmExport_<connkey>.zip, a merged
'<Monitor> <start> to <end>.mp4'), so safeExportComponent() rejects any
value with a directory separator, a null byte, or a '.'/'..' traversal and
falls back to the generated default. pathWithinExportDir() resolves the
final path with realpath() and is checked in front of readfile() and
unlink(), so a path that still escapes the export directory - including
through a symlink - is refused.

Tests: tests/php/test_download_path_traversal.php

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-01 22:04:58 -05:00
Isaac Connor 3a41f9d634 Merge pull request #5423 from connortechnology/5418-current-weekday
fix: make Current Weekday filter terms run in the web UI and zmfilter.pl
2026-11-01 21:57:56 -05:00
Jay Hemnani 6cae4738e2 fix: give each event audit report row its own monitor link, fixes #5416 2026-11-02 04:08:13 +05:30
Isaac ConnorandClaude Opus 5.5 960d8feef7 fix: make Current Weekday filter terms run in the web UI and zmfilter.pl refs #5418
FilterTerm::sql_attr() returned 'weekday(NOW()' without its closing
parenthesis, so any filter with a Current Weekday term failed with
"Database query failed". FilterTerm::valid() treated the value 0 (Monday) as
missing, so a Monday term was dropped and the filter matched every event.

ZoneMinder::Filter had no CurrentWeekday case at all and emitted
E.CurrentWeekday, a column Events does not have, so zmfilter.pl could not run
such a filter either. Emit weekday(NOW()) there as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:29:02 -05:00
Isaac Connor aee38dd26c Merge pull request #5419 from connortechnology/fix/ghsa-xmq9-cors-origin
fix: allow CORS only for exact server and same-host origins (GHSA-xmq9-4xrm-p6p8)
2026-11-01 17:28:41 -05:00
Nic BoetandClaude Opus 5.5 481db3422a docs: say why corsAllowedOrigin() lives in Network.php
Network.php's header said policy decisions involving addresses do not
belong there. corsAllowedOrigin() is one, kept there because the web UI
and the API share it and functions.php cannot be loaded by a standalone
test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:21:45 -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
Isaac ConnorandClaude Opus 5.5 fca88d3b19 fix: report the whole search result as the events total, not the page refs #5417
With the search or advanced search box in use, the total was counted after
the rows were cut down to the requested page, so it equalled the page size
and the table could not page through the results. Count them first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:19:47 -05:00
Isaac ConnorandClaude Opus 5.5 e8298d91cb fix: leave out deleted monitors' events in the events query, not after paging refs #5417
The Events list hid events of soft-deleted monitors (Monitors.Deleted) while
building the rows, after the filter limit, the page slice and the totals. Pages
came up short, the footer counted and summed events that were never listed,
and a filter limit counted hidden events too.

Exclude M.Deleted in both SELECTs of queryRequest() so the limit, paging and
totals only see listed events, and drop the per-row skip. The new test runs
queryRequest() against the database inside a rolled-back transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:19:32 -05:00
IgorA100 06b58aa2ae Merge branch 'master' into patch-278747 2026-11-01 22:17:26 +03: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
Nic BoetandClaude Opus 5.5 767bb4759e fix: redact object properties and SQL values in web log lines
ZM_Object::apply_defaults() logged every property of each object it
loaded at Debug level, so loading a Monitor wrote its Pass,
ONVIF_Password and the user:password@ in Path and ControlAddress, and
loading a User its password hash (found by the camera probe, after the
monitor-save fix). A statement that failed logged its bound values at
Error level, which reaches the Logs table: for a monitor or user save,
the camera password or the password hash. dbFetchOne()'s missing-column
warning printed the whole row.

Properties and rows go through redactForLog() (by field name). Bound
values of a failed statement are logged only with ZM_DB_DEBUG, the
setting that already logs every statement's values; otherwise their
count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Nic BoetandClaude Opus 5.5 49ab7682ea fix: keep the auth relay out of PHP warnings on failed remote requests
When the other server of a multi-server install did not answer,
file_get_contents() raised a PHP warning whose text is the call and its
URL, ?auth=<hash> or user=/pass= included, and PHP wrote it to the web
server's error log (Event.php, Filter.php). The same happened with the
image proxy's digest retry (camera user:password@) and the X-Frame
check of a website monitor (get_headers()), which also took the false
it returns on failure for an array.

Fetch with @ and log lastErrorForLog(), the reason without the call
and its URL, next to urlForLog() of the URL. Server::SendToApi()
already used @ and now logs the reason too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Nic BoetandClaude Opus 5.5 5c69921e18 fix: stop logging camera credentials in the web UI
The network probe logged the camera password it was about to try and
camera URLs with user:password@ (monitor_probe.php), saving a monitor
dumped the changed fields with Pass, ONVIF_Password and the Path and
ControlAddress credentials (actions/monitor.php), the ONVIF probe logged
the failing zmonvif-probe command line, password included, at Error
level, which reaches the Logs table by default (onvifprobe.php), the CSV
camera import logged each URL at Info level (add_monitors.php), and the
image proxy logged its Digest Authorization header and the camera URL
(views/image.php).

Log user names without passwords, URLs through urlForLog() and dumps
through redactForLog(). removeUserinfo(), used by both, now also strips
a ControlAddress's scheme-less user:password@host, and ends the userinfo
at the last @ before the path: a camera password with a raw @ in it
works with cameras and ffmpeg, and its tail was left in the log.

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