Commit Graph

57 Commits (master)

Author SHA1 Message Date
Isaac Connor b3a7c05f07 fix: close SQL injection, command injection, and shell escaping gaps
FilterTerm.php:
- Use intval() on AlarmedZoneId value in SQL subquery to prevent
  injection via crafted filter val

report_event_audit.php, montagereview.php:
- Cast $selected_monitor_ids through array_map('intval') before
  interpolating into SQL IN clause (values come from $_REQUEST)

download_functions.php:
- Replace manual single-quoting with escapeshellarg() for merged
  file name in ffmpeg, tar, and zip commands (monitor names can
  contain shell metacharacters including single quotes)
- Same fix for export list file path

export_functions.php:
- Use escapeshellarg() on source and destination paths in cp -as
  commands during event export

functions.php:
- Validate column keys in getFormChanges() against /^[a-zA-Z0-9_]+$/
  to prevent SQL injection via crafted array keys from $_REQUEST
- Use dbEscape() and intval() for image/document MIME type and size
  fields instead of raw string interpolation
- Replace escapeshellcmd() with escapeshellarg() in deletePath()
  rm -rf command

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 10:48:23 -04:00
Isaac Connor ffe6362dc3 fix: harden web interface against injection and SSRF vulnerabilities
FilterTerm.php:
- Replace eval() with safe compare() method for SystemLoad, DiskPercent,
  and DiskBlocks filter conditions (RCE via crafted op/val)
- Validate operator against allowlist in constructor
- Sanitize collate field to alphanumeric/underscore only (SQLi)

onvifprobe.php:
- Use escapeshellarg() on interface, device_ep, soapversion, username,
  and password arguments passed to execONVIF() (command injection)

Event.php:
- Use escapeshellarg() on all arguments to zmvideo.pl instead of
  escapeshellcmd() on the whole command (command injection via format)
- Anchor scale regex with ^ and $ to prevent partial matches

image.php:
- Restrict proxy URL scheme to http/https only (SSRF via file:// etc)

filterdebug.php:
- Use already-sanitized $fid instead of raw $_REQUEST['fid'] (XSS)

MonitorsController.php:
- Use escapeshellarg() on token, username, password, and monitor id
  in zmu shell command instead of escapeshellcmd() on whole command

HostController.php:
- Use escapeshellarg() on path in du command (command injection via mid)
- Remove space from daemon name allowlist (argument injection)

EventsController.php:
- Remove single quotes from interval expression regex (SQLi)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 23:30:49 -04:00
Pliable Pixels 79253dc374 fix: address review feedback for tag filter handling
- Add IS NOT operator check alongside != in PHP FilterTerm.php
  (was already handled in Perl but missing from PHP)
- Add defined() guard on $term->{val} in Perl Filter.pm to avoid
  uninitialized value warnings with malformed/legacy saved filters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:11:13 -05:00
Pliable Pixels 1188635e9a fix: correct tag filter operator handling for "No Tag" and "Any Tag"
The filter system ignored the operator (= vs !=) when generating SQL
for the special tag values "No Tag" (0) and "Any Tag" (-1).

In PHP (FilterTerm.php), "Tag != Any Tag" produced EXISTS instead of
NOT EXISTS, returning events WITH tags instead of events WITHOUT tags.

In Perl (Filter.pm), != was not handled as a special case and fell
through to generic SQL (T.Id != -1), which excluded events with no
tags because LEFT JOIN produces NULL and NULL != -1 evaluates to
UNKNOWN in SQL. Additionally, T.Id was unconditionally prepended for
all tag values, producing invalid SQL (T.IdEXISTS) for the special
cases that use EXISTS/NOT EXISTS subqueries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:01:39 -05:00
copilot-swe-agent[bot] b44aafb0ca Add "Any Tag" filter option for events
- Added "Any Tag" entry with value -1 to availableTags in Filter.php (widget and simple_widget methods)
- Added "Any Tag" entry to filter.php view
- Added translation for "Any Tag" in en_gb.php language file
- Implemented SQL logic in FilterTerm.php to handle "Any Tag" (value -1) using EXISTS query
- Implemented SQL logic in Filter.pm (Perl) to handle "Any Tag" (value -1) using EXISTS query

Co-authored-by: connortechnology <925519+connortechnology@users.noreply.github.com>
2026-01-10 14:13:37 +00:00
Simpler1 3a0d8d7c8f Fix(tags): "No Tag" filter now works properly. 2025-12-08 15:09:01 -05:00
Isaac Connor a0d66fc58f Add support for CurrentDate/Time/DateTime to filters 2025-10-23 19:17:00 -04:00
Isaac Connor 5d1707a409 Fix generated sql for filterServerId 2025-08-05 10:33:33 -04:00
Isaac Connor 78785861a7 Use '' instead of 0 for No Tag value. 2025-04-11 11:31:53 -04:00
Simpler1 aca3655442 feat(tags): Filter option for No Tag 2025-03-06 12:23:01 -05:00
Isaac Connor 7a8f9a603d Remove debug 2024-05-21 09:39:53 -04:00
Isaac Connor 36ab6380cb Include backtrace when complaining about lack of term in FilterTerm 2024-04-30 08:57:09 -04:00
Isaac Connor bec19f39e6 Fix comparison to True instead of true. Fixes #3952 2024-04-07 10:12:12 -04:00
Isaac Connor ef5e90d669 Improve logic of DiskSpace pre condition. Implement specific op support, instead of using unsafe eval. 2024-03-20 10:22:15 -04:00
Isaac Connor edcf09882f Subsitute a 0 when ZM_SERVER_ID is not defined 2024-02-21 16:35:04 -05:00
Isaac Connor 1545210b12 Add php8.1+ members support for multiple and chosen flags for filter terms 2023-10-26 18:43:05 -04:00
Isaac Connor f8c89a0405
Merge branch 'master' into tags 2023-09-14 16:42:06 -04:00
Isaac Connor ef402e7b99 Define tablename member 2023-09-13 13:05:39 -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 bc1214e8e5 Don't use empty because it tests for false, and 0 is false. Just check for empty string. Fixes #3732 2023-06-27 10:44:25 -04:00
Isaac Connor 66ef087a4d ServerId and FilterServerId must have a value to be valid 2023-05-26 16:38:58 -04:00
Isaac Connor e14fc279e4 Handle empty set in IN/NOT IN better 2023-05-26 16:35:45 -04:00
Isaac Connor 20b7624da0 Handle op not being specified 2023-05-23 15:51:35 -04:00
Isaac Connor fbe954473a Add support for placeholders, cookies, case insensitive search and Group as an attr. 2023-05-17 14:36:38 -04:00
Isaac Connor 240333381a Handle val and cnj not being specified. Add Notes to attr that must be non empty 2023-04-11 07:53:55 -04:00
Isaac Connor 32afb13b39 Sanitise attr input in FilterTerm to prefent SQL Injection. Fixes GHSA-222j-wh8m-xjrx 2023-02-23 09:25:03 -05:00
Isaac Connor c009ef1bbe Fix AlarmFrames validity test 2023-02-15 15:00:23 -05:00
Isaac Connor c8e4dcbe51 Add valid case for Archived 2023-01-25 13:25:33 -05:00
Isaac Connor fe95e5b2bc Add valid test case for AlarmFrames 2023-01-25 11:41:38 -05:00
Isaac Connor e59687f437 Remove debug 2023-01-03 13:16:38 -05:00
Isaac Connor e4d167b33e Fix returning periods for sql when no attr 2022-12-12 13:00:19 -05:00
Isaac Connor 0705bfa293 Check for term being null in FilterTerm constructor 2022-12-07 12:39:41 -05:00
Isaac Connor 5d36739d0d Add Monitor as an acceptable FilterTerm 2022-12-07 12:39:12 -05:00
Isaac Connor 6cd3e64bb8 Add NOW as a valid value for DateTime, rough in valid test function 2022-12-07 12:36:41 -05:00
Isaac Connor 1134954166 Add Monitor as a Filter Term 2022-12-07 12:34:31 -05:00
Isaac Connor 3d1a9c5b2d Add LIMIT 1 when filtering by AlarmZoneId to speed up 2022-09-01 07:06:46 -04:00
Isaac Connor d8dea37c88 When selecting AlarmedZone, must check for SCore > 0. 2022-07-28 16:33:38 -04:00
Isaac Connor a578370970 Add filter terms for snapshots 2022-06-09 12:13:58 -04:00
Isaac Connor b47d036b89 Use date() instead of strftime() for date formatting now that strftime is deprecated 2022-06-01 10:37:04 -04:00
Isaac Connor 8b14885541 Add handling of NOT IN and =\[\] and \!\[\] 2022-02-15 18:52:46 -05:00
Isaac Connor 44e8107cac Fix AlarmedZoneId filter term not working because I wrote AlarmZoneId instead 2021-05-02 13:38:06 -04:00
Isaac Connor b50916e02a Allow unknown columns in filters. Allow specifying the table name in FilterTerm. 2021-03-12 10:52:10 -05:00
Isaac Connor 0fc4b00ac1 Allow null as well as NULL infilter values 2021-02-20 12:32:38 -05:00
Andrew Bauer 0ffb5e153c modify FilterTerm to support Frames view searches 2020-11-14 17:33:18 -06:00
Isaac Connor 2d33dd5386 Rename StartTime, EndTime in Events to StartDateTime and EndDateTime 2020-11-04 13:52:32 -05:00
Isaac Connor e67532ef76 implement is_valid_attr. Fix incorrect EventDiskspace vs FS DiskSpace. FS DiskSpace isn't implemented. DiskPercent is. 2020-11-04 12:40:43 -05:00
Isaac Connor b6004012e9 implement passing the object name to use when constructing the querystring 2020-10-23 17:56:05 -04:00
Isaac Connor 1dfebc24b0 Fix ZM\ 2020-10-21 10:36:58 -04:00
Isaac Connor 10c0a6617c Return Debug to a regular function to match other logging functions. Since we switched to using namespaces we no longer clash with cake_php. 2020-10-14 10:39:25 -04:00
Isaac Connor 123b2a4747 Change Event Diskspace case to not interfere with Filesystem DiskSpace 2020-09-17 15:14:54 -04:00