Commit Graph
64 Commits
Author SHA1 Message Date
Jash d2c275550d fix: event rename accepts the name 0 and reports names that don't fit refs #6749 2026-11-19 08:20:01 +05:30
Isaac Connor 4444800161 Merge pull request #6014 from AJ0070/export-options-button
fix: Export view option memory, button state and event count
2026-11-15 18:07:26 -05:00
Jash 9581b780f4 fix: accept a single eids value in event export and download instead of a TypeError refs #6015 2026-11-15 23:41:51 +05:30
Jash b7b02b9748 fix: remember unticked export options instead of restoring them ticked refs #6013 2026-11-15 23:39:59 +05:30
Jash e20a2f58eb fix: report a refused or failed event delete instead of success refs #5975 2026-11-15 12:54:58 +05:30
Jash 62c78d54b8 fix: report a failed tag create or add instead of answering Ok refs #5758 2026-11-14 18:08:18 +05:30
Jash adb04f5d33 fix: honour the mp4 option in the event download modal refs #5708 2026-11-13 14:15:01 +05:30
Nic Boet 5b8e7a0ad5 fix: make event videos only for events the user can view
ajax/event.php action=video appended monitorLimitSql() after GROUP BY,
where "GROUP BY E.Id AND MonitorId IN (...)" only changes the grouping
and filters nothing. A user denied a monitor could still have
zmvideo.pl encode that monitor's events and learn the file's path.

Put the limit in the WHERE clause and also check the loaded event with
Event::canView(), which applies the monitor's permission and the
Snapshots rule. monitorLimitSql() has no other caller.

tests/php/test_event_video_requires_view.php covers a denied monitor, a
missing event, a Snapshots-only user and a user without Events or
Snapshots view; 5 of its 11 checks fail before this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c95d4decbc)
2026-10-31 18:19:41 -04:00
Nic Boet 012063d3e1 fix: change or delete only events on monitors the user can view
The ajax/event.php actions rename, eventdetail, archive, unarchive and
delete checked Events edit only, and took any event id: a user with
Events edit restricted to some monitors could rename, annotate,
archive, unarchive or delete events of monitors they can't see. The
web event action and the API already check the event's monitor.

Load the event once for every Edit-level action in ajax/event.php and
require visibleMonitor() on its monitor, as addtag/removetag do; a
missing and a hidden event get the same answer (delete keeps its "Event
not found." reply). getselectedtags lists no tags of an event on a
hidden monitor.

includes/actions/eventdetail.php checks each event's monitor since
13138a0af, but passes markEids entries through validInt(), which keeps
an array an array, and new ZM\Event() takes an array as the row itself
without loading it: markEids[0][Id]=<hidden event>&markEids[0][MonitorId]=
<visible monitor> passes canEdit() and updates the hidden event. Take
only scalar ids there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit afe6452e421b10a9738d243bb5092cbbb2c4d0a6)
2026-10-30 18:10:30 -04:00
Nic Boet 7f09a39c88 fix: tag only events on monitors the user can view
addtag and removetag took any event id: a user with Events edit
restricted to some monitors could tag or untag events on monitors they
can't see. Filters select events by tag (a purge filter can keep tagged
events, or delete them), so that reaches events the user has no access
to. Load the event and require visibleMonitor() on its monitor; a
missing and a hidden event get the same error. removetag now validates
its ids like addtag.

ajax/tags.php listed tags only for Events view since the previous
commit, but the event view also serves Snapshots view users and loads
the tag list; accept either, as ajax/event.php does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5b9df458d55d3491086dbbe25dbac2d3f3db1264)
2026-10-30 18:10:07 -04:00
Nic Boet 7bae8d61bb fix: require Events edit to tag events or delete event videos
Three event write paths were reachable with Events view only:

- ajax/event.php handled addtag and removetag in its canView('Events')
  block. removetag also deletes the Tag row once no event uses it.
- ajax/tags.php had no permission check, so createtag inserted Tags for
  any logged-in user, and getavailabletags listed them.
- views/video.php opens with canView('Events') and unlinks
  $videoFiles[deleteIndex]. ZM_FFMPEG_FORMATS defaults to "mp4* ...", so
  that list includes the event's own recording: a viewer could delete
  the recorded video of every event on the monitors they can see.

Move addtag and removetag into the canEdit('Events') block next to
rename and archive. In tags.php require canView('Events') for the file
and canEdit('Events') for createtag. In video.php require
canEdit('Events') for deleteIndex, skip indexes that are not in the
list, and only show the Delete link to users who can use it. The event
view disables the tag input and the tag-and-step buttons for users
without Events edit.

tests/php/test_event_writes_require_events_edit.php drives the three
files with Events None, View and Edit and checks the SQL they send and
whether the video file survives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d935293c527c4543a3afbdad1afdddc774c63ea2)
2026-10-30 18:10:07 -04:00
Isaac ConnorandClaude Opus 5.5 c3d2e542bc fix: never build an object from an id the request sent as an array
ZM_Object's constructor treats an array as the object's row, and validInt()
and validCardinal() returned an array as they got it (preg_replace() does).
So wherever a request id reached `new ZM\X(...)`, raw or through those
validators, a crafted array built an object whose Id, UserId or MonitorId
the sender chose. The permission check then looked at those, and the delete
or update that followed used the Id. A user with Events=View deleted another
user's filter by posting Id[Id]=<filter>&Id[UserId]=<self> to the filter
delete action; the same shape reached events (MonitorId), users, reports,
snapshots and storage.

validInt() and validCardinal() now give '' for anything that isn't a single
value. The places that built an object from a raw $_REQUEST value (the
control and event ajax handlers, the event, filter, report, snapshot and
storage actions, view_hls, and the download and event detail modals) take
the id through validCardinal().

tests/php/test_request_ids_scalar.php covers the validators with arrays and
fails if web code builds an object straight from $_REQUEST, $_GET or $_POST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 23:07:08 -04:00
Isaac Connor e0a12a7392 fix(tags): validate addtag ids and include database.php in TagOrder refs #5021
Follow-up to review comments on PR #5022.

addtag passed $_REQUEST['tid'] and $_REQUEST['id'] straight into the
Events_Tags INSERT and the Tags UPDATE, while only the TagOrder call
sanitized tid. A non-numeric tid therefore still inserted a row with the
value coerced to 0, and only the recency bookkeeping was skipped.
Validate both ids once at the top of the case, reject non-scalar values
(array-form parameters such as tid[]=1, which validCardinal would return
as an array and bind as one), and reuse the sanitized values for all
three statements.

TagOrder.php calls dbFetchOne/dbQuery but did not pull in the database
helpers itself, relying on the caller having done so. Both current call
sites happen to, but that is incidental; require_once('database.php') to
match Tag.php and User_Preference.php.
2026-08-08 11:33:11 -04:00
Simpler1 bc700595dc fix(tags): PHP solution for personal tag order 2026-07-29 09:51:55 -04:00
IgorA100 b5bd306a4c We'll limit ourselves to transferring no more than 100 links and additional file name validation. (event.php) 2026-06-05 11:49:22 +03:00
IgorA100 e6975e014a We will prohibit the use of the ../ combination in paths. (event.php) 2026-06-04 09:52:37 +03:00
IgorA100 e328333074 - DIR_EXPORTS_DOWNLOAD is not passed to JS, but is used only in PHP.
- When making an AJAX request, we pass an array of file paths relative to DIR_EXPORTS_DOWNLOAD , not absolute ones.
- Check $fileName for a non-empty string.
- Clear fileExistencePollingInterval if it exists before calling again.
- More correctly retrieve parameters from the "el.href" string using "new URL(el.href)".
- Disabled the cursor for "a.disabled".
2026-06-01 12:45:12 +03:00
IgorA100 f465309183 Added AJAX action='file_existence_check'
Added the DIR_EXPORTS_DOWNLOAD constant from PHP to JS
Added a style for "#downloadModal a.disabled" on the Events page
2026-05-30 23:28:40 +03:00
Isaac Connor 644716b4ea fix: sanitize reflected user input in ajax error messages
Earlier commits in this branch dropped reflected user input from
ajaxError() messages entirely to close Snyk XSS findings, but that
lost useful diagnostic information ("Unrecognised action <name>",
"Insufficient permissions for user <user>"). Use validHtmlStr()
(htmlspecialchars with ENT_QUOTES) so the values still appear in
the message and Snyk recognises the sanitization. Affects
add_monitors.php, device.php, event.php, events.php, log.php.
2026-05-13 22:54:02 -04:00
Isaac Connor 2c50a99368 fix: sanitize download params at event ajax boundary
The download action passed $_REQUEST['exportFormat'] and connkey
through downloadEvents() into ajaxResponse() unsanitized. Constrain
exportFormat to the allowlist ('tar'/'zip') and strip non-[\w.-]
chars from connkey at the call site.
2026-05-13 16:06:36 -04:00
Isaac Connor 0d197c9035 fix: sanitize export filename and connkey at event ajax boundary
$_REQUEST['exportFile'] and $_REQUEST['connkey'] flowed through
exportEvents() into ajaxResponse() (i.e. exit(jsonEncode())).
exportEvents() already sanitizes both internally via the same
preg_replace, but Snyk can't trace through the function — sanitize
at the call site so the taint is closed at the boundary.
2026-05-13 15:59:33 -04:00
Isaac Connor 4163feb939 fix: remove reflected user input from event ajax XSS sink
The catch-all ajaxError() at the bottom of event.php reflected both
$_REQUEST['action'] and the session username. Same Snyk pattern as
add_monitors.php and device.php. Action is now logged server-side
via ZM\\Warning; user-facing message is static.
2026-05-13 15:56:49 -04:00
Isaac Connor 286feece4c Move tag related commands to canView(Events) instead of canEdit(Events) 2026-03-12 15:03:29 -04:00
IgorA100 fc491ab12c Changed the function name from "exportEvents" to "downloadEvents" (event.php) 2025-12-18 00:52:36 +03:00
IgorA100 0020d29c89 Removed the ":" character from allowed characters (event.php) 2025-12-11 12:39:18 +03:00
IgorA100 b1f65aaabc Fix: Allow using any character from the "letter" category in the name of the downloaded event archive (event.php)
This change will allow the use of any national Unicode alphabet in the file name.
We also allow any numeric character and the characters "-", ".", "(", ")"
The ":" character is prohibited in file names in Windows, so we're excluding it from the list of allowed characters.
2025-12-11 12:15:11 +03:00
Isaac Connor 9e7d31841e Fix SQL Vulnerability. Fixes GHSA-qm8h-3xvf-m7j3 2024-10-31 13:51:50 -04:00
Isaac Connor 7e98cf36d6 Remove requirement for id or eids. We can specify by filter now. Fix populating exportIds making sure it is an array. 2024-02-15 16:21:39 -05:00
Isaac Connor 648bd77b21 Apply validCardinal to all eids. Remove dead delete code 2024-01-27 18:33:19 -05:00
Isaac Connor 44a3a7a6a8 Fix loading event due to missing GROUP BY. Fixes event video generation. 2023-12-01 12:46:05 -05:00
Isaac Connor 44c5c3c70c Introduce new download mode that concats event videos into 1 file per monitor 2023-10-04 12:04:11 -04:00
Simpler1 18d74ed7ac (feat): Tags
fix(tag): Create tags on mobile

chore(tags): Change TagName to Name

chore(tags): eslint

chore(tags): dbFetchAll to dbQuery for removetag

chore(events): eslint (attempt 2)

feat(tags): Better handling of keyboard

fix(tags): Enter key for creating new tag

fix(tags): Don't allow space as a tag name

feat(tags): Delete tag if last assignment removed

fix(tags): Increase height of dropdown

in progress

fix(Tags): Use T.Id on the events page dropdown

fix(Tags): Remove $availableTags from events.php

chore(sql): Formatting sql statements

feat(Tags): Working OR on filters and events pages

fix(filter): Populate availableTags

chore(Tags): code formatting

fix(tag): Add tag on create tag

Fix(tags): Remove tag from available if last

feat(tags): Add zm_update.sql

fix(chosen): Undo css width

fix(chosen): tags dropdown width

fix(tags): dropdown over timeline

fix(tags): Full width input

fix(events): Refresh table on page show

chore(filter): Clean up availableTags

chore(event): Clean up available & selected Tags

fix(event): Update available tags on remove

fix(event): Remove hack for selected tags

feat(tags): Blur input after adding tag

doc(tags): Initial tags documentation

fix(tags): Dark theme dropdown

fix(tags): Dark theme for tags on input

fix(tags): Dark theme for highlight in dropdown

fix(tags): Populate filter tags droplist

chore(): Bump zm_update to 1.37.42

chore(tags): Move mobile check to skin.js

chore(tags): Comment debug statements

fix(tags): Enter key to create tag on mobile Chome

chore(tags): Space in 'All Tags' for translation

Temporary commit to handle cookie expiration times

chore(tags): Remove unnecessary Tag(s) from en_gb

chore(): Cleanup unnecessary Error and Debug

chore(): Resolve merge conflicts

chore(): Address merge conflicts with master
2023-08-31 15:50:08 -04:00
Isaac Connor 969baa3891 Convert user from an array to a User object 2023-04-23 12:57:29 -04:00
Isaac Connor 4c40ef8cfb Add transform support and use Event::createVideo 2022-09-06 13:46:54 -04:00
Isaac Connor 05a38c76ba Turn back on flat structure for video Download 2022-05-24 12:11:18 -04:00
Isaac Connor ed84b59671 remove extra , 2021-11-10 14:23:36 -05:00
Isaac Connor e7e8996060 Can export events if canView Snapshots. Event->canView will filter events that are not in a snapshot 2021-08-18 10:53:59 -04:00
Isaac Connor 1f1678064e Allow specifying export Structure to get a flat zip 2021-08-06 13:10:44 -04:00
Isaac Connor bed41ca44b Support specifying the export filename by passing the export_root 2021-08-05 13:30:52 -04:00
Isaac Connor d7680e1a44 Spacing 2020-05-23 10:15:48 -04:00
Isaac Connor 4e58a38317 use ini_set(display_errors,0) instead of turning off errors entirely so that we still log errors, just not output them instead of json. 2020-04-03 15:21:31 -04:00
Isaac Connor 1cbc75813c improve the output of the ajaxError to say what the action was and who the user was 2020-02-06 13:21:57 -05:00
Isaac Connor 547e80b1a9 Fix download and export button from events list. Fixes #2668 (#2670) 2019-07-24 12:31:43 -04:00
Isaac Connor df348c3513 lets go with reporting actual errors 2019-04-10 11:48:17 -04:00
Isaac Connor f7dfe2982b Fix deleting single events 2019-04-10 11:46:12 -04:00
Isaac Connor 84a200395e spacing and turn off errors because ajax should only return json 2019-03-20 14:25:34 -04:00
Isaac Connor 40292f3dad Add Compression flag 2018-09-07 09:08:33 -04:00
Isaac Connor e05604e4b3 Alter code style, spacing 2018-07-12 14:05:23 -04:00
Isaac Connor 639f916156 spacing 2018-07-09 09:59:03 -04:00
digital-gnome 3e7c573da5 Add download video option to events view
Creates a new popup window for downloading event video files with no directory structure in the archive
2017-12-03 14:42:07 -05:00